Changeset 1309:b3ce42a4d7d2 in lemon0.x for src/test/lp_test.cc
 Timestamp:
 04/06/05 09:24:48 (16 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1748
 File:

 1 moved
Legend:
 Unmodified
 Added
 Removed

src/test/lp_test.cc
r1295 r1309 1 #include"lp_solver_skeleton.h" 2 #include"lp_glpk.h" 3 #include<lemon/list_graph.h> 1 #include<lemon/lp_solver_skeleton.h> 2 #include<lemon/lp_glpk.h> 4 3 5 4 using namespace lemon; … … 9 8 typedef LpSolverBase LP; 10 9 11 std::vector<LP::Col> x; 12 for(int i=0;i<10;i++) x.push_back(lp.addCol()); 10 std::vector<LP::Col> x(10); 11 // for(int i=0;i<10;i++) x.push_back(lp.addCol()); 12 lp.addColSet(x); 13 13 14 14 std::vector<LP::Col> y(10); … … 124 124 lp.addRow(x[1]<=x[5]); 125 125 126 }127 126 128 129 template<class G,class C>130 double maxFlow(const G &g,const C &cap,typename G::Node s,typename G::Node t)131 {132 LpGlpk lp;133 127 134 typedef G Graph;135 typedef typename G::Node Node;136 typedef typename G::NodeIt NodeIt;137 typedef typename G::Edge Edge;138 typedef typename G::EdgeIt EdgeIt;139 typedef typename G::OutEdgeIt OutEdgeIt;140 typedef typename G::InEdgeIt InEdgeIt;141 142 typename G::template EdgeMap<LpGlpk::Col> x(g);143 lp.addColSet(x);144 145 for(EdgeIt e(g);e!=INVALID;++e) {146 lp.colUpperBound(x[e],cap[e]);147 lp.colLowerBound(x[e],0);148 }149 150 for(NodeIt n(g);n!=INVALID;++n) if(n!=s&&n!=t) {151 LpGlpk::Expr ex;152 for(InEdgeIt e(g,n);e!=INVALID;++e) ex+=x[e];153 for(OutEdgeIt e(g,n);e!=INVALID;++e) ex=x[e];154 lp.addRow(ex==0);155 }156 {157 LpGlpk::Expr ex;158 for(InEdgeIt e(g,t);e!=INVALID;++e) ex+=x[e];159 for(OutEdgeIt e(g,t);e!=INVALID;++e) ex=x[e];160 lp.setObj(ex);161 }162 163 lp.solve();164 165 return 0;166 128 } 167 129 … … 174 136 lpTest(lp_glpk); 175 137 176 ListGraph g; 177 ListGraph::Node s=g.addNode(); 178 ListGraph::Node t=g.addNode(); 179 180 ListGraph::EdgeMap<double> cap(g); 181 182 maxFlow(g,cap,s,t); 183 138 return 0; 184 139 }
Note: See TracChangeset
for help on using the changeset viewer.