Changeset 3671 for pico/trunk/src/lp/pico/PicoCpxLP.h
- Timestamp:
- 03/05/04 12:17:11 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pico/trunk/src/lp/pico/PicoCpxLP.h
r3663 r3671 36 36 bool PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>::isTimeLimitReached() const 37 37 { 38 int stat = CPXgetstat( const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(), get LpPtr() );38 int stat = CPXgetstat( const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(), getConstLpPtr() ); 39 39 #if (CPX_VERSION >= 800) 40 40 return stat == CPXMIP_TIME_LIM_INFEAS || stat == CPXMIP_TIME_LIM_FEAS; … … 48 48 bool PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>::isProvenPrimalUnbounded() const 49 49 { 50 int stat = CPXgetstat( const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(), get LpPtr() );50 int stat = CPXgetstat( const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(), getConstLpPtr() ); 51 51 #if (CPX_VERSION >= 800) 52 52 return stat == CPX_STAT_UNBOUNDED; 53 53 #else 54 int method = CPXgetmethod(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(), get LpPtr() );54 int method = CPXgetmethod(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(), getConstLpPtr() ); 55 55 // stat for version < 8 is relative to solver. If running dual simplex and stat is 56 56 // infeasible, we do not necessarily know the primal is unbounded (could be infeasible). … … 65 65 // Version 8.0 and up returns status wrt the primal only. There is no primal status that 66 66 // proves dual unboundedness. CAP. 67 int stat = CPXgetstat( const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(), get LpPtr() );67 int stat = CPXgetstat( const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(), getConstLpPtr() ); 68 68 #if (CPX_VERSION >= 800) 69 69 return false; 70 70 #else 71 int method = CPXgetmethod(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(), get LpPtr() );71 int method = CPXgetmethod(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(), getConstLpPtr() ); 72 72 // stat for version < 8 is relative to solver. If running primal simplex and stat is 73 73 // infeasible, we do not necessarily know the dual is unbounded (could be infeasible). … … 81 81 { 82 82 double ans; 83 CPXgetlb(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),&ans,whichVariable,whichVariable);83 CPXgetlb(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichVariable,whichVariable); 84 84 return ans; 85 85 } … … 90 90 { 91 91 double ans; 92 CPXgetub(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),&ans,whichVariable,whichVariable);92 CPXgetub(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichVariable,whichVariable); 93 93 return ans; 94 94 } … … 99 99 { 100 100 char sense; 101 CPXgetsense(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),&sense,whichVariable,whichVariable);101 CPXgetsense(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&sense,whichVariable,whichVariable); 102 102 double rhs; 103 CPXgetrhs(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),&rhs,whichVariable,whichVariable);103 CPXgetrhs(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&rhs,whichVariable,whichVariable); 104 104 double range; 105 CPXgetrngval(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),&range,whichVariable,whichVariable);105 CPXgetrngval(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&range,whichVariable,whichVariable); 106 106 double lower, upper; 107 107 convertSenseToBound(sense, rhs, range, lower, upper); … … 114 114 { 115 115 char sense; 116 CPXgetsense(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),&sense,whichVariable,whichVariable);116 CPXgetsense(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&sense,whichVariable,whichVariable); 117 117 double rhs; 118 CPXgetrhs(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),&rhs,whichVariable,whichVariable);118 CPXgetrhs(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&rhs,whichVariable,whichVariable); 119 119 double range; 120 CPXgetrngval(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),&range,whichVariable,whichVariable);120 CPXgetrngval(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&range,whichVariable,whichVariable); 121 121 double lower, upper; 122 122 convertSenseToBound(sense, rhs, range, lower, upper); … … 129 129 { 130 130 double rhs; 131 CPXgetrhs(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),&rhs,whichConstraint,whichConstraint);131 CPXgetrhs(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&rhs,whichConstraint,whichConstraint); 132 132 return rhs; 133 133 } … … 138 138 { 139 139 char csense; 140 CPXgetsense( const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(), &csense, whichConstraint, whichConstraint);140 CPXgetsense( const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(), &csense, whichConstraint, whichConstraint); 141 141 142 142 PicoLPInterface::constraintSense sense; … … 158 158 { 159 159 double ans; 160 int err = CPXgetobj(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),&ans,whichVariable,whichVariable);160 int err = CPXgetobj(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichVariable,whichVariable); 161 161 checkCPXerror( err, "CPXgetobj", "getObjCoefficient" ); 162 162 return ans; … … 168 168 { 169 169 double ans = 0.0; 170 int probType = CPXgetprobtype(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr());170 int probType = CPXgetprobtype(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr()); 171 171 #if (CPX_VERSION >= 800) 172 172 if ( probType == CPXPROB_MILP ) { … … 174 174 if ( probType == CPXPROB_MIP ) { 175 175 #endif 176 int err = CPXgetmipx( const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(), &ans, whichCol, whichCol);176 int err = CPXgetmipx( const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(), &ans, whichCol, whichCol); 177 177 if ( err == CPXERR_NO_INT_SOLN ) 178 178 ans = 0.0; … … 181 181 } 182 182 else { 183 int err = CPXgetx( const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(), &ans, whichCol, whichCol );183 int err = CPXgetx( const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(), &ans, whichCol, whichCol ); 184 184 if ( err == CPXERR_NO_SOLN ) 185 185 ans = 0.0; … … 195 195 { 196 196 double ans; 197 int err = CPXgetpi(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),&ans,whichRow,whichRow);197 int err = CPXgetpi(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichRow,whichRow); 198 198 if (err == CPXERR_NO_SOLN) 199 199 ans = 0.0; … … 208 208 { 209 209 double ans; 210 int err = CPXgetdj(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),&ans,whichCol,whichCol);210 int err = CPXgetdj(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(),&ans,whichCol,whichCol); 211 211 if (err == CPXERR_NO_SOLN) 212 212 ans = 0.0; … … 223 223 int basisSize = numCols + getNumRows(); 224 224 utilib::IntVector tempBasis(basisSize); 225 int tmp = CPXgetbase(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),(int*)(tempBasis.data()),(int*)(&tempBasis[numCols]));225 int tmp = CPXgetbase(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(),(int*)(tempBasis.data()),(int*)(&tempBasis[numCols])); 226 226 if (tmp) 227 227 EXCEPTION_MNGR(runtime_error,"CPLEX would not retreive basis"); … … 239 239 int numCols = getNumCols(); 240 240 utilib::IntVector tempBasis(numCols + getNumRows()); 241 int tmp = CPXgetbase(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),241 int tmp = CPXgetbase(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(), 242 242 (int*)(tempBasis.data()),(int*)(&tempBasis[numCols])); 243 243 if (tmp) … … 263 263 for (int i = 0; i < basisSize; i++) 264 264 tempBasis[i] = (int)basisBuffer(i); 265 status = CPXcopybase(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),get LpPtr(),(int*)(tempBasis.data()),265 status = CPXcopybase(const_cast<PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>*>(this)->OsiCpxSolverInterface::getEnvironmentPtr(),getConstLpPtr(),(int*)(tempBasis.data()), 266 266 (int*)(&tempBasis[getNumCols() ])); 267 267 if (status && lpWarnings) … … 360 360 // Going to getting lp pointer with default values rather than 361 361 // OsiCpxSolverInterface::FREECACHED_COLUMN, for debugging 362 int err = CPXchgbds( getEnvironmentPtr(), get LpPtr(), len, indexList, &c, upperBounds);362 int err = CPXchgbds( getEnvironmentPtr(), getConstLpPtr(), len, indexList, &c, upperBounds); 363 363 checkCPXerror( err, "CPXchgbds", "setColUpper" ); 364 364 } … … 368 368 { 369 369 char c = 'L'; 370 int err = CPXchgbds( getEnvironmentPtr(), get LpPtr(), len, indexList, &c, lowerBounds);370 int err = CPXchgbds( getEnvironmentPtr(), getConstLpPtr(), len, indexList, &c, lowerBounds); 371 371 checkCPXerror( err, "CPXchgbds", "setColLower" ); 372 372 } … … 383 383 // doesn't give the real variable names (etc) to the cplex solver, 384 384 // it will be equivalent to the "REW" filetype = generic names 385 writeStatus = CPXwriteprob(getEnvironmentPtr(), get LpPtr(), filename, "MPS");385 writeStatus = CPXwriteprob(getEnvironmentPtr(), getConstLpPtr(), filename, "MPS"); 386 386 if (writeStatus) 387 387 ucout << "Error writing lp to file\n"; … … 390 390 if (format == lp_format) 391 391 { 392 writeStatus = CPXwriteprob(getEnvironmentPtr(), get LpPtr(), filename, "LP");392 writeStatus = CPXwriteprob(getEnvironmentPtr(), getConstLpPtr(), filename, "LP"); 393 393 if (status) 394 394 ucout << "Error writing lp to file\n"; … … 402 402 void PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>::printBrokenInfo() 403 403 { 404 int stat = CPXgetstat( getEnvironmentPtr(), get LpPtr() );404 int stat = CPXgetstat( getEnvironmentPtr(), getConstLpPtr() ); 405 405 cout << "Broken LP has cplex status " << stat << "\n"; 406 406 } … … 409 409 void PicoLPSubclass<OsiCpxSolverInterface,PicoLPCutMngmnt>::setMatrixCoeff(int row, int col, double newValue) 410 410 { 411 int stat = CPXchgcoef(getEnvironmentPtr(), get LpPtr(), row, col, newValue);411 int stat = CPXchgcoef(getEnvironmentPtr(), getConstLpPtr(), row, col, newValue); 412 412 if (stat != 0) EXCEPTION_MNGR(runtime_error, "Cplex error setting matrix coefficient for (" << row << ", " << col << ")") 413 413 }