alpar@1390
|
1 |
#include<lemon/lp_skeleton.h>
|
alpar@1390
|
2 |
|
ladanyi@1387
|
3 |
#ifdef HAVE_CONFIG_H
|
ladanyi@1387
|
4 |
#include <config.h>
|
ladanyi@1387
|
5 |
#endif
|
ladanyi@1387
|
6 |
|
ladanyi@1387
|
7 |
#ifdef HAVE_GLPK
|
ladanyi@1387
|
8 |
#include <lemon/lp_glpk.h>
|
ladanyi@1387
|
9 |
#elif HAVE_CPLEX
|
ladanyi@1387
|
10 |
#include <lemon/lp_cplex.h>
|
ladanyi@1387
|
11 |
#endif
|
alpar@1254
|
12 |
|
alpar@1254
|
13 |
using namespace lemon;
|
alpar@1254
|
14 |
|
ladanyi@1387
|
15 |
#ifdef HAVE_GLPK
|
ladanyi@1387
|
16 |
typedef LpGlpk LpDefault;
|
ladanyi@1387
|
17 |
#elif HAVE_CPLEX
|
ladanyi@1387
|
18 |
typedef LpCplex LpDefault;
|
ladanyi@1387
|
19 |
#endif
|
ladanyi@1387
|
20 |
|
alpar@1263
|
21 |
void lpTest(LpSolverBase & lp)
|
alpar@1254
|
22 |
{
|
alpar@1263
|
23 |
typedef LpSolverBase LP;
|
alpar@1256
|
24 |
|
alpar@1309
|
25 |
std::vector<LP::Col> x(10);
|
alpar@1309
|
26 |
// for(int i=0;i<10;i++) x.push_back(lp.addCol());
|
alpar@1309
|
27 |
lp.addColSet(x);
|
alpar@1256
|
28 |
|
alpar@1256
|
29 |
std::vector<LP::Col> y(10);
|
alpar@1256
|
30 |
lp.addColSet(y);
|
alpar@1256
|
31 |
|
alpar@1256
|
32 |
std::map<int,LP::Col> z;
|
alpar@1256
|
33 |
|
alpar@1256
|
34 |
z.insert(std::make_pair(12,INVALID));
|
alpar@1256
|
35 |
z.insert(std::make_pair(2,INVALID));
|
alpar@1256
|
36 |
z.insert(std::make_pair(7,INVALID));
|
alpar@1256
|
37 |
z.insert(std::make_pair(5,INVALID));
|
alpar@1256
|
38 |
|
alpar@1256
|
39 |
lp.addColSet(z);
|
alpar@1256
|
40 |
|
alpar@1256
|
41 |
|
alpar@1272
|
42 |
LP::Expr e,f,g;
|
alpar@1272
|
43 |
LP::Col p1,p2,p3,p4,p5;
|
alpar@1272
|
44 |
LP::Constr c;
|
alpar@1272
|
45 |
|
alpar@1272
|
46 |
e[p1]=2;
|
alpar@1272
|
47 |
e.constComp()=12;
|
alpar@1272
|
48 |
e[p1]+=2;
|
alpar@1272
|
49 |
e.constComp()+=12;
|
alpar@1272
|
50 |
e[p1]-=2;
|
alpar@1272
|
51 |
e.constComp()-=12;
|
alpar@1272
|
52 |
|
alpar@1272
|
53 |
e=2;
|
alpar@1272
|
54 |
e=2.2;
|
alpar@1272
|
55 |
e=p1;
|
alpar@1272
|
56 |
e=f;
|
alpar@1272
|
57 |
|
alpar@1272
|
58 |
e+=2;
|
alpar@1272
|
59 |
e+=2.2;
|
alpar@1272
|
60 |
e+=p1;
|
alpar@1272
|
61 |
e+=f;
|
alpar@1272
|
62 |
|
alpar@1272
|
63 |
e-=2;
|
alpar@1272
|
64 |
e-=2.2;
|
alpar@1272
|
65 |
e-=p1;
|
alpar@1272
|
66 |
e-=f;
|
alpar@1272
|
67 |
|
alpar@1272
|
68 |
e*=2;
|
alpar@1272
|
69 |
e*=2.2;
|
alpar@1272
|
70 |
e/=2;
|
alpar@1272
|
71 |
e/=2.2;
|
alpar@1272
|
72 |
|
alpar@1272
|
73 |
e=((p1+p2)+(p1-p2)+(p1+12)+(12+p1)+(p1-12)+(12-p1)+
|
alpar@1272
|
74 |
(f+12)+(12+f)+(p1+f)+(f+p1)+(f+g)+
|
alpar@1272
|
75 |
(f-12)+(12-f)+(p1-f)+(f-p1)+(f-g)+
|
alpar@1272
|
76 |
2.2*f+f*2.2+f/2.2+
|
alpar@1272
|
77 |
2*f+f*2+f/2+
|
alpar@1272
|
78 |
2.2*p1+p1*2.2+p1/2.2+
|
alpar@1272
|
79 |
2*p1+p1*2+p1/2
|
alpar@1272
|
80 |
);
|
alpar@1272
|
81 |
|
alpar@1272
|
82 |
|
alpar@1272
|
83 |
c = (e <= f );
|
alpar@1272
|
84 |
c = (e <= 2.2);
|
alpar@1272
|
85 |
c = (e <= 2 );
|
alpar@1272
|
86 |
c = (e <= p1 );
|
alpar@1272
|
87 |
c = (2.2<= f );
|
alpar@1272
|
88 |
c = (2 <= f );
|
alpar@1272
|
89 |
c = (p1 <= f );
|
alpar@1272
|
90 |
c = (p1 <= p2 );
|
alpar@1272
|
91 |
c = (p1 <= 2.2);
|
alpar@1272
|
92 |
c = (p1 <= 2 );
|
alpar@1272
|
93 |
c = (2.2<= p2 );
|
alpar@1272
|
94 |
c = (2 <= p2 );
|
alpar@1272
|
95 |
|
alpar@1272
|
96 |
c = (e >= f );
|
alpar@1272
|
97 |
c = (e >= 2.2);
|
alpar@1272
|
98 |
c = (e >= 2 );
|
alpar@1272
|
99 |
c = (e >= p1 );
|
alpar@1272
|
100 |
c = (2.2>= f );
|
alpar@1272
|
101 |
c = (2 >= f );
|
alpar@1272
|
102 |
c = (p1 >= f );
|
alpar@1272
|
103 |
c = (p1 >= p2 );
|
alpar@1272
|
104 |
c = (p1 >= 2.2);
|
alpar@1272
|
105 |
c = (p1 >= 2 );
|
alpar@1272
|
106 |
c = (2.2>= p2 );
|
alpar@1272
|
107 |
c = (2 >= p2 );
|
alpar@1272
|
108 |
|
alpar@1272
|
109 |
c = (e == f );
|
alpar@1272
|
110 |
c = (e == 2.2);
|
alpar@1272
|
111 |
c = (e == 2 );
|
alpar@1272
|
112 |
c = (e == p1 );
|
alpar@1272
|
113 |
c = (2.2== f );
|
alpar@1272
|
114 |
c = (2 == f );
|
alpar@1272
|
115 |
c = (p1 == f );
|
alpar@1272
|
116 |
//c = (p1 == p2 );
|
alpar@1272
|
117 |
c = (p1 == 2.2);
|
alpar@1272
|
118 |
c = (p1 == 2 );
|
alpar@1272
|
119 |
c = (2.2== p2 );
|
alpar@1272
|
120 |
c = (2 == p2 );
|
alpar@1272
|
121 |
|
alpar@1272
|
122 |
c = (2 <= e <= 3);
|
alpar@1272
|
123 |
c = (2 <= p1<= 3);
|
alpar@1272
|
124 |
|
alpar@1272
|
125 |
c = (2 >= e >= 3);
|
alpar@1272
|
126 |
c = (2 >= p1>= 3);
|
alpar@1272
|
127 |
|
alpar@1256
|
128 |
e[x[3]]=2;
|
alpar@1256
|
129 |
e[x[3]]=4;
|
alpar@1256
|
130 |
e[x[3]]=1;
|
alpar@1256
|
131 |
e.constComp()=12;
|
alpar@1259
|
132 |
|
alpar@1256
|
133 |
lp.addRow(LP::INF,e,23);
|
alpar@1259
|
134 |
lp.addRow(LP::INF,3.0*(x[1]+x[2]/2)-x[3],23);
|
alpar@1259
|
135 |
lp.addRow(LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23);
|
alpar@1264
|
136 |
|
alpar@1264
|
137 |
lp.addRow(x[1]+x[3]<=x[5]-3);
|
alpar@1264
|
138 |
lp.addRow(-7<=x[1]+x[3]-12<=3);
|
alpar@1273
|
139 |
lp.addRow(x[1]<=x[5]);
|
alpar@1272
|
140 |
|
alpar@1263
|
141 |
|
alpar@1264
|
142 |
|
alpar@1264
|
143 |
}
|
alpar@1264
|
144 |
|
alpar@1263
|
145 |
int main()
|
alpar@1263
|
146 |
{
|
alpar@1390
|
147 |
LpSkeleton lp_skel;
|
alpar@1390
|
148 |
lpTest(lp_skel);
|
alpar@1390
|
149 |
|
ladanyi@1387
|
150 |
LpDefault lp;
|
alpar@1263
|
151 |
|
ladanyi@1387
|
152 |
lpTest(lp);
|
alpar@1264
|
153 |
|
alpar@1309
|
154 |
return 0;
|
alpar@1263
|
155 |
}
|