alpar@1254
|
1 |
#include"lp_solver_skeleton.h"
|
alpar@1263
|
2 |
#include"lp_glpk.h"
|
alpar@1254
|
3 |
|
alpar@1254
|
4 |
using namespace lemon;
|
alpar@1254
|
5 |
|
alpar@1263
|
6 |
void lpTest(LpSolverBase & lp)
|
alpar@1254
|
7 |
{
|
alpar@1263
|
8 |
typedef LpSolverBase LP;
|
alpar@1256
|
9 |
|
alpar@1256
|
10 |
std::vector<LP::Col> x;
|
alpar@1256
|
11 |
for(int i=0;i<10;i++) x.push_back(lp.addCol());
|
alpar@1256
|
12 |
|
alpar@1256
|
13 |
std::vector<LP::Col> y(10);
|
alpar@1256
|
14 |
lp.addColSet(y);
|
alpar@1256
|
15 |
|
alpar@1256
|
16 |
std::map<int,LP::Col> z;
|
alpar@1256
|
17 |
|
alpar@1256
|
18 |
z.insert(std::make_pair(12,INVALID));
|
alpar@1256
|
19 |
z.insert(std::make_pair(2,INVALID));
|
alpar@1256
|
20 |
z.insert(std::make_pair(7,INVALID));
|
alpar@1256
|
21 |
z.insert(std::make_pair(5,INVALID));
|
alpar@1256
|
22 |
|
alpar@1256
|
23 |
lp.addColSet(z);
|
alpar@1256
|
24 |
|
alpar@1256
|
25 |
|
alpar@1256
|
26 |
LP::Expr e;
|
alpar@1256
|
27 |
e[x[3]]=2;
|
alpar@1256
|
28 |
e[x[3]]=4;
|
alpar@1256
|
29 |
e[x[3]]=1;
|
alpar@1256
|
30 |
e.constComp()=12;
|
alpar@1259
|
31 |
|
alpar@1259
|
32 |
LP::Col p1,p2,p3,p4,p5;
|
alpar@1259
|
33 |
|
alpar@1256
|
34 |
lp.addRow(LP::INF,e,23);
|
alpar@1259
|
35 |
lp.addRow(LP::INF,3.0*(p1+p2)-p3,23);
|
alpar@1259
|
36 |
lp.addRow(LP::INF,3.0*(x[1]+x[2]/2)-x[3],23);
|
alpar@1259
|
37 |
lp.addRow(LP::INF,3.0*(p1+p2*2-5*p3+12-p4/3)+2*p4-4,23);
|
alpar@1259
|
38 |
lp.addRow(LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23);
|
alpar@1254
|
39 |
}
|
alpar@1263
|
40 |
|
alpar@1263
|
41 |
|
alpar@1263
|
42 |
int main()
|
alpar@1263
|
43 |
{
|
alpar@1263
|
44 |
LpSolverSkeleton lp_skel;
|
alpar@1263
|
45 |
LpGlpk lp_glpk;
|
alpar@1263
|
46 |
|
alpar@1263
|
47 |
lpTest(lp_skel);
|
alpar@1263
|
48 |
lpTest(lp_glpk);
|
alpar@1263
|
49 |
}
|