| 162 | |
| 163 | |
| 164 | template <> |
| 165 | void PicoLPSubclass < OsiGlpkSolverInterface, |
| 166 | PicoLPCutMngmnt >::getBasis (BasisArray & basisBuffer) const |
| 167 | { |
| 168 | LPX *model = getModelPtr (); |
| 169 | |
| 170 | /* Get the basis status for all the structural variables */ |
| 171 | for (int i = 0; i < getNumCols (); i++) |
| 172 | switch (lpx_get_col_stat (model, i + 1)) |
| 173 | { |
| 174 | case LPX_BS: |
| 175 | basisBuffer.put (i, basic); |
| 176 | break; |
| 177 | case LPX_NL:basisBuffer.put (i, atLower); |
| 178 | break; |
| 179 | case LPX_NU:basisBuffer.put (i, atUpper); |
| 180 | break; |
| 181 | default:basisBuffer.put (i, other); |
| 182 | break; |
| 183 | } |
| 184 | |
| 185 | /* Get the basis status for all the auxillary variables */ |
| 186 | for (int j = 0; j < getNumRows (); j++) |
| 187 | switch (lpx_get_row_stat (model, j + 1)) |
| 188 | { |
| 189 | case LPX_BS: |
| 190 | basisBuffer.put (getNumCols () + j, basic); |
| 191 | break; |
| 192 | case LPX_NL: |
| 193 | basisBuffer.put (getNumCols () + j, atLower); |
| 194 | break; |
| 195 | case LPX_NU: |
| 196 | basisBuffer.put (getNumCols () + j, atUpper); |
| 197 | break; |
| 198 | default: |
| 199 | basisBuffer.put (getNumCols () + j, other); |
| 200 | break; |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | template <> |
| 205 | basisState PicoLPSubclass < OsiGlpkSolverInterface, |
| 206 | PicoLPCutMngmnt >::getBasis (int whichVariable) const |
| 207 | { |
| 208 | LPX *model = getModelPtr (); |
| 209 | int var; |
| 210 | |
| 211 | // If we need an structural variable */ |
| 212 | if (whichVariable < getNumCols ()) |
| 213 | var = lpx_get_col_stat (model, whichVariable + 1); |
| 214 | else |
| 215 | var = |
| 216 | lpx_get_row_stat (model, whichVariable - getNumCols () + 1); |
| 217 | switch (var) |
| 218 | { |
| 219 | case LPX_BS: |
| 220 | return basic; |
| 221 | case LPX_NL:return atLower; |
| 222 | case LPX_NU:return atUpper; |
| 223 | default:return other; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | |
| 228 | template <> |
| 229 | void PicoLPSubclass < OsiGlpkSolverInterface, |
| 230 | PicoLPCutMngmnt >::setBasis (BasisArray & basisBuffer) |
| 231 | { |
| 232 | LPX *model = getModelPtr (); |
| 233 | |
| 234 | /* Set the basis status of all the structural variables */ |
| 235 | for (int i = 0; i < getNumCols (); i++) |
| 236 | switch (basisBuffer (i)) |
| 237 | { |
| 238 | case basic: |
| 239 | lpx_set_col_stat (model, i + 1, LPX_BS); |
| 240 | break; |
| 241 | case atLower: |
| 242 | lpx_set_col_stat (model, i + 1, LPX_NL); |
| 243 | break; |
| 244 | case atUpper: |
| 245 | lpx_set_col_stat (model, i + 1, LPX_NU); |
| 246 | break; |
| 247 | } |
| 248 | |
| 249 | /* Set the basis status for all the auxillary variables */ |
| 250 | for (int j = 0; j < getNumRows (); j++) |
| 251 | switch (basisBuffer (getNumCols () + j)) |
| 252 | { |
| 253 | case basic: |
| 254 | lpx_set_col_stat (model, j + 1, LPX_BS); |
| 255 | break; |
| 256 | case atLower: |
| 257 | lpx_set_col_stat (model, j + 1, LPX_NL); |
| 258 | break; |
| 259 | case atUpper: |
| 260 | lpx_set_col_stat (model, j + 1, LPX_NU); |
| 261 | break; |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | |
| 266 | template <> |
| 267 | priceRule PicoLPSubclass < OsiGlpkSolverInterface, |
| 268 | PicoLPCutMngmnt >::getPricingRule ()const |
| 269 | { |
| 270 | LPX *model = getModelPtr (); |
| 271 | |
| 272 | switch (lpx_get_int_parm (model, LPX_K_PRICE)) |
| 273 | { |
| 274 | /* Textbook pricing */ |
| 275 | case 0: |
| 276 | return defaultPricing; |
| 277 | /* Steepest edge pricing */ |
| 278 | case 1:return steepestEdgePricing; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | |
| 283 | template <> |
| 284 | void PicoLPSubclass < OsiGlpkSolverInterface, |
| 285 | PicoLPCutMngmnt >::setPricingRule (priceRule rule) |
| 286 | { |
| 287 | LPX *model = getModelPtr (); |
| 288 | switch (rule) |
| 289 | { |
| 290 | /* Textbook pricing */ |
| 291 | case defaultPricing: |
| 292 | lpx_set_int_parm (model, LPX_K_PRICE, 0); |
| 293 | break; |
| 294 | /* Steepest edge pricing */ |
| 295 | case steepestEdgePricing: |
| 296 | lpx_set_int_parm (model, LPX_K_PRICE, 1); |
| 297 | break; |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | |
| 302 | template <> |
| 303 | double PicoLPSubclass < OsiGlpkSolverInterface, |
| 304 | PicoLPCutMngmnt >::getTimeLimit () const |
| 305 | { |
| 306 | LPX *model = getModelPtr (); |
| 307 | return lpx_get_real_parm (model, LPX_K_TMLIM); |
| 308 | } |
| 309 | |
| 310 | |
| 311 | template <> |
| 312 | void PicoLPSubclass < OsiGlpkSolverInterface, |
| 313 | PicoLPCutMngmnt >::setTimeLimit (double time) |
| 314 | { |
| 315 | LPX *model = getModelPtr (); |
| 316 | lpx_set_real_parm (model, LPX_K_TMLIM, time); |
| 317 | } |
| 318 | |
| 319 | |
| 320 | template <> |
| 321 | clockType PicoLPSubclass < OsiGlpkSolverInterface, |
| 322 | PicoLPCutMngmnt >::getClockType ()const |
| 323 | { |
| 324 | return wallTime; |
| 325 | } |
| 326 | |
| 327 | |
| 328 | template <> |
| 329 | void PicoLPSubclass < OsiGlpkSolverInterface, |
| 330 | PicoLPCutMngmnt >::setClockType (clockType cType) |
| 331 | { |
| 332 | /* GLPK only allows a time limit to be set using the wall clock */ |
| 333 | } |
| 334 | |
| 335 | |
| 336 | |
| 337 | template <> |
| 338 | PicoLPSubclass < OsiGlpkSolverInterface, |
| 339 | PicoLPCutMngmnt >::PicoLPSubclass () |
| 340 | { |
| 341 | } |
| 342 | |
| 343 | template <> |
| 344 | void PicoLPSubclass < OsiGlpkSolverInterface, |
| 345 | PicoLPCutMngmnt >::write (char *filename, ilp_format format) |
| 346 | { |
| 347 | LPX *model = getModelPtr (); |
| 348 | |
| 349 | switch (format) |
| 350 | { |
| 351 | case mps_format: |
| 352 | case glpk_mps_format: |
| 353 | lpx_write_mps (model, filename); |
| 354 | break; |
| 355 | case cplex_mps_format: |
| 356 | lpx_write_cpxlp (model, filename); |
| 357 | break; |
| 358 | } |
| 359 | |
| 360 | } |
| 361 | |
| 362 | template <> |
| 363 | void PicoLPSubclass < OsiGlpkSolverInterface, |
| 364 | PicoLPCutMngmnt >::printBrokenInfo () |
| 365 | { |
| 366 | } |
| 367 | |
| 368 | template <> |
| 369 | void PicoLPSubclass < OsiGlpkSolverInterface, |
| 370 | PicoLPCutMngmnt >::setMatrixCoeff (int row, int col, double newValue) |
| 371 | { |
| 372 | } |
| 373 | |
| 374 | typedef PicoLPSubclass < OsiGlpkSolverInterface, |
| 375 | PicoLPCutMngmnt > PicoGlpkLP; |
| 376 | } // namespace pico |
| 377 | |
60 | | #endif |
61 | | return false; |
62 | | } |
63 | | |
64 | | |
65 | | template<> |
66 | | bool PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::isProvenDualUnbounded() const |
67 | | { |
68 | | #if 0 |
69 | | // Version 8.0 and up returns status wrt the primal only. There is no primal status that |
70 | | // proves dual unboundedness. CAP. |
71 | | #if (CPX_VERSION < 800) |
72 | | int stat = |
73 | | #endif |
74 | | CPXgetstat( const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(), getConstLpPtr() ); |
75 | | #if (CPX_VERSION >= 800) |
76 | | return false; |
77 | | #else |
78 | | int method = CPXgetmethod(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(), getConstLpPtr() ); |
79 | | // stat for version < 8 is relative to solver. If running primal simplex and stat is |
80 | | // infeasible, we do not necessarily know the dual is unbounded (could be infeasible). |
81 | | return ((method == CPX_ALG_DUAL && stat == CPX_UNBOUNDED)); |
82 | | #endif |
83 | | #endif |
84 | | return false; |
85 | | } |
86 | | |
87 | | |
88 | | template<> |
89 | | double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getColLower(int whichVariable) const |
90 | | { |
91 | | #if 0 |
92 | | double ans; |
93 | | CPXgetlb(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichVariable,whichVariable); |
94 | | return ans; |
95 | | #endif |
96 | | return -999.0; |
97 | | } |
98 | | |
99 | | |
100 | | template<> |
101 | | double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getColUpper(int whichVariable) const |
102 | | { |
103 | | #if 0 |
104 | | double ans; |
105 | | CPXgetub(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichVariable,whichVariable); |
106 | | return ans; |
107 | | #endif |
108 | | return -999.0; |
109 | | } |
110 | | |
111 | | |
112 | | template<> |
113 | | double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getRowLower(int whichVariable) const |
114 | | { |
115 | | #if 0 |
116 | | char sense; |
117 | | CPXgetsense(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&sense,whichVariable,whichVariable); |
118 | | double rhs; |
119 | | CPXgetrhs(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&rhs,whichVariable,whichVariable); |
120 | | double range; |
121 | | CPXgetrngval(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&range,whichVariable,whichVariable); |
122 | | double lower, upper; |
123 | | convertSenseToBound(sense, rhs, range, lower, upper); |
124 | | return lower; |
125 | | #endif |
126 | | return -999.0; |
127 | | } |
128 | | |
129 | | |
130 | | template<> |
131 | | double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getRowUpper(int whichVariable) const |
132 | | { |
133 | | #if 0 |
134 | | char sense; |
135 | | CPXgetsense(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&sense,whichVariable,whichVariable); |
136 | | double rhs; |
137 | | CPXgetrhs(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&rhs,whichVariable,whichVariable); |
138 | | double range; |
139 | | CPXgetrngval(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&range,whichVariable,whichVariable); |
140 | | double lower, upper; |
141 | | convertSenseToBound(sense, rhs, range, lower, upper); |
142 | | return upper; |
143 | | #endif |
144 | | return -999.0; |
145 | | } |
146 | | |
147 | | |
148 | | template<> |
149 | | double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getRightHandSide(int whichConstraint) const |
150 | | { |
151 | | #if 0 |
152 | | double rhs; |
153 | | CPXgetrhs(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&rhs,whichConstraint,whichConstraint); |
154 | | return rhs; |
155 | | #endif |
156 | | return -999.0; |
157 | | } |
158 | | |
159 | | |
160 | | template<> |
161 | | PicoLPInterface::constraintSense PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getRowSense(int whichConstraint) const |
162 | | { |
163 | | #if 0 |
164 | | char csense; |
165 | | CPXgetsense( const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(), &csense, whichConstraint, whichConstraint); |
166 | | |
167 | | PicoLPInterface::constraintSense sense = notRestricted; |
168 | | switch (csense) { |
169 | | case 'L': sense = lessOrEqual; break; |
170 | | case 'G': sense = greaterOrEqual; break; |
171 | | case 'E': sense = equal; break; |
172 | | case 'R': sense = ranged; break; |
173 | | case 'N': sense = notRestricted; break; |
174 | | default: |
175 | | EXCEPTION_MNGR(runtime_error,"PicoLPSubclass::getRowSense - bad sense type=" << csense); |
176 | | }; |
177 | | return sense; |
178 | | #endif |
179 | | return notRestricted; |
180 | | } |
181 | | |
182 | | |
183 | | template<> |
184 | | double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getObjCoefficient(int whichVariable) const |
185 | | { |
186 | | #if 0 |
187 | | double ans; |
188 | | int err = CPXgetobj(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichVariable,whichVariable); |
189 | | checkCPXerror( err, "CPXgetobj", "getObjCoefficient" ); |
190 | | return ans; |
191 | | #endif |
192 | | return -999.0; |
193 | | } |
194 | | |
195 | | |
196 | | template<> |
197 | | double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getColSolution(const int whichCol) const |
198 | | { |
199 | | #if 0 |
200 | | double ans = 0.0; |
201 | | int probType = CPXgetprobtype(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr()); |
202 | | #if (CPX_VERSION >= 800) |
203 | | if ( probType == CPXPROB_MILP ) { |
204 | | #else |
205 | | if ( probType == CPXPROB_MIP ) { |
206 | | #endif |
207 | | int err = CPXgetmipx( const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(), &ans, whichCol, whichCol); |
208 | | if ( err == CPXERR_NO_INT_SOLN ) |
209 | | ans = 0.0; |
210 | | else |
211 | | checkCPXerror( err, "CPXgetmipx", "getColSolution" ); |
212 | | } |
213 | | else { |
214 | | int err = CPXgetx( const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(), &ans, whichCol, whichCol ); |
215 | | if ( err == CPXERR_NO_SOLN ) |
216 | | ans = 0.0; |
217 | | else |
218 | | checkCPXerror( err, "CPXgetx", "getColSolution" ); |
219 | | } |
220 | | return ans; |
221 | | #endif |
222 | | return -999.0; |
223 | | } |
224 | | |
225 | | |
226 | | template<> |
227 | | double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getRowPrice(const int whichRow) const |
228 | | { |
229 | | #if 0 |
230 | | double ans; |
231 | | int err = CPXgetpi(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichRow,whichRow); |
232 | | if (err == CPXERR_NO_SOLN) |
233 | | ans = 0.0; |
234 | | else |
235 | | checkCPXerror( err, "CPXgetpi", "getRowPrice" ); |
236 | | return ans; |
237 | | #endif |
238 | | return -999.0; |
239 | | } |
240 | | |
241 | | |
242 | | template<> |
243 | | double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getReducedCost(const int whichCol) const |
244 | | { |
245 | | #if 0 |
246 | | double ans; |
247 | | int err = CPXgetdj(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichCol,whichCol); |
248 | | if (err == CPXERR_NO_SOLN) |
249 | | ans = 0.0; |
250 | | else |
251 | | checkCPXerror( err, "CPXgetdj", "getReducedCost" ); |
252 | | return ans; |
253 | | #endif |
254 | | return -999.0; |
255 | | } |
256 | | |
257 | | |
258 | | template <> |
259 | | void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getBasis(BasisArray& basisBuffer) const |
260 | | { |
261 | | #if 0 |
262 | | int numCols = getNumCols(); |
263 | | int basisSize = numCols + getNumRows(); |
264 | | utilib::IntVector tempBasis(basisSize); |
265 | | int tmp = CPXgetbase(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),(int*)(tempBasis.data()),(int*)(&tempBasis[numCols])); |
266 | | if (tmp) |
267 | | EXCEPTION_MNGR(runtime_error,"CPLEX would not retreive basis"); |
268 | | for (int i = 0; i < basisSize; i++) { |
269 | | int val = tempBasis[i]; |
270 | | if (val == 0) basisBuffer.put(i, atLower); |
271 | | else if (val == 3) basisBuffer.put(i, other); |
272 | | else basisBuffer.put(i, (basisState)val); |
273 | | } |
274 | | #endif |
275 | | } |
276 | | |
277 | | template <> |
278 | | basisState PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getBasis(int whichVariable) const |
279 | | { |
280 | | #if 0 |
281 | | int numCols = getNumCols(); |
282 | | utilib::IntVector tempBasis(numCols + getNumRows()); |
283 | | int tmp = CPXgetbase(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(), |
284 | | (int*)(tempBasis.data()),(int*)(&tempBasis[numCols])); |
285 | | if (tmp) |
286 | | EXCEPTION_MNGR(runtime_error, "PicoLPSubclass<T,V>::getBasis -- " |
287 | | "Couldn't retreive basis"); |
288 | | int val = tempBasis[whichVariable]; |
289 | | // |
290 | | // Convert to Osi standard representation for the basis |
291 | | // |
292 | | if (val == 0) return atLower; |
293 | | if (val == 3) return other; |
294 | | return (basisState)val; |
295 | | #endif |
296 | | return other; |
297 | | } |
298 | | |
299 | | |
300 | | template <> |
301 | | void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::setBasis(BasisArray& basisBuffer) |
302 | | { |
303 | | #if 0 |
304 | | static BasicArray<int> tempBasis; |
305 | | |
306 | | int basisSize = getNumRows() + getNumCols(); |
307 | | tempBasis.resize(basisSize); |
308 | | for (int i = 0; i < basisSize; i++) |
309 | | tempBasis[i] = (int)basisBuffer(i); |
310 | | status = CPXcopybase(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),getConstLpPtr(),(int*)(tempBasis.data()), |
311 | | (int*)(&tempBasis[getNumCols() ])); |
312 | | if (status && lpWarnings) |
313 | | ucout << "Warning: cplex would not load basis, status = " << status; |
314 | | else |
315 | | { |
316 | | // We may want to rethink at some point. I don't think the MIP uses this |
317 | | // and I don't think we suppress basis copying if this is false. |
318 | | have_basis = true; |
319 | | // If you change the basis, presumably there needs to be some |
320 | | // computation to make it a solution to the problem. |
321 | | myState= unsolved; |
322 | | } |
323 | | #endif |
324 | | } |
325 | | |
326 | | |
327 | | template<> |
328 | | priceRule PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getPricingRule() const |
329 | | { |
330 | | /// TODO |
331 | | return defaultPricing; |
332 | | } |
333 | | |
334 | | |
335 | | template<> |
336 | | void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::setPricingRule(priceRule rule) |
337 | | { |
338 | | /// TODO |
339 | | } |
340 | | |
341 | | |
342 | | template<> |
343 | | double PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getTimeLimit() const |
344 | | { |
345 | | #if 0 |
346 | | double ans; |
347 | | int tmp = CPXgetdblparam(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),CPX_PARAM_TILIM,&ans); |
348 | | if (tmp != 0) |
349 | | { |
350 | | EXCEPTION_MNGR(runtime_error, "Unable to get time limit"); |
351 | | } |
352 | | return ans; |
353 | | #endif |
354 | | return -999.0; |
355 | | } |
356 | | |
357 | | |
358 | | template<> |
359 | | void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::setTimeLimit(double time) |
360 | | { |
361 | | #if 0 |
362 | | int tmp = CPXsetdblparam(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),CPX_PARAM_TILIM,time); |
363 | | if (tmp) |
364 | | EXCEPTION_MNGR(runtime_error,"Unable to set time limit"); |
365 | | #endif |
366 | | } |
367 | | |
368 | | |
369 | | template<> |
370 | | clockType PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::getClockType() const |
371 | | { |
372 | | #if 0 |
373 | | int ans; |
374 | | int tmp = CPXgetintparam(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),CPX_PARAM_CLOCKTYPE,&ans); |
375 | | if (tmp != 0) |
376 | | { |
377 | | EXCEPTION_MNGR(runtime_error,"Unable to get clock type"); |
378 | | } |
379 | | if ((clockType) ans != cpuTime && (clockType)ans != wallTime) |
380 | | EXCEPTION_MNGR(runtime_error, "Unknown clock type " << ans) |
381 | | return (clockType)ans; |
382 | | #endif |
383 | | return (clockType)0.0; |
384 | | } |
385 | | |
386 | | |
387 | | template<> |
388 | | void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::setClockType(clockType cType) |
389 | | { |
390 | | #if 0 |
391 | | if (cType != cpuTime && cType != wallTime) |
392 | | EXCEPTION_MNGR(runtime_error, "Improper clock type " << cType) |
393 | | int tmp = CPXsetintparam(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(),CPX_PARAM_CLOCKTYPE, (int)cType); |
394 | | if (tmp) |
395 | | EXCEPTION_MNGR(runtime_error, "Unable to set clock type") |
396 | | #endif |
397 | | } |
398 | | |
399 | | |
400 | | |
401 | | template<> |
402 | | PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::PicoLPSubclass() |
403 | | { |
404 | | #if 0 |
405 | | solverMethod = primalSimplex; |
406 | | // TODO |
407 | | // Turn cplex preprocessing off till we handle presolve infeasibility |
408 | | // errors more gracefully |
409 | | CPXsetintparam(const_cast<PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>*>(this)->OsiGlpkSolverInterface::getEnvironmentPtr(), CPX_PARAM_PREIND, 0); |
410 | | #endif |
411 | | } |
412 | | |
413 | | template<> |
414 | | void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::write(char *filename, ilp_format format) |
415 | | { |
416 | | #if 0 |
417 | | // actually just use cplex mps and lp formats for now. |
418 | | int writeStatus; |
419 | | if (format == mps_format) |
420 | | { |
421 | | // This will write with original names, but since PICO currently |
422 | | // doesn't give the real variable names (etc) to the cplex solver, |
423 | | // it will be equivalent to the "REW" filetype = generic names |
424 | | writeStatus = CPXwriteprob(getEnvironmentPtr(), getConstLpPtr(), filename, "MPS"); |
425 | | if (writeStatus) |
426 | | ucout << "Error writing lp to file\n"; |
427 | | return; |
428 | | } |
429 | | if (format == lp_format) |
430 | | { |
431 | | writeStatus = CPXwriteprob(getEnvironmentPtr(), getConstLpPtr(), filename, "LP"); |
432 | | if (status) |
433 | | ucout << "Error writing lp to file\n"; |
434 | | return; |
435 | | } |
436 | | // default for the other formats. |
437 | | PicoLPInterface::write(filename, format); |
438 | | #endif |
439 | | } |
440 | | |
441 | | template<> |
442 | | void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::printBrokenInfo() |
443 | | { |
444 | | #if 0 |
445 | | int stat = CPXgetstat( getEnvironmentPtr(), getConstLpPtr() ); |
446 | | cout << "Broken LP has cplex status " << stat << "\n"; |
447 | | #endif |
448 | | } |
449 | | |
450 | | template<> |
451 | | void PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt>::setMatrixCoeff(int row, int col, double newValue) |
452 | | { |
453 | | #if 0 |
454 | | int stat = CPXchgcoef(getEnvironmentPtr(), getConstLpPtr(), row, col, newValue); |
455 | | if (stat != 0) EXCEPTION_MNGR(runtime_error, "Cplex error setting matrix coefficient for (" << row << ", " << col << ")") |
456 | | #endif |
457 | | } |
458 | | |
459 | | typedef PicoLPSubclass<OsiGlpkSolverInterface,PicoLPCutMngmnt> PicoGlpkLP; |
460 | | |
461 | | } // namespace pico |
462 | | |
463 | | #endif |
464 | | |
465 | | #endif |