COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/athos/lp/lp_test.cc @ 1263:a490938ad0aa

Last change on this file since 1263:a490938ad0aa was 1263:a490938ad0aa, checked in by Alpar Juttner, 20 years ago
  • LpGlpk? added to the makefile
  • missing const_cast<>() added
  • prop for two new functions (solve() and solution())
File size: 926 bytes
RevLine 
[1254]1#include"lp_solver_skeleton.h"
[1263]2#include"lp_glpk.h"
[1254]3
4using namespace lemon;
5
[1263]6void lpTest(LpSolverBase & lp)
[1254]7{
[1263]8  typedef LpSolverBase LP;
[1256]9
10  std::vector<LP::Col> x;
11  for(int i=0;i<10;i++) x.push_back(lp.addCol());
12
13  std::vector<LP::Col> y(10);
14  lp.addColSet(y);
15
16  std::map<int,LP::Col> z;
17 
18  z.insert(std::make_pair(12,INVALID));
19  z.insert(std::make_pair(2,INVALID));
20  z.insert(std::make_pair(7,INVALID));
21  z.insert(std::make_pair(5,INVALID));
22 
23  lp.addColSet(z);
24
25
26  LP::Expr e;
27  e[x[3]]=2;
28  e[x[3]]=4;
29  e[x[3]]=1;
30  e.constComp()=12;
[1259]31
32  LP::Col p1,p2,p3,p4,p5;
33 
[1256]34  lp.addRow(LP::INF,e,23);
[1259]35  lp.addRow(LP::INF,3.0*(p1+p2)-p3,23);
36  lp.addRow(LP::INF,3.0*(x[1]+x[2]/2)-x[3],23);
37  lp.addRow(LP::INF,3.0*(p1+p2*2-5*p3+12-p4/3)+2*p4-4,23);
38  lp.addRow(LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23);
[1254]39}
[1263]40
41
42int main()
43{
44  LpSolverSkeleton lp_skel;
45  LpGlpk lp_glpk;
46
47  lpTest(lp_skel);
48  lpTest(lp_glpk);
49}
Note: See TracBrowser for help on using the repository browser.