author | athos |
Thu, 26 May 2005 12:16:16 +0000 | |
changeset 1436 | e0beb94d08bf |
parent 1390 | 9c8e464ed940 |
child 1437 | 2a3f3448ced1 |
permissions | -rw-r--r-- |
1 #include<lemon/lp_skeleton.h>
3 #ifdef HAVE_CONFIG_H
4 #include <config.h>
5 #endif
7 #ifdef HAVE_GLPK
8 #include <lemon/lp_glpk.h>
9 #elif HAVE_CPLEX
10 #include <lemon/lp_cplex.h>
11 #endif
13 using namespace lemon;
15 #ifdef HAVE_GLPK
16 typedef LpGlpk LpDefault;
17 #elif HAVE_CPLEX
18 typedef LpCplex LpDefault;
19 #endif
21 void lpTest(LpSolverBase & lp)
22 {
23 typedef LpSolverBase LP;
25 std::vector<LP::Col> x(10);
26 // for(int i=0;i<10;i++) x.push_back(lp.addCol());
27 lp.addColSet(x);
29 std::vector<LP::Col> y(10);
30 lp.addColSet(y);
32 std::map<int,LP::Col> z;
34 z.insert(std::make_pair(12,INVALID));
35 z.insert(std::make_pair(2,INVALID));
36 z.insert(std::make_pair(7,INVALID));
37 z.insert(std::make_pair(5,INVALID));
39 lp.addColSet(z);
42 LP::Expr e,f,g;
43 LP::Col p1,p2,p3,p4,p5;
44 LP::Constr c;
46 e[p1]=2;
47 e.constComp()=12;
48 e[p1]+=2;
49 e.constComp()+=12;
50 e[p1]-=2;
51 e.constComp()-=12;
53 e=2;
54 e=2.2;
55 e=p1;
56 e=f;
58 e+=2;
59 e+=2.2;
60 e+=p1;
61 e+=f;
63 e-=2;
64 e-=2.2;
65 e-=p1;
66 e-=f;
68 e*=2;
69 e*=2.2;
70 e/=2;
71 e/=2.2;
73 e=((p1+p2)+(p1-p2)+(p1+12)+(12+p1)+(p1-12)+(12-p1)+
74 (f+12)+(12+f)+(p1+f)+(f+p1)+(f+g)+
75 (f-12)+(12-f)+(p1-f)+(f-p1)+(f-g)+
76 2.2*f+f*2.2+f/2.2+
77 2*f+f*2+f/2+
78 2.2*p1+p1*2.2+p1/2.2+
79 2*p1+p1*2+p1/2
80 );
83 c = (e <= f );
84 c = (e <= 2.2);
85 c = (e <= 2 );
86 c = (e <= p1 );
87 c = (2.2<= f );
88 c = (2 <= f );
89 c = (p1 <= f );
90 c = (p1 <= p2 );
91 c = (p1 <= 2.2);
92 c = (p1 <= 2 );
93 c = (2.2<= p2 );
94 c = (2 <= p2 );
96 c = (e >= f );
97 c = (e >= 2.2);
98 c = (e >= 2 );
99 c = (e >= p1 );
100 c = (2.2>= f );
101 c = (2 >= f );
102 c = (p1 >= f );
103 c = (p1 >= p2 );
104 c = (p1 >= 2.2);
105 c = (p1 >= 2 );
106 c = (2.2>= p2 );
107 c = (2 >= p2 );
109 c = (e == f );
110 c = (e == 2.2);
111 c = (e == 2 );
112 c = (e == p1 );
113 c = (2.2== f );
114 c = (2 == f );
115 c = (p1 == f );
116 //c = (p1 == p2 );
117 c = (p1 == 2.2);
118 c = (p1 == 2 );
119 c = (2.2== p2 );
120 c = (2 == p2 );
122 c = (2 <= e <= 3);
123 c = (2 <= p1<= 3);
125 c = (2 >= e >= 3);
126 c = (2 >= p1>= 3);
128 e[x[3]]=2;
129 e[x[3]]=4;
130 e[x[3]]=1;
131 e.constComp()=12;
133 lp.addRow(LP::INF,e,23);
134 lp.addRow(LP::INF,3.0*(x[1]+x[2]/2)-x[3],23);
135 lp.addRow(LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23);
137 lp.addRow(x[1]+x[3]<=x[5]-3);
138 lp.addRow(-7<=x[1]+x[3]-12<=3);
139 lp.addRow(x[1]<=x[5]);
143 }
145 int main()
146 {
147 LpSkeleton lp_skel;
148 lpTest(lp_skel);
150 LpDefault lp;
152 lpTest(lp);
154 return 0;
155 }