55 |
55 |
56 } |
56 } |
57 |
57 |
58 LpGlpk::SolveExitStatus MipGlpk::_solve(){ |
58 LpGlpk::SolveExitStatus MipGlpk::_solve(){ |
59 int result = lpx_simplex(lp); |
59 int result = lpx_simplex(lp); |
60 result = lpx_integer(lp); |
60 // |
61 switch (result){ |
61 if (lpx_get_status(lp)==LPX_OPT){ |
62 case LPX_E_OBJLL: |
62 //Maybe we could try the routine lpx_intopt(lp), a revised |
63 case LPX_E_OBJUL: |
63 //version of lpx_integer |
64 case LPX_E_ITLIM: |
64 result = lpx_integer(lp); |
65 case LPX_E_TMLIM: |
65 switch (result){ |
66 case LPX_E_OK: |
66 case LPX_E_OK: |
67 return SOLVED; |
67 return SOLVED; |
68 default: |
68 default: |
69 return UNSOLVED; |
69 return UNSOLVED; |
|
70 } |
|
71 |
70 } |
72 } |
|
73 return UNSOLVED; |
71 } |
74 } |
72 |
75 |
73 |
76 |
74 LpGlpk::SolutionStatus MipGlpk::_getMipStatus(){ |
77 LpGlpk::SolutionStatus MipGlpk::_getMipStatus(){ |
75 |
78 |
76 //Meg kell nezni: ha az LP is infinite, akkor ez is, ha az is |
79 if (lpx_get_status(lp)==LPX_OPT){ |
77 //infeasible, akkor ez is, de ez lehet maskepp is infeasible. |
80 //Meg kell nezni: ha az LP is infinite, akkor ez is, ha az is |
78 int stat= lpx_mip_status(lp); |
81 //infeasible, akkor ez is, de ez lehet maskepp is infeasible. |
79 switch (stat) { |
82 int stat= lpx_mip_status(lp); |
80 case LPX_I_UNDEF://Undefined (no solve has been run yet) |
83 |
81 return UNDEFINED; |
84 switch (stat) { |
82 case LPX_I_NOFEAS://There is no feasible integral solution (primal, I guess) |
85 case LPX_I_UNDEF://Undefined (no solve has been run yet) |
83 return INFEASIBLE; |
86 return UNDEFINED; |
84 // case LPX_UNBND://Unbounded |
87 case LPX_I_NOFEAS://There is no feasible integral solution |
85 // return INFINITE; |
88 return INFEASIBLE; |
86 case LPX_I_FEAS://Feasible |
89 // case LPX_UNBND://Unbounded |
87 return FEASIBLE; |
90 // return INFINITE; |
88 case LPX_I_OPT://Feasible |
91 case LPX_I_FEAS://Feasible |
89 return OPTIMAL; |
92 return FEASIBLE; |
90 default: |
93 case LPX_I_OPT://Feasible |
|
94 return OPTIMAL; |
|
95 default: |
91 return UNDEFINED; //to avoid gcc warning |
96 return UNDEFINED; //to avoid gcc warning |
92 //FIXME error |
97 //FIXME error |
|
98 } |
93 } |
99 } |
|
100 else |
|
101 return UNDEFINED; //Maybe we could refine this: what does the LP |
|
102 //relaxation look like |
|
103 |
94 } |
104 } |
95 |
105 |
96 MipGlpk::Value MipGlpk::_getPrimal(int i){ |
106 MipGlpk::Value MipGlpk::_getPrimal(int i){ |
97 return lpx_mip_col_val(lp,i); |
107 return lpx_mip_col_val(lp,i); |
98 } |
108 } |