19 ///\file |
19 ///\file |
20 ///\brief Implementation of the LEMON-CPLEX lp solver interface. |
20 ///\brief Implementation of the LEMON-CPLEX lp solver interface. |
21 namespace lemon { |
21 namespace lemon { |
22 |
22 |
23 LpCplex::LpCplex() : LpSolverBase() { |
23 LpCplex::LpCplex() : LpSolverBase() { |
24 env = NULL; |
24 |
25 lp = NULL; |
25 // env = CPXopenCPLEXdevelop(&status); |
26 env = CPXopenCPLEXdevelop(&status); |
26 env = CPXopenCPLEX(&status); |
27 // if (Env == NULL) |
|
28 // { |
|
29 // fprintf(stderr,"A CPLEX környezet megnyitása sikertelen.\n"); |
|
30 // CPXgeterrorstring(Env, Status, ErrorMsg); |
|
31 // fprintf(stderr,"%s",ErrorMsg); |
|
32 // goto Terminate; |
|
33 // } |
|
34 |
|
35 // *** A problema létrehozása *** |
|
36 lp = CPXcreateprob(env, &status, "LP problem"); |
27 lp = CPXcreateprob(env, &status, "LP problem"); |
37 |
28 //CPXmsg (cpxresults, "Hello-bello\n"); |
38 // if (Problem == NULL) |
|
39 // { |
|
40 // fprintf(stderr,"Az LP létrehozása sikertelen"); |
|
41 // goto Terminate; |
|
42 // } |
|
43 |
|
44 } |
29 } |
45 |
30 |
46 LpCplex::~LpCplex() { |
31 LpCplex::~LpCplex() { |
47 status = CPXfreeprob(env,&lp); |
32 CPXfreeprob(env,&lp); |
48 // if (Status != 0) |
33 CPXcloseCPLEX(&env); |
49 // { |
|
50 // fprintf(stderr,"A CPLEX feladat törlése sikertelen.\n"); |
|
51 // CPXgeterrorstring(Env, Status, ErrorMsg); |
|
52 // fprintf(stderr,"%s",ErrorMsg); |
|
53 // goto Terminate; |
|
54 // } |
|
55 |
|
56 status = CPXcloseCPLEX(&env); |
|
57 // if (Status != 0) |
|
58 // { |
|
59 // fprintf(stderr,"A CPLEX környezet bezárása sikertelen.\n"); |
|
60 // CPXgeterrorstring(Env, Status, ErrorMsg); |
|
61 // fprintf(stderr,"%s",ErrorMsg); |
|
62 // goto Terminate; |
|
63 // } |
|
64 |
|
65 } |
34 } |
66 |
35 |
67 LpSolverBase &LpCplex::_newLp() |
36 LpSolverBase &LpCplex::_newLp() |
68 { |
37 { |
69 return *(LpSolverBase*)0; |
38 //The first approach opens a new environment |
70 } |
39 LpCplex* newlp=new LpCplex(); |
|
40 return *newlp; |
|
41 } |
|
42 |
71 LpSolverBase &LpCplex::_copyLp() { |
43 LpSolverBase &LpCplex::_copyLp() { |
72 return *(LpSolverBase*)0; |
44 //The first approach opens a new environment |
73 //Ez lesz majd CPXcloneprob (env, lp, &status); |
45 LpCplex* newlp=new LpCplex(); |
|
46 //The routine CPXcloneprob can be used to create a new CPLEX problem |
|
47 //object and copy all the problem data from an existing problem |
|
48 //object to it. Solution and starting information is not copied. |
|
49 newlp->lp = CPXcloneprob (env, lp, &status); |
|
50 return *newlp; |
74 } |
51 } |
75 |
52 |
76 int LpCplex::_addCol() |
53 int LpCplex::_addCol() |
77 { |
54 { |
78 int i = CPXgetnumcols (env, lp); |
55 int i = CPXgetnumcols (env, lp); |
80 lb[0]=-INF;//-CPX_INFBOUND; |
57 lb[0]=-INF;//-CPX_INFBOUND; |
81 ub[0]=INF;//CPX_INFBOUND; |
58 ub[0]=INF;//CPX_INFBOUND; |
82 status = CPXnewcols (env, lp, 1, NULL, lb, ub, NULL, NULL); |
59 status = CPXnewcols (env, lp, 1, NULL, lb, ub, NULL, NULL); |
83 return i; |
60 return i; |
84 } |
61 } |
|
62 |
85 |
63 |
86 int LpCplex::_addRow() |
64 int LpCplex::_addRow() |
87 { |
65 { |
88 //We want a row that is not constrained |
66 //We want a row that is not constrained |
89 char sense[1]; |
67 char sense[1]; |
95 return i; |
73 return i; |
96 } |
74 } |
97 |
75 |
98 |
76 |
99 void LpCplex::_eraseCol(int i) { |
77 void LpCplex::_eraseCol(int i) { |
100 ///\todo Not implemented yet |
78 CPXdelcols (env, lp, i, i); |
101 } |
79 } |
102 |
80 |
103 void LpCplex::_eraseRow(int i) { |
81 void LpCplex::_eraseRow(int i) { |
104 ///\todo Not implemented yet |
82 CPXdelrows (env, lp, i, i); |
105 } |
83 } |
106 |
84 |
107 |
85 |
108 ///\warning Data at index 0 is ignored in the arrays. |
86 ///\warning Data at index 0 is ignored in the arrays. |
109 void LpCplex::_setRowCoeffs(int i, |
87 void LpCplex::_setRowCoeffs(int i, |