34 #define STRONGBRANCH_RESTOREBASIS
43 #define CHECK_SPXSOLVE true
44 #define CHECK_SPXSTRONGBRANCH true
46 #define EXIT_AT_WRONG_RESULT false
47 #define EXIT_AT_CPXERROR false
49 #define CPX_CALL(x) do \
52 if( (_cpxstat_ = (x)) != 0 ) \
54 SCIPmessagePrintWarning(_messagehdlr, "CPLEX error <%d>; SoPlex result unchecked\n", _cpxstat_); \
55 if( EXIT_AT_CPXERROR ) \
78 #ifndef SOPLEX_SUBVERSION
79 #define SOPLEX_SUBVERSION 0
84 #if (SOPLEX_VERSION < 172 || (SOPLEX_VERSION == 172 && SOPLEX_SUBVERSION < 8))
85 #error "This interface is not compatible with SoPlex versions prior to 1.7.2.8"
88 #include "spxgithash.h"
97 #define SOPLEX_VERBLEVEL 5
110 using namespace soplex;
118 #define SOPLEX_TRY(messagehdlr, x) do \
124 catch(SPxException E) \
126 std::string s = E.what(); \
127 SCIPmessagePrintWarning((messagehdlr), "SoPlex threw an exception: %s\n", s.c_str()); \
128 return SCIP_LPERROR; \
134 #define SOPLEX_TRY(messagehdlr, x) do \
140 catch(SPxException E) \
142 return SCIP_LPERROR; \
148 #define SOPLEX_TRYLPI(x) SOPLEX_TRY(lpi->messagehdlr, x)
149 #define SOPLEX_TRYLPIPTR(x) SOPLEX_TRY((*lpi)->messagehdlr, x)
154 #define SOPLEX_TRY_ABORT(x) do \
160 catch(SPxException E) \
162 std::string s = E.what(); \
163 SCIPerrorMessage("SoPlex threw an exception: %s\n", s.c_str()); \
172 class SPxSCIP :
public SoPlex
177 SPxSolver::VarStatus* _colStat;
178 SPxSolver::VarStatus* _rowStat;
190 const char* probname =
NULL
197 _messagehdlr(messagehdlr)
199 if ( probname !=
NULL )
205 _doublecheck =
false;
206 _cpxenv = CPXopenCPLEX(&cpxstat);
207 assert(_cpxenv !=
NULL);
208 _cpxlp = CPXcreateprob(_cpxenv, &cpxstat, probname !=
NULL ? probname :
"spxcheck");
209 (void) CPXsetintparam(_cpxenv, CPX_PARAM_SCRIND, 0);
215 if( _probname !=
NULL )
218 freePreStrongbranchingBasis();
221 (void) CPXfreeprob(_cpxenv, &_cpxlp);
222 (void) CPXcloseCPLEX(&_cpxenv);
230 return realParam(FEASTOL);
238 setRealParam(FEASTOL, d);
244 return realParam(OPTTOL);
252 setRealParam(OPTTOL, d);
256 Real getObjLimit()
const
258 return (intParam(SoPlex::OBJSENSE) == SoPlex::OBJSENSE_MINIMIZE)
259 ? realParam(SoPlex::OBJLIMIT_UPPER)
260 : realParam(SoPlex::OBJLIMIT_LOWER);
264 bool getFromScratch()
const
269 void setFromScratch(
bool fs)
275 bool getLpInfo()
const
280 void setLpInfo(
bool lpinfo)
286 void setProbname(
const char* probname)
290 assert(probname !=
NULL);
291 if( _probname !=
NULL )
293 len = (int)strlen(probname);
294 spx_alloc(_probname, len + 1);
295 strncpy(_probname, probname, len);
296 _probname[len] =
'\0';
299 void setRep(SPxSolver::Representation p_rep)
301 if( p_rep == SPxSolver::COLUMN && intParam(REPRESENTATION) == REPRESENTATION_ROW )
304 setIntParam(REPRESENTATION, REPRESENTATION_COLUMN);
306 else if( (p_rep == SPxSolver::ROW && intParam(REPRESENTATION) == REPRESENTATION_COLUMN) )
309 setIntParam(REPRESENTATION, REPRESENTATION_ROW);
314 bool getDoubleCheck()
317 return _doublecheck && _checknum + 1 >= CHECK_START;
320 void setDoubleCheck(
bool dc)
325 const char* spxStatusString(
const SPxSolver::Status stat)
329 case SPxSolver::ABORT_TIME:
331 case SPxSolver::ABORT_ITER:
333 case SPxSolver::ABORT_VALUE:
334 return "ABORT_VALUE";
335 case SPxSolver::SINGULAR:
337 case SPxSolver::REGULAR:
339 case SPxSolver::UNKNOWN:
341 case SPxSolver::OPTIMAL:
343 case SPxSolver::UNBOUNDED:
345 case SPxSolver::INFEASIBLE:
354 const char* cpxStatusString(
const int stat)
358 case CPX_STAT_ABORT_TIME_LIM:
360 case CPX_STAT_ABORT_IT_LIM:
362 case CPX_STAT_ABORT_OBJ_LIM:
363 return "ABORT_VALUE";
364 case CPX_STAT_OPTIMAL:
366 case CPX_STAT_OPTIMAL_INFEAS:
367 return "CPX_STAT_OPTIMAL_INFEAS: OPT SOL INFEASIBLE AFTER UNSCALING";
368 case CPX_STAT_UNBOUNDED:
370 case CPX_STAT_INFEASIBLE:
372 case CPX_STAT_INForUNBD:
373 return "INFEASIBLE or UNBOUNDED";
374 case CPX_STAT_NUM_BEST:
375 return "CPX_STAT_NUM_BEST: SOL AVAILABLE BUT NOT PROVEN OPTIMAL DUE TO NUM TROUBLE";
385 bool checkConsistentBounds()
387 for(
int i = 0; i < numColsReal(); ++i )
389 if( lowerReal(i) > upperReal(i) )
391 SCIPerrorMessage(
"inconsistent bounds on column %d: lower=%.17g, upper=%.17g\n",
392 i, lowerReal(i), upperReal(i));
400 bool checkConsistentSides()
402 for(
int i = 0; i < numRowsReal(); ++i )
404 if( lhsReal(i) > rhsReal(i) )
407 i, lhsReal(i), rhsReal(i));
416 void trySolve(
bool printwarning =
true)
425 catch(SPxException x)
427 std::string s = x.what();
437 assert(status() != SPxSolver::OPTIMAL);
440 assert(intParam(ITERLIMIT) < 0 || numIterations() <= intParam(ITERLIMIT));
443 timespent = solveTime();
447 timelimit = realParam(TIMELIMIT);
448 if( timelimit > timespent )
449 timelimit -= timespent;
453 assert(timelimit >= 0);
454 setRealParam(TIMELIMIT, timelimit);
458 virtual SPxSolver::Status doSolve(
bool printwarning =
true)
462 SPxSolver::Status spxStatus;
465 verbosity = Param::verbose();
468 assert(checkConsistentBounds());
469 assert(checkConsistentSides());
473 if( getDoubleCheck() )
474 writeStateReal(
"spxcheck",
NULL,
NULL);
477 trySolve(printwarning);
478 spxStatus = status();
484 bool minimize = intParam(OBJSENSE) == OBJSENSE_MINIMIZE;
485 Real objLimitUpper = realParam(OBJLIMIT_UPPER);
486 Real objLimitLower = realParam(OBJLIMIT_LOWER);
489 if( getDoubleCheck() && (spxStatus == SPxSolver::OPTIMAL || spxStatus == SPxSolver::UNBOUNDED || spxStatus == SPxSolver::INFEASIBLE || spxStatus == SPxSolver::ABORT_VALUE) )
495 CPX_CALL( CPXreadcopyprob(_cpxenv, _cpxlp,
"spxcheck.mps",
NULL) );
496 CPX_CALL( CPXreadcopybase(_cpxenv, _cpxlp,
"spxcheck.bas") );
499 CPX_CALL( CPXsetdblparam(_cpxenv, CPX_PARAM_EPOPT,
MAX(opttol(), 1e-9)) );
500 CPX_CALL( CPXsetdblparam(_cpxenv, CPX_PARAM_EPRHS,
MAX(feastol(), 1e-9)) );
503 CPX_CALL( CPXlpopt(_cpxenv, _cpxlp) );
506 CPX_CALL( CPXsolution(_cpxenv, _cpxlp, &cpxstat, &cpxobj,
NULL,
NULL,
NULL,
NULL) );
511 if( cpxstat == CPX_STAT_OPTIMAL_INFEAS )
513 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s)\n",
514 _probname, spxStatus, spxStatusString(spxStatus), cpxstat, cpxStatusString(cpxstat));
515 if( EXIT_AT_CPXERROR )
518 else if( (spxStatus == SPxSolver::OPTIMAL && cpxstat != CPX_STAT_OPTIMAL)
519 || (spxStatus == SPxSolver::UNBOUNDED && cpxstat != CPX_STAT_UNBOUNDED)
520 || (spxStatus == SPxSolver::INFEASIBLE && cpxstat != CPX_STAT_INFEASIBLE) )
522 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
523 _probname, spxStatus, spxStatusString(spxStatus), cpxstat, cpxStatusString(cpxstat), _checknum);
524 if( EXIT_AT_WRONG_RESULT )
527 else if( spxStatus == SPxSolver::ABORT_VALUE )
531 case CPX_STAT_OPTIMAL:
532 if( (minimize && LTrel(cpxobj, objLimitUpper, 2*opttol()))
533 || (!minimize && GTrel(cpxobj, objLimitLower, 2*opttol())) )
535 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
536 _probname, spxStatus, spxStatusString(spxStatus), cpxobj, minimize ?
"<" :
">",
537 minimize ? objLimitUpper : objLimitLower, cpxStatusString(cpxstat), _checknum);
538 if( EXIT_AT_WRONG_RESULT )
541 else if( (minimize && cpxobj < objLimitUpper) || (!minimize && cpxobj > objLimitLower) )
543 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
544 _probname, spxStatus, spxStatusString(spxStatus), cpxobj, minimize?
"<" :
">",
545 minimize ? objLimitUpper : objLimitLower, cpxStatusString(cpxstat), _checknum);
548 case CPX_STAT_OPTIMAL_INFEAS:
549 case CPX_STAT_NUM_BEST:
550 if( (minimize && cpxobj < objLimitUpper) || (!minimize && cpxobj > objLimitLower) )
552 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
553 _probname, spxStatus, spxStatusString(spxStatus), cpxobj, minimize ?
"<" :
">",
554 minimize ? objLimitUpper : objLimitLower, cpxStatusString(cpxstat), _checknum);
557 case CPX_STAT_INFEASIBLE:
559 case CPX_STAT_UNBOUNDED:
560 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
561 _probname, spxStatus, spxStatusString(spxStatus), cpxstat, cpxStatusString(cpxstat), _checknum);
562 if( EXIT_AT_WRONG_RESULT )
565 case CPX_STAT_INForUNBD:
567 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
568 _probname, spxStatus, spxStatusString(spxStatus), cpxstat, cpxStatusString(cpxstat), _checknum);
573 else if( spxStatus == SPxSolver::OPTIMAL )
575 if( (minimize && LTrel(objValueReal(), cpxobj, 2*opttol()))
576 || (!minimize && GTrel(objValueReal(), cpxobj, 2*opttol())) )
581 else if( (minimize && GTrel(objValueReal(), cpxobj, 2*opttol()))
582 || (!minimize && LTrel(objValueReal(), cpxobj, 2*opttol())) )
584 SCIPerrorMessage(
"In %s: LP optimal; SoPlex value=%.10f %s CPLEX value=%.10f suboptimal (checknum=%d)\n", objValueReal(),
585 _probname, minimize ?
">" :
"<", cpxobj, _checknum);
586 if( EXIT_AT_WRONG_RESULT )
596 Param::setVerbose(verbosity);
602 void savePreStrongbranchingBasis()
604 assert(_rowStat ==
NULL);
605 assert(_colStat ==
NULL);
607 spx_alloc(_rowStat, numRowsReal());
608 spx_alloc(_colStat, numColsReal());
612 getBasis(_rowStat, _colStat);
614 catch(SPxException x)
617 std::string s = x.what();
624 assert(status() != SPxSolver::OPTIMAL);
630 void restorePreStrongbranchingBasis()
632 assert(_rowStat !=
NULL);
633 assert(_colStat !=
NULL);
637 setBasis(_rowStat, _colStat);
639 catch(SPxException x)
642 std::string s = x.what();
649 assert(status() != SPxSolver::OPTIMAL);
654 void freePreStrongbranchingBasis()
656 if( _rowStat !=
NULL )
658 if( _colStat !=
NULL )
663 bool preStrongbranchingBasisFreed()
665 return ((_rowStat ==
NULL ) && (_colStat ==
NULL));
678 #include "scip/bitencode.h"
681 #define COLS_PER_PACKET SCIP_DUALPACKETSIZE
683 #define ROWS_PER_PACKET SCIP_DUALPACKETSIZE
728 if( num > lpi->cstatsize )
732 newsize =
MAX(2*lpi->cstatsize, num);
733 SCIP_ALLOC( BMSreallocMemoryArray(&lpi->cstat, newsize) );
734 lpi->cstatsize = newsize;
736 assert(num <= lpi->cstatsize);
750 if( num > lpi->rstatsize )
754 newsize =
MAX(2*lpi->rstatsize, num);
755 SCIP_ALLOC( BMSreallocMemoryArray(&lpi->rstat, newsize) );
756 lpi->rstatsize = newsize;
758 assert(num <= lpi->rstatsize);
796 assert(lpistate !=
NULL);
797 assert(lpistate->packcstat !=
NULL);
798 assert(lpistate->packrstat !=
NULL);
800 SCIPencodeDualBit(cstat, lpistate->packcstat, lpistate->ncols);
801 SCIPencodeDualBit(rstat, lpistate->packrstat, lpistate->nrows);
812 assert(lpistate !=
NULL);
813 assert(lpistate->packcstat !=
NULL);
814 assert(lpistate->packrstat !=
NULL);
816 SCIPdecodeDualBit(lpistate->packcstat, cstat, lpistate->ncols);
817 SCIPdecodeDualBit(lpistate->packrstat, rstat, lpistate->nrows);
829 assert(lpistate !=
NULL);
830 assert(blkmem !=
NULL);
834 SCIP_ALLOC( BMSallocBlockMemory(blkmem, lpistate) );
835 SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*lpistate)->packcstat, colpacketNum(ncols)) );
836 SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*lpistate)->packrstat, rowpacketNum(nrows)) );
848 assert(blkmem !=
NULL);
849 assert(lpistate !=
NULL);
850 assert(*lpistate !=
NULL);
852 BMSfreeBlockMemoryArray(blkmem, &(*lpistate)->packcstat, colpacketNum((*lpistate)->ncols));
853 BMSfreeBlockMemoryArray(blkmem, &(*lpistate)->packrstat, rowpacketNum((*lpistate)->nrows));
854 BMSfreeBlockMemory(blkmem, lpistate);
867 void invalidateSolution(
SCIP_LPI* lpi)
884 static char spxname[100];
885 static char spxdesc[200];
897 #if (SOPLEX_SUBVERSION > 0)
898 sprintf(spxname,
"SoPlex2 %d.%d.%d.%d", SOPLEX_VERSION/100, (SOPLEX_VERSION % 100)/10, SOPLEX_VERSION % 10,
SOPLEX_SUBVERSION);
900 sprintf(spxname,
"SoPlex2 %d.%d.%d", SOPLEX_VERSION/100, (SOPLEX_VERSION % 100)/10, SOPLEX_VERSION % 10);
910 sprintf(spxdesc,
"%s",
"Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de)");
911 sprintf(spxdesc,
"%s [GitHash: %s]", spxdesc, getGitHash());
913 sprintf(spxdesc,
"%s %s", spxdesc,
"- including CPLEX double check");
923 return (
void*) lpi->spx;
951 (*lpi)->spx =
static_cast<SPxSCIP*
>(BMSallocMemoryCPP(
sizeof(SPxSCIP)));
952 SOPLEX_TRY( messagehdlr, (*lpi)->spx = new ((*lpi)->spx) SPxSCIP(messagehdlr, name) );
953 (*lpi)->cstat =
NULL;
954 (*lpi)->rstat =
NULL;
955 (*lpi)->cstatsize = 0;
956 (*lpi)->rstatsize = 0;
959 (*lpi)->conditionlimit = -1.0;
960 (*lpi)->checkcondition =
FALSE;
961 (*lpi)->messagehdlr = messagehdlr;
963 invalidateSolution(*lpi);
972 int verbosity = Param::verbose();
974 (*lpi)->spx->printVersion();
975 Param::setVerbose(verbosity);
987 assert(*lpi !=
NULL);
988 assert((*lpi)->spx !=
NULL);
991 (*lpi)->spx->~SPxSCIP();
992 BMSfreeMemory(&((*lpi)->spx));
995 BMSfreeMemoryArrayNull(&(*lpi)->cstat);
996 BMSfreeMemoryArrayNull(&(*lpi)->rstat);
1035 assert(lpi !=
NULL);
1036 assert(lpi->spx !=
NULL);
1037 assert(lhs !=
NULL);
1038 assert(rhs !=
NULL);
1040 invalidateSolution(lpi);
1041 assert(lpi->spx->preStrongbranchingBasisFreed());
1045 SPxSCIP* spx = lpi->spx;
1046 LPRowSet rows(nrows);
1047 DSVector emptyVector(0);
1053 spx->setIntParam(SoPlex::OBJSENSE, (objsen ==
SCIP_OBJSEN_MINIMIZE ? SoPlex::OBJSENSE_MINIMIZE : SoPlex::OBJSENSE_MAXIMIZE));
1056 for( i = 0; i < nrows; ++i )
1057 rows.add(lhs[i], emptyVector, rhs[i]);
1058 spx->addRowsReal(rows);
1063 catch(SPxException x)
1066 std::string s = x.what();
1091 assert(lpi !=
NULL);
1092 assert(lpi->spx !=
NULL);
1093 assert(obj !=
NULL);
1096 assert(nnonz == 0 || beg !=
NULL);
1097 assert(nnonz == 0 || ind !=
NULL);
1098 assert(nnonz == 0 || val !=
NULL);
1100 invalidateSolution(lpi);
1102 assert( lpi->spx->preStrongbranchingBasisFreed() );
1104 SPxSCIP* spx = lpi->spx;
1107 LPColSet cols(ncols);
1108 DSVector colVector(ncols);
1114 for( i = 0; i < ncols; ++i )
1120 last = (i == ncols-1 ? nnonz : beg[i+1]);
1121 colVector.add( last-start, &ind[start], &val[start] );
1123 cols.add(obj[i], lb[i], colVector, ub[i]);
1125 spx->addColsReal(cols);
1127 catch(SPxException x)
1130 std::string s = x.what();
1148 assert(lpi !=
NULL);
1149 assert(lpi->spx !=
NULL);
1150 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->numColsReal());
1152 invalidateSolution(lpi);
1154 assert( lpi->spx->preStrongbranchingBasisFreed() );
1156 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->removeColRangeReal(firstcol, lastcol) );
1174 assert(lpi !=
NULL);
1175 assert(lpi->spx !=
NULL);
1177 invalidateSolution(lpi);
1179 assert( lpi->spx->preStrongbranchingBasisFreed() );
1181 ncols = lpi->spx->numColsReal();
1184 for( i = 0; i < ncols; ++i )
1187 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->removeColsReal(dstat) );
1207 assert(lpi !=
NULL);
1208 assert(lpi->spx !=
NULL);
1209 assert(lhs !=
NULL);
1210 assert(rhs !=
NULL);
1211 assert(nnonz == 0 || beg !=
NULL);
1212 assert(nnonz == 0 || ind !=
NULL);
1213 assert(nnonz == 0 || val !=
NULL);
1215 invalidateSolution(lpi);
1217 assert( lpi->spx->preStrongbranchingBasisFreed() );
1221 SPxSCIP* spx = lpi->spx;
1222 LPRowSet rows(nrows);
1229 for( i = 0; i < nrows; ++i )
1235 last = (i == nrows-1 ? nnonz : beg[i+1]);
1236 rowVector.add( last-start, &ind[start], &val[start] );
1238 rows.add(lhs[i], rowVector, rhs[i]);
1240 spx->addRowsReal(rows);
1242 catch(SPxException x)
1245 std::string s = x.what();
1263 assert(lpi !=
NULL);
1264 assert(lpi->spx !=
NULL);
1265 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->numRowsReal());
1267 invalidateSolution(lpi);
1269 assert( lpi->spx->preStrongbranchingBasisFreed() );
1271 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->removeRowRangeReal(firstrow, lastrow) );
1289 assert(lpi !=
NULL);
1290 assert(lpi->spx !=
NULL);
1292 invalidateSolution(lpi);
1294 assert( lpi->spx->preStrongbranchingBasisFreed() );
1296 nrows = lpi->spx->numRowsReal();
1299 for( i = 0; i < nrows; ++i )
1302 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->removeRowsReal(dstat) );
1314 assert(lpi !=
NULL);
1315 assert(lpi->spx !=
NULL);
1317 invalidateSolution(lpi);
1319 assert( lpi->spx->preStrongbranchingBasisFreed() );
1320 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->clearLPReal() );
1338 assert(lpi !=
NULL);
1339 assert(lpi->spx !=
NULL);
1340 assert(ind !=
NULL);
1344 invalidateSolution(lpi);
1346 assert( lpi->spx->preStrongbranchingBasisFreed() );
1350 for( i = 0; i < ncols; ++i )
1352 assert(0 <= ind[i] && ind[i] < lpi->spx->numColsReal());
1353 lpi->spx->changeBoundsReal(ind[i], lb[i], ub[i]);
1354 assert(lpi->spx->lowerReal(ind[i]) <= lpi->spx->upperReal(ind[i]));
1357 catch(SPxException x)
1360 std::string s = x.what();
1382 assert(lpi !=
NULL);
1383 assert(lpi->spx !=
NULL);
1384 assert(ind !=
NULL);
1385 assert(lhs !=
NULL);
1386 assert(rhs !=
NULL);
1388 invalidateSolution(lpi);
1390 assert( lpi->spx->preStrongbranchingBasisFreed() );
1394 for( i = 0; i < nrows; ++i )
1396 assert(0 <= ind[i] && ind[i] < lpi->spx->numRowsReal());
1397 lpi->spx->changeRangeReal(ind[i], lhs[i], rhs[i]);
1398 assert(lpi->spx->lhsReal(ind[i]) <= lpi->spx->rhsReal(ind[i]));
1401 catch(SPxException x)
1404 std::string s = x.what();
1423 assert(lpi !=
NULL);
1424 assert(lpi->spx !=
NULL);
1425 assert(0 <= row && row < lpi->spx->numRowsReal());
1426 assert(0 <= col && col < lpi->spx->numColsReal());
1428 invalidateSolution(lpi);
1430 assert( lpi->spx->preStrongbranchingBasisFreed() );
1432 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->changeElementReal(row, col, newval) );
1445 assert(lpi !=
NULL);
1446 assert(lpi->spx !=
NULL);
1448 invalidateSolution(lpi);
1450 assert( lpi->spx->preStrongbranchingBasisFreed() );
1452 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->setIntParam(SoPlex::OBJSENSE, objsen ==
SCIP_OBJSEN_MINIMIZE ? SoPlex::OBJSENSE_MINIMIZE : SoPlex::OBJSENSE_MAXIMIZE ) );
1469 assert(lpi !=
NULL);
1470 assert(lpi->spx !=
NULL);
1471 assert(ind !=
NULL);
1472 assert(obj !=
NULL);
1474 invalidateSolution(lpi);
1476 assert( lpi->spx->preStrongbranchingBasisFreed() );
1480 for( i = 0; i < ncols; ++i )
1482 assert(0 <= ind[i] && ind[i] < lpi->spx->numColsReal());
1483 lpi->spx->changeObjReal(ind[i], obj[i]);
1486 catch(SPxException x)
1489 std::string s = x.what();
1510 assert(lpi !=
NULL);
1511 assert(lpi->spx !=
NULL);
1512 assert(scaleval != 0.0);
1516 invalidateSolution(lpi);
1518 assert( lpi->spx->preStrongbranchingBasisFreed() );
1521 SVector rowvec = lpi->spx->rowVectorReal(row);
1522 lhs = lpi->spx->lhsReal(row);
1523 rhs = lpi->spx->rhsReal(row);
1529 if( lhs > -lpi->spx->realParam(SoPlex::INFTY) )
1531 else if( scaleval < 0.0 )
1532 lhs = lpi->spx->realParam(SoPlex::INFTY);
1533 if( rhs < lpi->spx->realParam(SoPlex::INFTY) )
1535 else if( scaleval < 0.0 )
1536 rhs = -lpi->spx->realParam(SoPlex::INFTY);
1537 if( scaleval < 0.0 )
1545 LPRow lprow(lhs, rowvec, rhs);
1548 lpi->spx->changeRowReal(row, lprow);
1549 assert(lpi->spx->lhsReal(row) <= lpi->spx->rhsReal(row));
1551 catch(SPxException x)
1554 std::string s = x.what();
1578 assert(lpi !=
NULL);
1579 assert(lpi->spx !=
NULL);
1580 assert(scaleval != 0.0);
1584 invalidateSolution(lpi);
1586 assert( lpi->spx->preStrongbranchingBasisFreed() );
1589 SVector colvec = lpi->spx->colVectorReal(col);
1590 obj = lpi->spx->objReal(col);
1591 lb = lpi->spx->lowerReal(col);
1592 ub = lpi->spx->upperReal(col);
1601 if( lb > -lpi->spx->realParam(SoPlex::INFTY) )
1603 else if( scaleval < 0.0 )
1604 lb = lpi->spx->realParam(SoPlex::INFTY);
1605 if( ub < lpi->spx->realParam(SoPlex::INFTY) )
1607 else if( scaleval < 0.0 )
1608 ub = -lpi->spx->realParam(SoPlex::INFTY);
1609 if( scaleval < 0.0 )
1617 LPCol lpcol(obj, colvec, ub, lb);
1620 lpi->spx->changeColReal(col, lpcol);
1621 assert(lpi->spx->lowerReal(col) <= lpi->spx->upperReal(col));
1623 catch(SPxException x)
1626 std::string s = x.what();
1655 assert(lpi !=
NULL);
1656 assert(lpi->spx !=
NULL);
1657 assert(nrows !=
NULL);
1659 *nrows = lpi->spx->numRowsReal();
1672 assert(lpi !=
NULL);
1673 assert(lpi->spx !=
NULL);
1674 assert(ncols !=
NULL);
1676 *ncols = lpi->spx->numColsReal();
1691 assert(lpi !=
NULL);
1692 assert(lpi->spx !=
NULL);
1693 assert(nnonz !=
NULL);
1697 if( lpi->spx->numRowsReal() < lpi->spx->numColsReal() )
1699 for( i = 0; i < lpi->spx->numRowsReal(); ++i )
1700 (*nnonz) += lpi->spx->rowVectorReal(i).size();
1704 for( i = 0; i < lpi->spx->numColsReal(); ++i )
1705 (*nnonz) += lpi->spx->colVectorReal(i).size();
1732 assert(lpi !=
NULL);
1733 assert(lpi->spx !=
NULL);
1734 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->numColsReal());
1740 const Vector& lbvec = lpi->spx->lowerReal();
1741 const Vector& ubvec = lpi->spx->upperReal();
1742 for( i = firstcol; i <= lastcol; ++i )
1744 lb[i-firstcol] = lbvec[i];
1745 ub[i-firstcol] = ubvec[i];
1754 for( i = firstcol; i <= lastcol; ++i )
1756 beg[i-firstcol] = *nnonz;
1757 const SVector& cvec = lpi->spx->colVectorReal(i);
1758 for( j = 0; j < cvec.size(); ++j )
1760 ind[*nnonz] = cvec.index(j);
1761 val[*nnonz] = cvec.value(j);
1768 assert(beg ==
NULL);
1769 assert(ind ==
NULL);
1770 assert(val ==
NULL);
1797 assert(lpi !=
NULL);
1798 assert(lpi->spx !=
NULL);
1799 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->numRowsReal());
1803 assert(rhs !=
NULL);
1805 const Vector& lhsvec = lpi->spx->lhsReal();
1806 const Vector& rhsvec = lpi->spx->rhsReal();
1807 for( i = firstrow; i <= lastrow; ++i )
1809 lhs[i-firstrow] = lhsvec[i];
1810 rhs[i-firstrow] = rhsvec[i];
1814 assert(rhs ==
NULL);
1819 for( i = firstrow; i <= lastrow; ++i )
1821 beg[i-firstrow] = *nnonz;
1822 const SVector& rvec = lpi->spx->rowVectorReal(i);
1823 for( j = 0; j < rvec.size(); ++j )
1825 ind[*nnonz] = rvec.index(j);
1826 val[*nnonz] = rvec.value(j);
1833 assert(beg ==
NULL);
1834 assert(ind ==
NULL);
1835 assert(val ==
NULL);
1848 int namestoragesize,
1852 assert( lpi !=
NULL );
1853 assert( lpi->spx !=
NULL );
1854 assert( colnames !=
NULL || namestoragesize == 0 );
1855 assert( namestorage !=
NULL || namestoragesize == 0 );
1856 assert( namestoragesize >= 0 );
1857 assert( storageleft !=
NULL );
1858 assert( 0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->numColsReal() );
1875 int namestoragesize,
1879 assert( lpi !=
NULL );
1880 assert( lpi->spx !=
NULL );
1881 assert( rownames !=
NULL || namestoragesize == 0 );
1882 assert( namestorage !=
NULL || namestoragesize == 0 );
1883 assert( namestoragesize >= 0 );
1884 assert( storageleft !=
NULL );
1885 assert( 0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->numRowsReal() );
1902 assert(lpi !=
NULL);
1903 assert(lpi->spx !=
NULL);
1904 assert(objsen !=
NULL);
1923 assert(lpi !=
NULL);
1924 assert(lpi->spx !=
NULL);
1925 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->numColsReal());
1926 assert(vals !=
NULL);
1928 for( i = firstcol; i <= lastcol; ++i )
1929 vals[i-firstcol] = lpi->spx->objReal(i);
1947 assert(lpi !=
NULL);
1948 assert(lpi->spx !=
NULL);
1949 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->numColsReal());
1951 for( i = firstcol; i <= lastcol; ++i )
1954 lbs[i-firstcol] = lpi->spx->lowerReal(i);
1956 ubs[i-firstcol] = lpi->spx->upperReal(i);
1975 assert(lpi !=
NULL);
1976 assert(lpi->spx !=
NULL);
1977 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->numRowsReal());
1979 for( i = firstrow; i <= lastrow; ++i )
1982 lhss[i-firstrow] = lpi->spx->lhsReal(i);
1984 rhss[i-firstrow] = lpi->spx->rhsReal(i);
2000 assert(lpi !=
NULL);
2001 assert(lpi->spx !=
NULL);
2002 assert(0 <= col && col < lpi->spx->numColsReal());
2003 assert(0 <= row && row < lpi->spx->numRowsReal());
2004 assert(val !=
NULL);
2006 *val = lpi->spx->colVectorReal(col)[row];
2027 SPxSolver::Representation rep,
2028 SPxSolver::Type type
2031 assert( lpi !=
NULL );
2032 assert( lpi->spx !=
NULL );
2033 assert( rep == SPxSolver::ROW || rep == SPxSolver::COLUMN );
2034 assert( type == SPxSolver::ENTER || type == SPxSolver::LEAVE );
2038 verbosity = Param::verbose();
2041 SCIPdebugMessage(
"calling SoPlex solve(): %d cols, %d rows\n", lpi->spx->numColsReal(), lpi->spx->numRowsReal());
2043 invalidateSolution(lpi);
2045 assert( lpi->spx->preStrongbranchingBasisFreed() );
2048 if( rep == SPxSolver::COLUMN )
2049 lpi->spx->setIntParam(SoPlex::REPRESENTATION, SoPlex::REPRESENTATION_COLUMN);
2051 lpi->spx->setIntParam(SoPlex::REPRESENTATION, SoPlex::REPRESENTATION_ROW);
2052 if( type == SPxSolver::LEAVE )
2053 lpi->spx->setIntParam(SoPlex::ALGORITHM, SoPlex::ALGORITHM_LEAVE);
2055 lpi->spx->setIntParam(SoPlex::ALGORITHM, SoPlex::ALGORITHM_ENTER);
2057 #ifdef WITH_LPSCHECK
2058 lpi->spx->setDoubleCheck(CHECK_SPXSOLVE);
2061 SPxSolver::Status status = lpi->spx->doSolve();
2062 SCIPdebugMessage(
" -> SoPlex status: %d, basis status: %d\n", lpi->spx->status(), lpi->spx->basisStatus());
2066 Param::setVerbose(verbosity);
2070 case SPxSolver::ABORT_TIME:
2071 case SPxSolver::ABORT_ITER:
2072 case SPxSolver::ABORT_VALUE:
2073 case SPxSolver::SINGULAR:
2074 case SPxSolver::REGULAR:
2075 case SPxSolver::UNKNOWN:
2076 case SPxSolver::OPTIMAL:
2077 case SPxSolver::UNBOUNDED:
2078 case SPxSolver::INFEASIBLE:
2095 assert(lpi !=
NULL);
2096 assert(lpi->spx !=
NULL);
2100 if( lpi->rowrepswitch >= 0 )
2102 rowrep = lpi->spx->intParam(SoPlex::REPRESENTATION) == SoPlex::REPRESENTATION_ROW;
2105 rowrep = lpi->spx->numRowsReal() > lpi->spx->numColsReal() * (lpi->rowrepswitch);
2107 rowrep = lpi->spx->numRowsReal() * 1.1 > lpi->spx->numColsReal() * (lpi->rowrepswitch);
2122 retcode = rowrep ? spxSolve(lpi, SPxSolver::ROW, SPxSolver::LEAVE) : spxSolve(lpi, SPxSolver::COLUMN, SPxSolver::ENTER);
2123 assert(!rowrep || lpi->spx->intParam(SoPlex::REPRESENTATION) == SoPlex::REPRESENTATION_ROW);
2124 assert(rowrep || lpi->spx->intParam(SoPlex::REPRESENTATION) == SoPlex::REPRESENTATION_COLUMN);
2139 assert(lpi !=
NULL);
2140 assert(lpi->spx !=
NULL);
2144 if( lpi->rowrepswitch >= 0 )
2146 rowrep = lpi->spx->intParam(SoPlex::REPRESENTATION) == SoPlex::REPRESENTATION_ROW;
2149 rowrep = lpi->spx->numRowsReal() > lpi->spx->numColsReal() * (lpi->rowrepswitch);
2151 rowrep = lpi->spx->numRowsReal() * 1.1 > lpi->spx->numColsReal() * (lpi->rowrepswitch);
2166 retcode = rowrep ? spxSolve(lpi, SPxSolver::ROW, SPxSolver::ENTER) : spxSolve(lpi, SPxSolver::COLUMN, SPxSolver::LEAVE);
2167 assert(!rowrep || lpi->spx->intParam(SoPlex::REPRESENTATION) == SoPlex::REPRESENTATION_ROW);
2168 assert(rowrep || lpi->spx->intParam(SoPlex::REPRESENTATION) == SoPlex::REPRESENTATION_COLUMN);
2190 assert( lpi->spx->preStrongbranchingBasisFreed() );
2191 lpi->spx->savePreStrongbranchingBasis();
2201 assert( ! lpi->spx->preStrongbranchingBasisFreed() );
2202 lpi->spx->restorePreStrongbranchingBasis();
2203 lpi->spx->freePreStrongbranchingBasis();
2225 SPxSolver::Status status;
2230 bool fromparentbasis;
2236 verbosity = Param::verbose();
2239 SCIPdebugMessage(
"calling SCIPlpiStrongbranch() on variable %d (%d iterations)\n", col, itlim);
2241 assert(lpi !=
NULL);
2242 assert(lpi->spx !=
NULL);
2245 assert(downvalid !=
NULL);
2246 assert(upvalid !=
NULL);
2249 status = SPxSolver::UNKNOWN;
2250 fromparentbasis =
false;
2252 oldItlim = spx->intParam(SoPlex::ITERLIMIT);
2255 oldlb = spx->lowerReal(col);
2256 oldub = spx->upperReal(col);
2265 spx->setIntParam(SoPlex::ALGORITHM, spx->intParam(SoPlex::REPRESENTATION) == SoPlex::REPRESENTATION_ROW
2266 ? SoPlex::ALGORITHM_ENTER : SoPlex::ALGORITHM_LEAVE);
2269 newub =
EPSCEIL(psol-1.0, lpi->spx->feastol());
2270 if( newub >= oldlb - 0.5 && down !=
NULL )
2272 SCIPdebugMessage(
"strong branching down on x%d (%g) with %d iterations\n", col, psol, itlim);
2274 spx->changeUpperReal(col, newub);
2275 assert(spx->lowerReal(col) <= spx->upperReal(col));
2277 spx->setIntParam(SoPlex::ITERLIMIT, itlim);
2280 #ifdef WITH_LPSCHECK
2281 spx->setDoubleCheck(CHECK_SPXSTRONGBRANCH);
2283 status = spx->solve();
2287 case SPxSolver::OPTIMAL:
2288 *down = spx->objValueReal();
2292 case SPxSolver::ABORT_TIME:
2293 case SPxSolver::ABORT_ITER:
2294 case SPxSolver::ABORT_CYCLING:
2295 *down = spx->objValueReal();
2297 case SPxSolver::ABORT_VALUE:
2298 case SPxSolver::INFEASIBLE:
2299 *down = spx->getObjLimit();
2307 (*iter) += spx->numIterations();
2309 #ifdef STRONGBRANCH_RESTOREBASIS
2311 assert( ! spx->preStrongbranchingBasisFreed() );
2312 spx->restorePreStrongbranchingBasis();
2313 fromparentbasis =
false;
2317 if( (status == SPxSolver::ABORT_CYCLING || status == SPxSolver::SINGULAR) && !fromparentbasis && spx->numIterations() < itlim )
2319 SCIPdebugMessage(
" --> Repeat strong branching down with %d iterations after restoring basis\n",
2320 itlim - spx->numIterations());
2321 spx->setIntParam(SoPlex::ITERLIMIT, itlim - spx->numIterations());
2322 assert( ! spx->hasPreStrongbranchingBasis() );
2323 spx->restorePreStrongbranchingBasis();
2324 fromparentbasis =
true;
2329 fromparentbasis =
false;
2332 while( fromparentbasis );
2334 spx->changeUpperReal(col, oldub);
2335 assert(spx->lowerReal(col) <= spx->upperReal(col));
2337 else if( down !=
NULL )
2339 *down = spx->getObjLimit();
2348 newlb =
EPSFLOOR(psol+1.0, lpi->spx->feastol());
2349 if( newlb <= oldub + 0.5 && up !=
NULL )
2351 SCIPdebugMessage(
"strong branching up on x%d (%g) with %d iterations\n", col, psol, itlim);
2353 spx->changeLowerReal(col, newlb);
2354 assert(spx->lowerReal(col) <= spx->upperReal(col));
2356 spx->setIntParam(SoPlex::ITERLIMIT, itlim);
2359 #ifdef WITH_LPSCHECK
2360 spx->setDoubleCheck(CHECK_SPXSTRONGBRANCH);
2362 status = spx->solve();
2366 case SPxSolver::OPTIMAL:
2367 *up = spx->objValueReal();
2371 case SPxSolver::ABORT_TIME:
2372 case SPxSolver::ABORT_ITER:
2373 case SPxSolver::ABORT_CYCLING:
2374 *up = spx->objValueReal();
2376 case SPxSolver::ABORT_VALUE:
2377 case SPxSolver::INFEASIBLE:
2378 *up = spx->getObjLimit();
2386 (*iter) += spx->numIterations();
2388 #ifdef STRONGBRANCH_RESTOREBASIS
2390 assert( ! spx->preStrongbranchingBasisFreed() );
2391 spx->restorePreStrongbranchingBasis();
2392 fromparentbasis =
false;
2396 else if( (status == SPxSolver::ABORT_CYCLING || status == SPxSolver::SINGULAR) && !fromparentbasis && spx->numIterations() < itlim )
2398 SCIPdebugMessage(
" --> Repeat strong branching up with %d iterations after restoring basis\n", itlim - spx->numIterations());
2399 assert( ! spx->hasPreStrongbranchingBasis() );
2400 spx->restorePreStrongbranchingBasis();
2401 spx->setIntParam(SoPlex::ITERLIMIT, itlim - spx->numIterations());
2403 fromparentbasis =
true;
2407 fromparentbasis =
false;
2410 while( fromparentbasis );
2412 spx->changeLowerReal(col, oldlb);
2413 assert(spx->lowerReal(col) <= spx->upperReal(col));
2415 else if( up !=
NULL )
2417 *up = spx->getObjLimit();
2425 spx->setIntParam(SoPlex::ITERLIMIT, oldItlim);
2428 Param::setVerbose(verbosity);
2432 SCIPdebugMessage(
"SCIPlpiStrongbranch() returned SoPlex status %d\n",
int(status));
2457 retcode = lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter);
2487 assert( iter !=
NULL );
2488 assert( cols !=
NULL );
2489 assert( psols !=
NULL );
2490 assert( down !=
NULL );
2491 assert( up !=
NULL );
2492 assert( downvalid !=
NULL );
2493 assert( upvalid !=
NULL );
2494 assert( down !=
NULL );
2499 for (
int j = 0; j < ncols; ++j)
2502 retcode = lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter);
2532 retcode = lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter);
2562 assert( iter !=
NULL );
2563 assert( cols !=
NULL );
2564 assert( psols !=
NULL );
2565 assert( down !=
NULL );
2566 assert( up !=
NULL );
2567 assert( downvalid !=
NULL );
2568 assert( upvalid !=
NULL );
2569 assert( down !=
NULL );
2574 for (
int j = 0; j < ncols; ++j)
2577 retcode = lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter);
2606 assert(lpi !=
NULL);
2620 assert(lpi !=
NULL);
2621 assert(primalfeasible !=
NULL);
2622 assert(dualfeasible !=
NULL);
2639 assert(lpi !=
NULL);
2640 assert(lpi->spx !=
NULL);
2642 return (lpi->spx->status() == SPxSolver::UNBOUNDED);
2654 assert(lpi !=
NULL);
2655 assert(lpi->spx !=
NULL);
2657 return (lpi->spx->status() == SPxSolver::UNBOUNDED);
2667 assert(lpi !=
NULL);
2668 assert(lpi->spx !=
NULL);
2670 assert(lpi->spx->status() != SPxSolver::UNBOUNDED || lpi->spx->basisStatus() == SPxBasis::UNBOUNDED);
2675 return lpi->spx->status() == SPxSolver::UNBOUNDED;
2685 assert(lpi !=
NULL);
2686 assert(lpi->spx !=
NULL);
2688 return (lpi->spx->status() == SPxSolver::INFEASIBLE);
2696 SPxBasis::SPxStatus basestatus;
2700 assert(lpi !=
NULL);
2701 assert(lpi->spx !=
NULL);
2703 basestatus = lpi->spx->basisStatus();
2708 assert(basestatus == SPxBasis::OPTIMAL || lpi->spx->status() != SPxSolver::OPTIMAL);
2710 return basestatus == SPxBasis::OPTIMAL || basestatus == SPxBasis::PRIMAL;
2722 assert(lpi !=
NULL);
2723 assert(lpi->spx !=
NULL);
2725 return (lpi->spx->status() == SPxSolver::INFEASIBLE);
2737 assert(lpi !=
NULL);
2738 assert(lpi->spx !=
NULL);
2740 return (lpi->spx->status() == SPxSolver::INFEASIBLE);
2750 assert(lpi !=
NULL);
2751 assert(lpi->spx !=
NULL);
2753 return lpi->spx->status() == SPxSolver::INFEASIBLE && lpi->spx->basisStatus() == SPxBasis::DUAL;
2763 assert(lpi !=
NULL);
2764 assert(lpi->spx !=
NULL);
2766 return (lpi->spx->status() == SPxSolver::UNBOUNDED);
2776 assert(lpi !=
NULL);
2777 assert(lpi->spx !=
NULL);
2782 assert(lpi->spx->basisStatus() == SPxBasis::OPTIMAL || lpi->spx->status() != SPxSolver::OPTIMAL);
2784 return (lpi->spx->basisStatus() == SPxBasis::OPTIMAL) || lpi->spx->basisStatus() == SPxBasis::DUAL;
2794 assert(lpi !=
NULL);
2795 assert((lpi->spx->basisStatus() == SPxBasis::OPTIMAL)
2801 return (lpi->spx->basisStatus() == SPxBasis::OPTIMAL);
2811 assert(lpi !=
NULL);
2812 assert(lpi->spx !=
NULL);
2814 if( lpi->spx->status() == SPxSolver::ERROR || lpi->spx->status() == SPxSolver::SINGULAR )
2832 if( kappa > lpi->conditionlimit )
2846 assert(lpi !=
NULL);
2847 assert(lpi->spx !=
NULL);
2849 return (lpi->spx->status() == SPxSolver::ABORT_VALUE);
2859 assert(lpi !=
NULL);
2860 assert(lpi->spx !=
NULL);
2862 return (lpi->spx->status() == SPxSolver::ABORT_ITER);
2872 assert(lpi !=
NULL);
2873 assert(lpi->spx !=
NULL);
2875 return (lpi->spx->status() == SPxSolver::ABORT_TIME);
2885 assert(lpi !=
NULL);
2886 assert(lpi->spx !=
NULL);
2888 return static_cast<int>(lpi->spx->status());
2899 assert(lpi !=
NULL);
2900 assert(lpi->spx !=
NULL);
2916 assert(lpi !=
NULL);
2917 assert(lpi->spx !=
NULL);
2918 assert(objval !=
NULL);
2920 *objval = lpi->spx->objValueReal();
2937 assert(lpi !=
NULL);
2938 assert(lpi->spx !=
NULL);
2940 if( objval !=
NULL )
2941 *objval = lpi->spx->objValueReal();
2945 if( primsol !=
NULL )
2947 Vector tmp(lpi->spx->numColsReal(), primsol);
2948 (void)lpi->spx->getPrimalReal(tmp);
2950 if( dualsol !=
NULL )
2952 Vector tmp(lpi->spx->numRowsReal(), dualsol);
2953 (void)lpi->spx->getDualReal(tmp);
2955 if( activity !=
NULL )
2957 Vector tmp(lpi->spx->numRowsReal(), activity);
2958 (void)lpi->spx->getSlacksReal(tmp);
2960 if( redcost !=
NULL )
2962 Vector tmp(lpi->spx->numColsReal(), redcost);
2963 (void)lpi->spx->getRedCostReal(tmp);
2966 catch(SPxException x)
2969 std::string s = x.what();
2986 assert(lpi !=
NULL);
2987 assert(lpi->spx !=
NULL);
2991 Vector tmp(lpi->spx->numColsReal(), ray);
2992 (void)lpi->spx->getPrimalRayReal(tmp);
2994 catch(SPxException x)
2997 std::string s = x.what();
3014 assert(lpi !=
NULL);
3015 assert(lpi->spx !=
NULL);
3019 Vector tmp(lpi->spx->numRowsReal(), dualfarkas);
3020 (void)lpi->spx->getDualFarkasReal(tmp);
3022 catch(SPxException x)
3025 std::string s = x.what();
3042 assert(lpi !=
NULL);
3043 assert(lpi->spx !=
NULL);
3045 *iterations = lpi->spx->numIterations();
3064 assert(lpi !=
NULL);
3065 assert(quality !=
NULL);
3069 assert(lpi !=
NULL);
3070 assert(quality !=
NULL);
3072 SCIPdebugMessage(
"requesting solution quality from SoPlex: quality %d\n", qualityindicator);
3074 switch( qualityindicator )
3077 success = lpi->spx->getEstimatedCondition(*quality);
3081 success = lpi->spx->getExactCondition(*quality);
3122 assert(lpi !=
NULL);
3123 assert(lpi->spx !=
NULL);
3125 assert( lpi->spx->preStrongbranchingBasisFreed() );
3127 if( rstat !=
NULL && cstat !=
NULL )
3129 for( i = 0; i < lpi->spx->numRowsReal(); ++i )
3131 switch( lpi->spx->basisRowStatus(i) )
3133 case SPxSolver::BASIC:
3136 case SPxSolver::FIXED:
3137 case SPxSolver::ON_LOWER:
3140 case SPxSolver::ON_UPPER:
3143 case SPxSolver::ZERO:
3144 SCIPerrorMessage(
"slack variable has basis status ZERO (should not occur)\n");
3156 for( i = 0; i < lpi->spx->numColsReal(); ++i )
3159 switch( lpi->spx->basisColStatus(i) )
3161 case SPxSolver::BASIC:
3164 case SPxSolver::FIXED:
3176 case SPxSolver::ON_LOWER:
3179 case SPxSolver::ON_UPPER:
3182 case SPxSolver::ZERO:
3207 assert(lpi !=
NULL);
3208 assert(lpi->spx !=
NULL);
3209 assert(cstat !=
NULL || lpi->spx->numColsReal() == 0);
3210 assert(rstat !=
NULL || lpi->spx->numRowsReal() == 0);
3212 assert( lpi->spx->preStrongbranchingBasisFreed() );
3213 invalidateSolution(lpi);
3215 SPxSolver::VarStatus* spxcstat =
NULL;
3216 SPxSolver::VarStatus* spxrstat =
NULL;
3217 SCIP_ALLOC( BMSallocMemoryArray(&spxcstat, lpi->spx->numColsReal()) );
3218 SCIP_ALLOC( BMSallocMemoryArray(&spxrstat, lpi->spx->numRowsReal()) );
3220 for( i = 0; i < lpi->spx->numRowsReal(); ++i )
3225 spxrstat[i] = SPxSolver::ON_LOWER;
3228 spxrstat[i] = SPxSolver::BASIC;
3231 spxrstat[i] = SPxSolver::ON_UPPER;
3234 SCIPerrorMessage(
"slack variable has basis status ZERO (should not occur)\n");
3235 BMSfreeMemoryArrayNull(&spxcstat);
3236 BMSfreeMemoryArrayNull(&spxrstat);
3245 for( i = 0; i < lpi->spx->numColsReal(); ++i )
3250 spxcstat[i] = SPxSolver::ON_LOWER;
3253 spxcstat[i] = SPxSolver::BASIC;
3256 spxcstat[i] = SPxSolver::ON_UPPER;
3259 spxcstat[i] = SPxSolver::ZERO;
3268 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->setBasis(spxrstat, spxcstat) );
3272 BMSfreeMemoryArrayNull(&spxcstat);
3273 BMSfreeMemoryArrayNull(&spxrstat);
3286 assert(lpi !=
NULL);
3287 assert(lpi->spx !=
NULL);
3289 assert(lpi->spx->preStrongbranchingBasisFreed());
3291 lpi->spx->getBasisInd(bind);
3306 assert( lpi !=
NULL);
3307 assert(lpi->spx !=
NULL);
3308 assert(lpi->spx->preStrongbranchingBasisFreed());
3311 assert(r < lpi->spx->numRowsReal());
3313 if( ! lpi->spx->getBasisInverseRowReal(r, coef) )
3332 assert( lpi !=
NULL );
3333 assert( lpi->spx !=
NULL );
3334 assert( lpi->spx->preStrongbranchingBasisFreed() );
3336 if( ! lpi->spx->getBasisInverseColReal(c, coef) )
3358 assert(lpi !=
NULL);
3359 assert(lpi->spx !=
NULL);
3360 assert( lpi->spx->preStrongbranchingBasisFreed() );
3362 nrows = lpi->spx->numRowsReal();
3363 ncols = lpi->spx->numColsReal();
3367 if( binvrow ==
NULL )
3369 SCIP_ALLOC( BMSallocMemoryArray(&buf, nrows) );
3376 assert(binv !=
NULL);
3380 Vector binvvec(nrows, binv);
3381 for( c = 0; c < ncols; ++c )
3382 coef[c] = binvvec * lpi->spx->colVectorReal(c);
3385 BMSfreeMemoryArrayNull(&buf);
3397 DVector col(lpi->spx->numRowsReal());
3401 assert( lpi !=
NULL );
3402 assert( lpi->spx !=
NULL );
3403 assert( lpi->spx->preStrongbranchingBasisFreed() );
3407 assert(c < lpi->spx->numColsReal());
3411 col = lpi->spx->colVectorReal(c);
3413 col.reDim(lpi->spx->numRowsReal());
3416 if( ! lpi->spx->getBasisInverseTimesVecReal(col.get_ptr(), coef) )
3446 assert(blkmem !=
NULL);
3447 assert(lpi !=
NULL);
3448 assert(lpi->spx !=
NULL);
3449 assert(lpistate !=
NULL);
3451 assert( lpi->spx->preStrongbranchingBasisFreed() );
3453 ncols = lpi->spx->numColsReal();
3454 nrows = lpi->spx->numRowsReal();
3459 SCIP_CALL( lpistateCreate(lpistate, blkmem, ncols, nrows) );
3462 SCIP_CALL( ensureCstatMem(lpi, ncols) );
3463 SCIP_CALL( ensureRstatMem(lpi, nrows) );
3469 (*lpistate)->ncols = ncols;
3470 (*lpistate)->nrows = nrows;
3471 lpistatePack(*lpistate, lpi->cstat, lpi->rstat);
3491 assert(lpi !=
NULL);
3492 assert(lpi->spx !=
NULL);
3493 assert(lpistate !=
NULL);
3495 assert( lpi->spx->preStrongbranchingBasisFreed() );
3497 lpncols = lpi->spx->numColsReal();
3498 lpnrows = lpi->spx->numRowsReal();
3499 assert(lpistate->ncols <= lpncols);
3500 assert(lpistate->nrows <= lpnrows);
3503 SCIP_CALL( ensureCstatMem(lpi, lpncols) );
3504 SCIP_CALL( ensureRstatMem(lpi, lpnrows) );
3507 lpistateUnpack(lpistate, lpi->cstat, lpi->rstat);
3510 for( i = lpistate->ncols; i < lpncols; ++i )
3516 bnd = lpi->spx->lowerReal(i);
3525 for( i = lpistate->nrows; i < lpnrows; ++i )
3541 assert(lpi !=
NULL);
3542 assert(lpi->spx !=
NULL);
3546 lpi->spx->clearBasis();
3548 catch(SPxException x)
3551 std::string s = x.what();
3554 assert( lpi->spx->status() != SPxSolver::OPTIMAL );
3570 assert(lpi !=
NULL);
3571 assert(lpistate !=
NULL);
3573 if ( *lpistate !=
NULL )
3574 lpistateFree(lpistate, blkmem);
3596 assert( lpi->spx->preStrongbranchingBasisFreed() );
3599 SOPLEX_TRY( lpi->messagehdlr, success = lpi->spx->readBasisFile(fname, 0, 0) );
3612 assert( lpi->spx->preStrongbranchingBasisFreed() );
3615 SOPLEX_TRY( lpi->messagehdlr, res = lpi->spx->writeBasisFile(fname, 0, 0) );
3644 assert(lpinorms !=
NULL);
3660 assert(lpinorms ==
NULL);
3673 assert(lpinorms ==
NULL);
3700 assert(lpi !=
NULL);
3701 assert(lpi->spx !=
NULL);
3702 assert(ival !=
NULL);
3707 *ival = lpi->spx->getFromScratch();
3710 *ival = lpi->spx->getLpInfo();
3713 *ival = lpi->spx->intParam(SoPlex::ITERLIMIT);
3716 *ival = lpi->spx->intParam(SoPlex::SIMPLIFIER) == SoPlex::SIMPLIFIER_AUTO;
3719 *ival = (int) lpi->pricing;
3722 *ival = (
int) (lpi->spx->intParam(SoPlex::SCALER) != SoPlex::SCALER_OFF);
3740 assert(lpi !=
NULL);
3741 assert(lpi->spx !=
NULL);
3747 lpi->spx->setFromScratch(
bool(ival));
3751 lpi->spx->setLpInfo(
bool(ival));
3755 lpi->spx->setIntParam(SoPlex::ITERLIMIT, ival);
3759 lpi->spx->setIntParam(SoPlex::SIMPLIFIER, (ival ? SoPlex::SIMPLIFIER_AUTO : SoPlex::SIMPLIFIER_OFF));
3763 switch( lpi->pricing )
3767 lpi->spx->setIntParam(SoPlex::PRICER, SoPlex::PRICER_AUTO);
3770 lpi->spx->setIntParam(SoPlex::PRICER, SoPlex::PRICER_STEEP);
3773 lpi->spx->setIntParam(SoPlex::PRICER, SoPlex::PRICER_PARMULT);
3776 lpi->spx->setIntParam(SoPlex::PRICER, SoPlex::PRICER_STEEP);
3779 lpi->spx->setIntParam(SoPlex::PRICER, SoPlex::PRICER_QUICKSTEEP);
3782 lpi->spx->setIntParam(SoPlex::PRICER, SoPlex::PRICER_DEVEX);
3790 lpi->spx->setIntParam(SoPlex::SCALER, ( ival ? SoPlex::SCALER_BIEQUI : SoPlex::SCALER_OFF));
3808 assert(lpi !=
NULL);
3809 assert(lpi->spx !=
NULL);
3810 assert(dval !=
NULL);
3815 *dval = lpi->spx->feastol();
3818 *dval = lpi->spx->opttol();
3821 *dval = lpi->spx->realParam(SoPlex::OBJLIMIT_LOWER);
3824 *dval = lpi->spx->realParam(SoPlex::OBJLIMIT_UPPER);
3827 *dval = lpi->spx->realParam(SoPlex::TIMELIMIT);
3830 *dval = lpi->rowrepswitch;
3833 *dval = lpi->conditionlimit;
3850 assert(lpi !=
NULL);
3851 assert(lpi->spx !=
NULL);
3856 lpi->spx->setFeastol(dval);
3859 lpi->spx->setOpttol(dval);
3862 lpi->spx->setRealParam(SoPlex::OBJLIMIT_LOWER, dval);
3865 lpi->spx->setRealParam(SoPlex::OBJLIMIT_UPPER, dval);
3868 lpi->spx->setRealParam(SoPlex::TIMELIMIT, dval);
3871 assert(dval >= -1.5);
3872 lpi->rowrepswitch = dval;
3875 lpi->conditionlimit = dval;
3876 lpi->checkcondition = (dval >= 0);
3904 return lpi->spx->realParam(SoPlex::INFTY);
3915 return (val >= lpi->spx->realParam(SoPlex::INFTY));
3933 const char* filename
3938 f = fopen(filename,
"r");
3955 assert(lpi !=
NULL);
3956 assert(lpi->spx !=
NULL);
3958 assert( lpi->spx->preStrongbranchingBasisFreed() );
3960 if( !fileExists(fname) )
3965 assert(lpi->spx->intParam(SoPlex::READMODE) == SoPlex::READMODE_REAL);
3966 if( !lpi->spx->readFile(fname) )
3969 catch(SPxException x)
3972 std::string s = x.what();
3989 assert(lpi !=
NULL);
3990 assert(lpi->spx !=
NULL);
3994 lpi->spx->writeFileReal(fname);
3996 catch(SPxException x)
3999 std::string s = x.what();