30 #define STRONGBRANCH_RESTOREBASIS 39 #define CHECK_SPXSOLVE true 40 #define CHECK_SPXSTRONGBRANCH true 42 #define EXIT_AT_WRONG_RESULT false 43 #define EXIT_AT_CPXERROR false 45 #define CPX_CALL(x) do \ 48 if( (_cpxstat_ = (x)) != 0 ) \ 50 SCIPmessagePrintWarning(_messagehdlr, "CPLEX error <%d>; SoPlex result unchecked\n", _cpxstat_); \ 51 if( EXIT_AT_CPXERROR ) \ 65 #define CHECK_SOPLEX_PARAM(x) \ 68 SCIPmessagePrintWarning(_messagehdlr, "SoPlex: unsupported parameter value\n"); \ 81 #ifndef SOPLEX_SUBVERSION 82 #define SOPLEX_SUBVERSION 0 86 #if (SOPLEX_VERSION < 200 || (SOPLEX_VERSION == 200 && SOPLEX_SUBVERSION < 2) || (SOPLEX_VERSION > 200 && SOPLEX_VERSION < 201)) 87 #error "This interface is not compatible with SoPlex versions prior to 2.0.0.2" 90 #include "spxgithash.h" 99 #define SOPLEX_VERBLEVEL 5 120 #define SOPLEX_TRY(messagehdlr, x) do \ 126 catch(const SPxException& E) \ 128 std::string s = E.what(); \ 129 SCIPmessagePrintWarning((messagehdlr), "SoPlex threw an exception: %s\n", s.c_str()); \ 130 return SCIP_LPERROR; \ 136 #define SOPLEX_TRY(messagehdlr, x) do \ 142 catch(const SPxException& E) \ 144 return SCIP_LPERROR; \ 153 #define SOPLEX_TRY_ABORT(x) do \ 159 catch(const SPxException& E) \ 161 std::string s = E.what(); \ 162 SCIPerrorMessage("SoPlex threw an exception: %s\n", s.c_str()); \ 171 class SPxSCIP :
public SoPlex
176 SPxSolver::VarStatus* _colStat;
177 SPxSolver::VarStatus* _rowStat;
189 const char* probname =
NULL 196 _messagehdlr(messagehdlr)
198 if ( probname !=
NULL )
204 _doublecheck =
false;
205 _cpxenv = CPXopenCPLEX(&cpxstat);
206 assert(_cpxenv !=
NULL);
207 _cpxlp = CPXcreateprob(_cpxenv, &cpxstat, probname !=
NULL ? probname :
"spxcheck");
208 (void) CPXsetintparam(_cpxenv, CPX_PARAM_SCRIND, 0);
214 if( _probname !=
NULL )
217 if( _colStat !=
NULL )
220 if( _rowStat !=
NULL )
223 freePreStrongbranchingBasis();
226 (void) CPXfreeprob(_cpxenv, &_cpxlp);
227 (void) CPXcloseCPLEX(&_cpxenv);
235 return realParam(FEASTOL);
249 return realParam(OPTTOL);
261 Real getObjLimit()
const 263 return (intParam(SoPlex::OBJSENSE) == SoPlex::OBJSENSE_MINIMIZE)
264 ? realParam(SoPlex::OBJLIMIT_UPPER)
265 : realParam(SoPlex::OBJLIMIT_LOWER);
269 bool getFromScratch()
const 274 void setFromScratch(
bool fs)
280 bool getLpInfo()
const 285 void setLpInfo(
bool lpinfo)
291 void setProbname(
const char* probname)
295 assert(probname !=
NULL);
296 if( _probname !=
NULL )
298 len = (int)strlen(probname);
299 spx_alloc(_probname, len + 1);
300 strncpy(_probname, probname, len);
301 _probname[len] =
'\0';
304 void setRep(SPxSolver::Representation p_rep)
306 if( p_rep == SPxSolver::COLUMN && intParam(REPRESENTATION) == REPRESENTATION_ROW )
311 else if( (p_rep == SPxSolver::ROW && intParam(REPRESENTATION) == REPRESENTATION_COLUMN) )
319 bool getDoubleCheck()
322 return _doublecheck && _checknum + 1 >= CHECK_START;
325 void setDoubleCheck(
bool dc)
330 const char* spxStatusString(
const SPxSolver::Status stat)
const 334 case SPxSolver::ABORT_TIME:
336 case SPxSolver::ABORT_ITER:
338 case SPxSolver::ABORT_VALUE:
339 return "ABORT_VALUE";
340 case SPxSolver::SINGULAR:
342 case SPxSolver::REGULAR:
346 case SPxSolver::OPTIMAL:
348 case SPxSolver::UNBOUNDED:
350 case SPxSolver::INFEASIBLE:
357 const char* cpxStatusString(
const int stat)
const 361 case CPX_STAT_ABORT_TIME_LIM:
363 case CPX_STAT_ABORT_IT_LIM:
365 case CPX_STAT_ABORT_OBJ_LIM:
366 return "ABORT_VALUE";
367 case CPX_STAT_OPTIMAL:
369 case CPX_STAT_OPTIMAL_INFEAS:
370 return "CPX_STAT_OPTIMAL_INFEAS: OPT SOL INFEASIBLE AFTER UNSCALING";
371 case CPX_STAT_UNBOUNDED:
373 case CPX_STAT_INFEASIBLE:
375 case CPX_STAT_INForUNBD:
376 return "INFEASIBLE or UNBOUNDED";
377 case CPX_STAT_NUM_BEST:
378 return "CPX_STAT_NUM_BEST: SOL AVAILABLE BUT NOT PROVEN OPTIMAL DUE TO NUM TROUBLE";
386 bool checkConsistentBounds()
const 388 for(
int i = 0; i < numColsReal(); ++i )
390 if( lowerReal(i) > upperReal(i) + realParam(SoPlex::EPSILON_ZERO) )
392 SCIPerrorMessage(
"inconsistent bounds on column %d: lower=%.17g, upper=%.17g\n",
393 i, lowerReal(i), upperReal(i));
401 bool checkConsistentSides()
const 403 for(
int i = 0; i < numRowsReal(); ++i )
405 if( lhsReal(i) > rhsReal(i) + realParam(SoPlex::EPSILON_ZERO) )
408 i, lhsReal(i), rhsReal(i));
417 void trySolve(
bool printwarning =
true)
426 catch(
const SPxException& x)
428 std::string s = x.what();
438 assert(status() != SPxSolver::OPTIMAL);
441 assert(intParam(ITERLIMIT) < 0 || numIterations() <= intParam(ITERLIMIT));
444 timespent = solveTime();
448 timelimit = realParam(TIMELIMIT);
449 if( timelimit > timespent )
450 timelimit -= timespent;
454 assert(timelimit >= 0);
459 SPxSolver::Status doSolve(
bool printwarning =
true)
461 SPxOut::Verbosity verbosity;
463 SPxSolver::Status spxStatus;
466 verbosity = spxout.getVerbosity();
467 spxout.setVerbosity((SPxOut::Verbosity)(getLpInfo() ?
SOPLEX_VERBLEVEL : 0));
469 assert(checkConsistentBounds());
470 assert(checkConsistentSides());
474 if( getDoubleCheck() )
475 writeStateReal(
"spxcheck",
NULL,
NULL);
478 trySolve(printwarning);
479 spxStatus = status();
485 bool minimize = intParam(OBJSENSE) == OBJSENSE_MINIMIZE;
486 Real objLimitUpper = realParam(OBJLIMIT_UPPER);
487 Real objLimitLower = realParam(OBJLIMIT_LOWER);
490 if( getDoubleCheck() && (spxStatus == SPxSolver::OPTIMAL || spxStatus == SPxSolver::UNBOUNDED || spxStatus == SPxSolver::INFEASIBLE || spxStatus == SPxSolver::ABORT_VALUE) )
496 CPX_CALL( CPXreadcopyprob(_cpxenv, _cpxlp,
"spxcheck.mps",
NULL) );
497 CPX_CALL( CPXreadcopybase(_cpxenv, _cpxlp,
"spxcheck.bas") );
500 CPX_CALL( CPXsetdblparam(_cpxenv, CPX_PARAM_EPOPT,
MAX(opttol(), 1e-9)) );
501 CPX_CALL( CPXsetdblparam(_cpxenv, CPX_PARAM_EPRHS,
MAX(feastol(), 1e-9)) );
504 CPX_CALL( CPXlpopt(_cpxenv, _cpxlp) );
507 CPX_CALL( CPXsolution(_cpxenv, _cpxlp, &cpxstat, &cpxobj,
NULL,
NULL,
NULL,
NULL) );
512 if( cpxstat == CPX_STAT_OPTIMAL_INFEAS )
514 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s)\n",
515 _probname, spxStatus, spxStatusString(spxStatus), cpxstat, cpxStatusString(cpxstat));
516 if( EXIT_AT_CPXERROR )
519 else if( (spxStatus == SPxSolver::OPTIMAL && cpxstat != CPX_STAT_OPTIMAL)
520 || (spxStatus == SPxSolver::UNBOUNDED && cpxstat != CPX_STAT_UNBOUNDED)
521 || (spxStatus == SPxSolver::INFEASIBLE && cpxstat != CPX_STAT_INFEASIBLE) )
523 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
524 _probname, spxStatus, spxStatusString(spxStatus), cpxstat, cpxStatusString(cpxstat), _checknum);
525 if( EXIT_AT_WRONG_RESULT )
528 else if( spxStatus == SPxSolver::ABORT_VALUE )
532 case CPX_STAT_OPTIMAL:
533 if( (minimize && LTrel(cpxobj, objLimitUpper, 2*opttol()))
534 || (!minimize && GTrel(cpxobj, objLimitLower, 2*opttol())) )
536 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
537 _probname, spxStatus, spxStatusString(spxStatus), cpxobj, minimize ?
"<" :
">",
538 minimize ? objLimitUpper : objLimitLower, cpxStatusString(cpxstat), _checknum);
539 if( EXIT_AT_WRONG_RESULT )
542 else if( (minimize && cpxobj < objLimitUpper) || (!minimize && cpxobj > objLimitLower) )
544 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
545 _probname, spxStatus, spxStatusString(spxStatus), cpxobj, minimize?
"<" :
">",
546 minimize ? objLimitUpper : objLimitLower, cpxStatusString(cpxstat), _checknum);
549 case CPX_STAT_OPTIMAL_INFEAS:
550 case CPX_STAT_NUM_BEST:
551 if( (minimize && cpxobj < objLimitUpper) || (!minimize && cpxobj > objLimitLower) )
553 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
554 _probname, spxStatus, spxStatusString(spxStatus), cpxobj, minimize ?
"<" :
">",
555 minimize ? objLimitUpper : objLimitLower, cpxStatusString(cpxstat), _checknum);
558 case CPX_STAT_INFEASIBLE:
560 case CPX_STAT_UNBOUNDED:
561 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
562 _probname, spxStatus, spxStatusString(spxStatus), cpxstat, cpxStatusString(cpxstat), _checknum);
563 if( EXIT_AT_WRONG_RESULT )
566 case CPX_STAT_INForUNBD:
568 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
569 _probname, spxStatus, spxStatusString(spxStatus), cpxstat, cpxStatusString(cpxstat), _checknum);
574 else if( spxStatus == SPxSolver::OPTIMAL )
576 if( (minimize && LTrel(objValueReal(), cpxobj, 2*opttol()))
577 || (!minimize && GTrel(objValueReal(), cpxobj, 2*opttol())) )
582 else if( (minimize && GTrel(objValueReal(), cpxobj, 2*opttol()))
583 || (!minimize && LTrel(objValueReal(), cpxobj, 2*opttol())) )
585 SCIPerrorMessage(
"In %s: LP optimal; SoPlex value=%.10f %s CPLEX value=%.10f suboptimal (checknum=%d)\n", objValueReal(),
586 _probname, minimize ?
">" :
"<", cpxobj, _checknum);
587 if( EXIT_AT_WRONG_RESULT )
597 spxout.setVerbosity(verbosity);
603 void savePreStrongbranchingBasis()
605 assert(_rowStat ==
NULL);
606 assert(_colStat ==
NULL);
608 spx_alloc(_rowStat, numRowsReal());
609 spx_alloc(_colStat, numColsReal());
613 getBasis(_rowStat, _colStat);
615 catch(
const SPxException& x)
618 std::string s = x.what();
625 assert(status() != SPxSolver::OPTIMAL);
631 void restorePreStrongbranchingBasis()
633 assert(_rowStat !=
NULL);
634 assert(_colStat !=
NULL);
638 setBasis(_rowStat, _colStat);
640 catch(
const SPxException& x)
643 std::string s = x.what();
650 assert(status() != SPxSolver::OPTIMAL);
655 void freePreStrongbranchingBasis()
657 if( _rowStat !=
NULL )
659 if( _colStat !=
NULL )
664 bool preStrongbranchingBasisFreed()
const 666 return ((_rowStat ==
NULL ) && (_colStat ==
NULL));
682 #define COLS_PER_PACKET SCIP_DUALPACKETSIZE 684 #define ROWS_PER_PACKET SCIP_DUALPACKETSIZE 743 assert(num <= lpi->cstatsize);
765 assert(num <= lpi->rstatsize);
803 assert(lpistate !=
NULL);
819 assert(lpistate !=
NULL);
836 assert(lpistate !=
NULL);
837 assert(blkmem !=
NULL);
858 assert(blkmem !=
NULL);
859 assert(lpistate !=
NULL);
860 assert(*lpistate !=
NULL);
910 #if (SOPLEX_SUBVERSION > 0) 911 sprintf(
spxname,
"SoPlex2 %d.%d.%d.%d", SOPLEX_VERSION/100, (SOPLEX_VERSION % 100)/10, SOPLEX_VERSION % 10,
SOPLEX_SUBVERSION);
913 sprintf(
spxname,
"SoPlex2 %d.%d.%d", SOPLEX_VERSION/100, (SOPLEX_VERSION % 100)/10, SOPLEX_VERSION % 10);
923 sprintf(
spxdesc,
"%s",
"Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de)");
926 sprintf(
spxdesc,
"%s %s",
spxdesc,
"- including CPLEX double check");
936 return (
void*) lpi->
spx;
965 SOPLEX_TRY( messagehdlr, (*lpi)->spx = new ((*lpi)->spx) SPxSCIP(messagehdlr, name) );
966 (void) (*lpi)->spx->setIntParam(SoPlex::SYNCMODE, SoPlex::SYNCMODE_ONLYREAL);
967 (void) (*lpi)->spx->setIntParam(SoPlex::SOLVEMODE, SoPlex::SOLVEMODE_REAL);
968 (void) (*lpi)->spx->setIntParam(SoPlex::REPRESENTATION, SoPlex::REPRESENTATION_AUTO);
970 (*lpi)->cstat =
NULL;
971 (*lpi)->rstat =
NULL;
972 (*lpi)->cstatsize = 0;
973 (*lpi)->rstatsize = 0;
975 (*lpi)->conditionlimit = -1.0;
976 (*lpi)->checkcondition =
FALSE;
977 (*lpi)->messagehdlr = messagehdlr;
988 SPxOut::Verbosity verbosity = (*lpi)->spx->spxout.getVerbosity();
989 (*lpi)->spx->spxout.setVerbosity((SPxOut::Verbosity)((*lpi)->spx->getLpInfo() ?
SOPLEX_VERBLEVEL : 0));
990 (*lpi)->spx->printVersion();
991 (*lpi)->spx->spxout.setVerbosity(verbosity);
1002 assert(lpi !=
NULL);
1003 assert(*lpi !=
NULL);
1004 assert((*lpi)->spx !=
NULL);
1007 (*lpi)->spx->~SPxSCIP();
1051 assert(lpi !=
NULL);
1053 assert(lhs !=
NULL);
1054 assert(rhs !=
NULL);
1057 assert(lpi->
spx->preStrongbranchingBasisFreed());
1061 SPxSCIP* spx = lpi->
spx;
1062 LPRowSet rows(nrows);
1063 DSVector emptyVector(0);
1069 (void) spx->setIntParam(SoPlex::OBJSENSE, (objsen ==
SCIP_OBJSEN_MINIMIZE ? SoPlex::OBJSENSE_MINIMIZE : SoPlex::OBJSENSE_MAXIMIZE));
1072 for( i = 0; i < nrows; ++i )
1073 rows.add(lhs[i], emptyVector, rhs[i]);
1074 spx->addRowsReal(rows);
1079 catch(
const SPxException& x)
1082 std::string s = x.what();
1107 assert(lpi !=
NULL);
1109 assert(obj !=
NULL);
1112 assert(nnonz == 0 || beg !=
NULL);
1113 assert(nnonz == 0 || ind !=
NULL);
1114 assert(nnonz == 0 || val !=
NULL);
1118 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1120 SPxSCIP* spx = lpi->
spx;
1123 LPColSet cols(ncols);
1124 DSVector colVector(ncols);
1130 for( i = 0; i < ncols; ++i )
1136 last = (i == ncols-1 ? nnonz : beg[i+1]);
1137 colVector.add( last-start, &ind[start], &val[start] );
1139 cols.add(obj[i], lb[i], colVector, ub[i]);
1141 spx->addColsReal(cols);
1143 catch(
const SPxException& x)
1146 std::string s = x.what();
1164 assert(lpi !=
NULL);
1166 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->numColsReal());
1170 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1190 assert(lpi !=
NULL);
1195 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1197 ncols = lpi->
spx->numColsReal();
1200 for( i = 0; i < ncols; ++i )
1223 assert(lpi !=
NULL);
1225 assert(lhs !=
NULL);
1226 assert(rhs !=
NULL);
1227 assert(nnonz == 0 || beg !=
NULL);
1228 assert(nnonz == 0 || ind !=
NULL);
1229 assert(nnonz == 0 || val !=
NULL);
1233 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1237 SPxSCIP* spx = lpi->
spx;
1238 LPRowSet rows(nrows);
1245 for( i = 0; i < nrows; ++i )
1251 last = (i == nrows-1 ? nnonz : beg[i+1]);
1252 rowVector.add( last-start, &ind[start], &val[start] );
1254 rows.add(lhs[i], rowVector, rhs[i]);
1256 spx->addRowsReal(rows);
1258 catch(
const SPxException& x)
1261 std::string s = x.what();
1279 assert(lpi !=
NULL);
1281 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->numRowsReal());
1285 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1305 assert(lpi !=
NULL);
1310 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1312 nrows = lpi->
spx->numRowsReal();
1315 for( i = 0; i < nrows; ++i )
1330 assert(lpi !=
NULL);
1335 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1354 assert(lpi !=
NULL);
1356 assert(ind !=
NULL);
1362 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1366 for( i = 0; i < ncols; ++i )
1368 assert(0 <= ind[i] && ind[i] < lpi->
spx->numColsReal());
1369 lpi->
spx->changeBoundsReal(ind[i], lb[i], ub[i]);
1370 assert(lpi->
spx->lowerReal(ind[i]) <= lpi->
spx->upperReal(ind[i]) + lpi->
spx->realParam(SoPlex::EPSILON_ZERO));
1373 catch(
const SPxException& x)
1376 std::string s = x.what();
1398 assert(lpi !=
NULL);
1400 assert(ind !=
NULL);
1401 assert(lhs !=
NULL);
1402 assert(rhs !=
NULL);
1406 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1410 for( i = 0; i < nrows; ++i )
1412 assert(0 <= ind[i] && ind[i] < lpi->
spx->numRowsReal());
1413 lpi->
spx->changeRangeReal(ind[i], lhs[i], rhs[i]);
1414 assert(lpi->
spx->lhsReal(ind[i]) <= lpi->
spx->rhsReal(ind[i]) + lpi->
spx->realParam(SoPlex::EPSILON_ZERO));
1417 catch(
const SPxException& x)
1420 std::string s = x.what();
1439 assert(lpi !=
NULL);
1441 assert(0 <= row && row < lpi->spx->numRowsReal());
1442 assert(0 <= col && col < lpi->spx->numColsReal());
1446 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1461 assert(lpi !=
NULL);
1466 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1485 assert(lpi !=
NULL);
1487 assert(ind !=
NULL);
1488 assert(obj !=
NULL);
1492 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1496 for( i = 0; i < ncols; ++i )
1498 assert(0 <= ind[i] && ind[i] < lpi->
spx->numColsReal());
1499 lpi->
spx->changeObjReal(ind[i], obj[i]);
1502 catch(
const SPxException& x)
1505 std::string s = x.what();
1526 assert(lpi !=
NULL);
1528 assert(scaleval != 0.0);
1534 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1537 SVector rowvec = lpi->
spx->rowVectorReal(row);
1538 lhs = lpi->
spx->lhsReal(row);
1539 rhs = lpi->
spx->rhsReal(row);
1545 if( lhs > -lpi->
spx->realParam(SoPlex::INFTY) )
1547 else if( scaleval < 0.0 )
1548 lhs = lpi->
spx->realParam(SoPlex::INFTY);
1549 if( rhs < lpi->spx->realParam(SoPlex::INFTY) )
1551 else if( scaleval < 0.0 )
1552 rhs = -lpi->
spx->realParam(SoPlex::INFTY);
1553 if( scaleval < 0.0 )
1561 LPRow lprow(lhs, rowvec, rhs);
1564 lpi->
spx->changeRowReal(row, lprow);
1565 assert(lpi->
spx->lhsReal(row) <= lpi->
spx->rhsReal(row));
1567 catch(
const SPxException& x)
1570 std::string s = x.what();
1594 assert(lpi !=
NULL);
1596 assert(scaleval != 0.0);
1602 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1605 SVector colvec = lpi->
spx->colVectorReal(col);
1606 obj = lpi->
spx->objReal(col);
1607 lb = lpi->
spx->lowerReal(col);
1608 ub = lpi->
spx->upperReal(col);
1617 if( lb > -lpi->
spx->realParam(SoPlex::INFTY) )
1619 else if( scaleval < 0.0 )
1620 lb = lpi->
spx->realParam(SoPlex::INFTY);
1621 if( ub < lpi->spx->realParam(SoPlex::INFTY) )
1623 else if( scaleval < 0.0 )
1624 ub = -lpi->
spx->realParam(SoPlex::INFTY);
1625 if( scaleval < 0.0 )
1633 LPCol lpcol(obj, colvec, ub, lb);
1636 lpi->
spx->changeColReal(col, lpcol);
1637 assert(lpi->
spx->lowerReal(col) <= lpi->
spx->upperReal(col));
1639 catch(
const SPxException& x)
1642 std::string s = x.what();
1671 assert(lpi !=
NULL);
1673 assert(nrows !=
NULL);
1675 *nrows = lpi->
spx->numRowsReal();
1688 assert(lpi !=
NULL);
1690 assert(ncols !=
NULL);
1692 *ncols = lpi->
spx->numColsReal();
1707 assert(lpi !=
NULL);
1709 assert(nnonz !=
NULL);
1713 if( lpi->
spx->numRowsReal() < lpi->
spx->numColsReal() )
1715 for( i = 0; i < lpi->
spx->numRowsReal(); ++i )
1716 (*nnonz) += lpi->
spx->rowVectorReal(i).size();
1720 for( i = 0; i < lpi->
spx->numColsReal(); ++i )
1721 (*nnonz) += lpi->
spx->colVectorReal(i).size();
1748 assert(lpi !=
NULL);
1750 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->numColsReal());
1756 const Vector& lbvec = lpi->
spx->lowerReal();
1757 const Vector& ubvec = lpi->
spx->upperReal();
1758 for( i = firstcol; i <= lastcol; ++i )
1760 lb[i-firstcol] = lbvec[i];
1761 ub[i-firstcol] = ubvec[i];
1770 for( i = firstcol; i <= lastcol; ++i )
1772 beg[i-firstcol] = *nnonz;
1773 const SVector& cvec = lpi->
spx->colVectorReal(i);
1774 for( j = 0; j < cvec.size(); ++j )
1776 ind[*nnonz] = cvec.index(j);
1777 val[*nnonz] = cvec.value(j);
1784 assert(beg ==
NULL);
1785 assert(ind ==
NULL);
1786 assert(val ==
NULL);
1813 assert(lpi !=
NULL);
1815 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->numRowsReal());
1819 assert(rhs !=
NULL);
1821 const Vector& lhsvec = lpi->
spx->lhsReal();
1822 const Vector& rhsvec = lpi->
spx->rhsReal();
1823 for( i = firstrow; i <= lastrow; ++i )
1825 lhs[i-firstrow] = lhsvec[i];
1826 rhs[i-firstrow] = rhsvec[i];
1830 assert(rhs ==
NULL);
1835 for( i = firstrow; i <= lastrow; ++i )
1837 beg[i-firstrow] = *nnonz;
1838 const SVector& rvec = lpi->
spx->rowVectorReal(i);
1839 for( j = 0; j < rvec.size(); ++j )
1841 ind[*nnonz] = rvec.index(j);
1842 val[*nnonz] = rvec.value(j);
1849 assert(beg ==
NULL);
1850 assert(ind ==
NULL);
1851 assert(val ==
NULL);
1864 int namestoragesize,
1868 assert( lpi !=
NULL );
1870 assert( colnames !=
NULL || namestoragesize == 0 );
1871 assert( namestorage !=
NULL || namestoragesize == 0 );
1872 assert( namestoragesize >= 0 );
1873 assert( storageleft !=
NULL );
1874 assert( 0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->numColsReal() );
1890 int namestoragesize,
1894 assert( lpi !=
NULL );
1896 assert( rownames !=
NULL || namestoragesize == 0 );
1897 assert( namestorage !=
NULL || namestoragesize == 0 );
1898 assert( namestoragesize >= 0 );
1899 assert( storageleft !=
NULL );
1900 assert( 0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->numRowsReal() );
1917 assert(lpi !=
NULL);
1919 assert(objsen !=
NULL);
1938 assert(lpi !=
NULL);
1940 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->numColsReal());
1941 assert(vals !=
NULL);
1943 for( i = firstcol; i <= lastcol; ++i )
1944 vals[i-firstcol] = lpi->
spx->objReal(i);
1962 assert(lpi !=
NULL);
1964 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->numColsReal());
1966 for( i = firstcol; i <= lastcol; ++i )
1969 lbs[i-firstcol] = lpi->
spx->lowerReal(i);
1971 ubs[i-firstcol] = lpi->
spx->upperReal(i);
1990 assert(lpi !=
NULL);
1992 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->numRowsReal());
1994 for( i = firstrow; i <= lastrow; ++i )
1997 lhss[i-firstrow] = lpi->
spx->lhsReal(i);
1999 rhss[i-firstrow] = lpi->
spx->rhsReal(i);
2015 assert(lpi !=
NULL);
2017 assert(0 <= col && col < lpi->spx->numColsReal());
2018 assert(0 <= row && row < lpi->spx->numRowsReal());
2019 assert(val !=
NULL);
2021 *val = lpi->
spx->colVectorReal(col)[row];
2044 assert( lpi !=
NULL );
2047 SPxOut::Verbosity verbosity;
2049 verbosity = lpi->
spx->spxout.getVerbosity();
2052 SCIPdebugMessage(
"calling SoPlex solve(): %d cols, %d rows\n", lpi->
spx->numColsReal(), lpi->
spx->numRowsReal());
2056 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2058 #ifdef WITH_LPSCHECK 2059 lpi->
spx->setDoubleCheck(CHECK_SPXSOLVE);
2063 if( lpi->
spx->getFromScratch() )
2067 lpi->
spx->clearBasis();
2069 catch(
const SPxException& x)
2072 std::string s = x.what();
2075 assert( lpi->
spx->status() != SPxSolver::OPTIMAL );
2079 assert(!lpi->
spx->getFromScratch() || lpi->
spx->status() == SPxSolver::NO_PROBLEM);
2081 SPxSolver::Status status = lpi->
spx->doSolve();
2082 SCIPdebugMessage(
" -> SoPlex status: %d, basis status: %d\n", lpi->
spx->status(), lpi->
spx->basisStatus());
2086 lpi->
spx->spxout.setVerbosity(verbosity);
2090 case SPxSolver::ABORT_TIME:
2091 case SPxSolver::ABORT_ITER:
2092 case SPxSolver::ABORT_VALUE:
2093 case SPxSolver::SINGULAR:
2094 case SPxSolver::REGULAR:
2096 case SPxSolver::OPTIMAL:
2097 case SPxSolver::UNBOUNDED:
2098 case SPxSolver::INFEASIBLE:
2112 assert(lpi !=
NULL);
2115 (void) lpi->
spx->setIntParam(SoPlex::ALGORITHM, SoPlex::ALGORITHM_PRIMAL);
2126 assert(lpi !=
NULL);
2129 (void) lpi->
spx->setIntParam(SoPlex::ALGORITHM, SoPlex::ALGORITHM_DUAL);
2150 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2151 lpi->
spx->savePreStrongbranchingBasis();
2161 assert( ! lpi->
spx->preStrongbranchingBasisFreed() );
2162 lpi->
spx->restorePreStrongbranchingBasis();
2163 lpi->
spx->freePreStrongbranchingBasis();
2185 SPxSolver::Status status;
2190 bool fromparentbasis;
2193 SPxOut::Verbosity verbosity;
2196 verbosity = lpi->
spx->spxout.getVerbosity();
2199 SCIPdebugMessage(
"calling SCIPlpiStrongbranch() on variable %d (%d iterations)\n", col, itlim);
2201 assert(lpi !=
NULL);
2205 assert(downvalid !=
NULL);
2206 assert(upvalid !=
NULL);
2210 fromparentbasis =
false;
2212 oldItlim = spx->intParam(SoPlex::ITERLIMIT);
2215 oldlb = spx->lowerReal(col);
2216 oldub = spx->upperReal(col);
2226 (void) spx->setIntParam(SoPlex::ALGORITHM, SoPlex::ALGORITHM_DUAL);
2230 newub =
EPSCEIL(psol-1.0, lpi->
spx->feastol());
2231 if( newub >= oldlb - 0.5 && down !=
NULL )
2233 SCIPdebugMessage(
"strong branching down on x%d (%g) with %d iterations\n", col, psol, itlim);
2235 spx->changeUpperReal(col, newub);
2236 assert(spx->lowerReal(col) <= spx->upperReal(col));
2238 (void) spx->setIntParam(SoPlex::ITERLIMIT, itlim);
2241 #ifdef WITH_LPSCHECK 2242 spx->setDoubleCheck(CHECK_SPXSTRONGBRANCH);
2244 status = spx->solve();
2248 case SPxSolver::OPTIMAL:
2249 *down = spx->objValueReal();
2253 case SPxSolver::ABORT_TIME:
2254 case SPxSolver::ABORT_ITER:
2255 case SPxSolver::ABORT_CYCLING:
2256 *down = spx->objValueReal();
2258 case SPxSolver::ABORT_VALUE:
2259 case SPxSolver::INFEASIBLE:
2260 *down = spx->getObjLimit();
2268 (*iter) += spx->numIterations();
2270 #ifdef STRONGBRANCH_RESTOREBASIS 2272 assert( ! spx->preStrongbranchingBasisFreed() );
2273 spx->restorePreStrongbranchingBasis();
2274 fromparentbasis =
false;
2278 if( (status == SPxSolver::ABORT_CYCLING || status == SPxSolver::SINGULAR) && !fromparentbasis && spx->numIterations() < itlim )
2280 SCIPdebugMessage(
" --> Repeat strong branching down with %d iterations after restoring basis\n",
2281 itlim - spx->numIterations());
2282 spx->setIntParam(SoPlex::ITERLIMIT, itlim - spx->numIterations());
2283 assert( ! spx->hasPreStrongbranchingBasis() );
2284 spx->restorePreStrongbranchingBasis();
2285 fromparentbasis =
true;
2290 fromparentbasis =
false;
2293 while( fromparentbasis );
2295 spx->changeUpperReal(col, oldub);
2296 assert(spx->lowerReal(col) <= spx->upperReal(col));
2298 else if( down !=
NULL )
2300 *down = spx->getObjLimit();
2310 if( newlb <= oldub + 0.5 && up !=
NULL )
2312 SCIPdebugMessage(
"strong branching up on x%d (%g) with %d iterations\n", col, psol, itlim);
2314 spx->changeLowerReal(col, newlb);
2315 assert(spx->lowerReal(col) <= spx->upperReal(col));
2317 (void) spx->setIntParam(SoPlex::ITERLIMIT, itlim);
2320 #ifdef WITH_LPSCHECK 2321 spx->setDoubleCheck(CHECK_SPXSTRONGBRANCH);
2323 status = spx->solve();
2327 case SPxSolver::OPTIMAL:
2328 *up = spx->objValueReal();
2332 case SPxSolver::ABORT_TIME:
2333 case SPxSolver::ABORT_ITER:
2334 case SPxSolver::ABORT_CYCLING:
2335 *up = spx->objValueReal();
2337 case SPxSolver::ABORT_VALUE:
2338 case SPxSolver::INFEASIBLE:
2339 *up = spx->getObjLimit();
2347 (*iter) += spx->numIterations();
2349 #ifdef STRONGBRANCH_RESTOREBASIS 2351 assert( ! spx->preStrongbranchingBasisFreed() );
2352 spx->restorePreStrongbranchingBasis();
2353 fromparentbasis =
false;
2357 else if( (status == SPxSolver::ABORT_CYCLING || status == SPxSolver::SINGULAR) && !fromparentbasis && spx->numIterations() < itlim )
2359 SCIPdebugMessage(
" --> Repeat strong branching up with %d iterations after restoring basis\n", itlim - spx->numIterations());
2360 assert( ! spx->hasPreStrongbranchingBasis() );
2361 spx->restorePreStrongbranchingBasis();
2362 spx->setIntParam(SoPlex::ITERLIMIT, itlim - spx->numIterations());
2364 fromparentbasis =
true;
2368 fromparentbasis =
false;
2371 while( fromparentbasis );
2373 spx->changeLowerReal(col, oldlb);
2374 assert(spx->lowerReal(col) <= spx->upperReal(col));
2376 else if( up !=
NULL )
2378 *up = spx->getObjLimit();
2386 (void) spx->setIntParam(SoPlex::ITERLIMIT, oldItlim);
2389 lpi->
spx->spxout.setVerbosity(verbosity);
2393 SCIPdebugMessage(
"SCIPlpiStrongbranch() returned SoPlex status %d\n",
int(status));
2418 retcode =
lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter);
2448 assert( cols !=
NULL );
2449 assert( psols !=
NULL );
2450 assert( down !=
NULL );
2451 assert( up !=
NULL );
2452 assert( downvalid !=
NULL );
2453 assert( upvalid !=
NULL );
2454 assert( down !=
NULL );
2459 for (
int j = 0; j < ncols; ++j)
2462 retcode =
lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter);
2492 retcode =
lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter);
2522 assert( cols !=
NULL );
2523 assert( psols !=
NULL );
2524 assert( down !=
NULL );
2525 assert( up !=
NULL );
2526 assert( downvalid !=
NULL );
2527 assert( upvalid !=
NULL );
2528 assert( down !=
NULL );
2533 for (
int j = 0; j < ncols; ++j)
2536 retcode =
lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter);
2565 assert(lpi !=
NULL);
2579 assert(lpi !=
NULL);
2580 assert(primalfeasible !=
NULL);
2581 assert(dualfeasible !=
NULL);
2598 assert(lpi !=
NULL);
2601 return (lpi->
spx->status() == SPxSolver::UNBOUNDED);
2613 assert(lpi !=
NULL);
2616 return (lpi->
spx->status() == SPxSolver::UNBOUNDED);
2626 assert(lpi !=
NULL);
2629 assert(lpi->
spx->status() != SPxSolver::UNBOUNDED || lpi->
spx->basisStatus() == SPxBasis::UNBOUNDED);
2634 return lpi->
spx->status() == SPxSolver::UNBOUNDED;
2644 assert(lpi !=
NULL);
2647 return (lpi->
spx->status() == SPxSolver::INFEASIBLE);
2655 SPxBasis::SPxStatus basestatus;
2659 assert(lpi !=
NULL);
2662 basestatus = lpi->
spx->basisStatus();
2667 assert(basestatus == SPxBasis::OPTIMAL || lpi->
spx->status() != SPxSolver::OPTIMAL);
2669 return basestatus == SPxBasis::OPTIMAL || basestatus == SPxBasis::PRIMAL;
2681 assert(lpi !=
NULL);
2684 return (lpi->
spx->status() == SPxSolver::INFEASIBLE);
2696 assert(lpi !=
NULL);
2699 return (lpi->
spx->status() == SPxSolver::INFEASIBLE);
2709 assert(lpi !=
NULL);
2712 return lpi->
spx->status() == SPxSolver::INFEASIBLE && lpi->
spx->basisStatus() == SPxBasis::DUAL;
2722 assert(lpi !=
NULL);
2725 return (lpi->
spx->status() == SPxSolver::UNBOUNDED);
2735 assert(lpi !=
NULL);
2741 assert(lpi->
spx->basisStatus() == SPxBasis::OPTIMAL || lpi->
spx->status() != SPxSolver::OPTIMAL);
2743 return (lpi->
spx->basisStatus() == SPxBasis::OPTIMAL) || lpi->
spx->basisStatus() == SPxBasis::DUAL;
2753 assert(lpi !=
NULL);
2754 assert((lpi->
spx->basisStatus() == SPxBasis::OPTIMAL)
2760 return (lpi->
spx->basisStatus() == SPxBasis::OPTIMAL);
2770 assert(lpi !=
NULL);
2773 if( lpi->
spx->status() == SPxSolver::ERROR || lpi->
spx->status() == SPxSolver::SINGULAR )
2805 assert(lpi !=
NULL);
2808 return (lpi->
spx->status() == SPxSolver::ABORT_VALUE);
2818 assert(lpi !=
NULL);
2821 return (lpi->
spx->status() == SPxSolver::ABORT_ITER);
2831 assert(lpi !=
NULL);
2834 return (lpi->
spx->status() == SPxSolver::ABORT_TIME);
2844 assert(lpi !=
NULL);
2847 return static_cast<int>(lpi->
spx->status());
2858 assert(lpi !=
NULL);
2875 assert(lpi !=
NULL);
2877 assert(objval !=
NULL);
2879 *objval = lpi->
spx->objValueReal();
2896 assert(lpi !=
NULL);
2899 if( objval !=
NULL )
2900 *objval = lpi->
spx->objValueReal();
2904 if( primsol !=
NULL )
2906 Vector tmp(lpi->
spx->numColsReal(), primsol);
2907 (void)lpi->
spx->getPrimalReal(tmp);
2909 if( dualsol !=
NULL )
2911 Vector tmp(lpi->
spx->numRowsReal(), dualsol);
2912 (void)lpi->
spx->getDualReal(tmp);
2914 if( activity !=
NULL )
2916 Vector tmp(lpi->
spx->numRowsReal(), activity);
2917 (void)lpi->
spx->getSlacksReal(tmp);
2919 if( redcost !=
NULL )
2921 Vector tmp(lpi->
spx->numColsReal(), redcost);
2922 (void)lpi->
spx->getRedCostReal(tmp);
2925 catch(
const SPxException& x)
2928 std::string s = x.what();
2945 assert(lpi !=
NULL);
2950 Vector tmp(lpi->
spx->numColsReal(), ray);
2951 (void)lpi->
spx->getPrimalRayReal(tmp);
2953 catch(
const SPxException& x)
2956 std::string s = x.what();
2973 assert(lpi !=
NULL);
2978 Vector tmp(lpi->
spx->numRowsReal(), dualfarkas);
2979 (void)lpi->
spx->getDualFarkasReal(tmp);
2981 catch(
const SPxException& x)
2984 std::string s = x.what();
3001 assert(lpi !=
NULL);
3004 *iterations = lpi->
spx->numIterations();
3022 assert(lpi !=
NULL);
3023 assert(quality !=
NULL);
3027 assert(lpi !=
NULL);
3028 assert(quality !=
NULL);
3030 SCIPdebugMessage(
"requesting solution quality from SoPlex: quality %d\n", qualityindicator);
3032 switch( qualityindicator )
3035 success = lpi->
spx->getEstimatedCondition(*quality);
3039 success = lpi->
spx->getExactCondition(*quality);
3080 assert(lpi !=
NULL);
3083 assert( lpi->
spx->preStrongbranchingBasisFreed() );
3085 if( rstat !=
NULL && cstat !=
NULL )
3087 for( i = 0; i < lpi->
spx->numRowsReal(); ++i )
3089 switch( lpi->
spx->basisRowStatus(i) )
3091 case SPxSolver::BASIC:
3094 case SPxSolver::FIXED:
3095 case SPxSolver::ON_LOWER:
3098 case SPxSolver::ON_UPPER:
3101 case SPxSolver::ZERO:
3102 SCIPerrorMessage(
"slack variable has basis status ZERO (should not occur)\n");
3104 case SPxSolver::UNDEFINED:
3115 for( i = 0; i < lpi->
spx->numColsReal(); ++i )
3118 switch( lpi->
spx->basisColStatus(i) )
3120 case SPxSolver::BASIC:
3123 case SPxSolver::FIXED:
3137 case SPxSolver::ON_LOWER:
3140 case SPxSolver::ON_UPPER:
3143 case SPxSolver::ZERO:
3146 case SPxSolver::UNDEFINED:
3166 int nCols = lpi->
spx->numColsReal();
3167 int nRows = lpi->
spx->numRowsReal();
3171 assert(lpi !=
NULL);
3173 assert(cstat !=
NULL || nCols == 0);
3174 assert(rstat !=
NULL || nRows == 0);
3176 assert( lpi->
spx->preStrongbranchingBasisFreed() );
3179 SPxSolver::VarStatus* spxcstat =
NULL;
3180 SPxSolver::VarStatus* spxrstat =
NULL;
3184 for( i = 0; i < nRows; ++i )
3189 spxrstat[i] = SPxSolver::ON_LOWER;
3192 spxrstat[i] = SPxSolver::BASIC;
3195 spxrstat[i] = SPxSolver::ON_UPPER;
3198 SCIPerrorMessage(
"slack variable has basis status ZERO (should not occur)\n");
3211 for( i = 0; i < nCols; ++i )
3216 spxcstat[i] = SPxSolver::ON_LOWER;
3219 spxcstat[i] = SPxSolver::BASIC;
3222 spxcstat[i] = SPxSolver::ON_UPPER;
3225 spxcstat[i] = SPxSolver::ZERO;
3252 assert(lpi !=
NULL);
3255 assert(lpi->
spx->preStrongbranchingBasisFreed());
3257 lpi->
spx->getBasisInd(bind);
3280 assert( lpi !=
NULL);
3282 assert(lpi->
spx->preStrongbranchingBasisFreed());
3285 assert(r < lpi->spx->numRowsReal());
3287 if( ! lpi->
spx->getBasisInverseRowReal(r, coef, inds, ninds) )
3314 assert( lpi !=
NULL );
3316 assert( lpi->
spx->preStrongbranchingBasisFreed() );
3318 if( ! lpi->
spx->getBasisInverseColReal(c, coef, inds, ninds) )
3348 assert(lpi !=
NULL);
3350 assert( lpi->
spx->preStrongbranchingBasisFreed() );
3352 nrows = lpi->
spx->numRowsReal();
3353 ncols = lpi->
spx->numColsReal();
3357 if( binvrow ==
NULL )
3366 assert(binv !=
NULL);
3374 Vector binvvec(nrows, binv);
3375 for( c = 0; c < ncols; ++c )
3376 coef[c] = binvvec * lpi->
spx->colVectorReal(c);
3400 DVector col(lpi->
spx->numRowsReal());
3404 assert( lpi !=
NULL );
3406 assert( lpi->
spx->preStrongbranchingBasisFreed() );
3410 assert(c < lpi->spx->numColsReal());
3419 col = lpi->
spx->colVectorReal(c);
3422 if( ! lpi->
spx->getBasisInverseTimesVecReal(col.get_ptr(), coef) )
3452 assert(blkmem !=
NULL);
3453 assert(lpi !=
NULL);
3455 assert(lpistate !=
NULL);
3457 assert( lpi->
spx->preStrongbranchingBasisFreed() );
3459 ncols = lpi->
spx->numColsReal();
3460 nrows = lpi->
spx->numRowsReal();
3475 (*lpistate)->ncols = ncols;
3476 (*lpistate)->nrows = nrows;
3497 assert(lpi !=
NULL);
3499 assert(lpistate !=
NULL);
3501 assert( lpi->
spx->preStrongbranchingBasisFreed() );
3503 lpncols = lpi->
spx->numColsReal();
3504 lpnrows = lpi->
spx->numRowsReal();
3505 assert(lpistate->
ncols <= lpncols);
3506 assert(lpistate->
nrows <= lpnrows);
3516 for( i = lpistate->
ncols; i < lpncols; ++i )
3522 bnd = lpi->
spx->lowerReal(i);
3534 for( i = lpistate->
nrows; i < lpnrows; ++i )
3550 assert(lpi !=
NULL);
3555 lpi->
spx->clearBasis();
3557 catch(
const SPxException& x)
3560 std::string s = x.what();
3563 assert( lpi->
spx->status() != SPxSolver::OPTIMAL );
3579 assert(lpi !=
NULL);
3580 assert(lpistate !=
NULL);
3582 if ( *lpistate !=
NULL )
3605 assert( lpi->
spx->preStrongbranchingBasisFreed() );
3621 assert( lpi->
spx->preStrongbranchingBasisFreed() );
3653 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 3657 assert(blkmem !=
NULL);
3658 assert(lpi !=
NULL);
3660 assert(lpinorms !=
NULL);
3662 lpi->
spx->getNdualNorms(nrows, ncols);
3664 if( nrows == 0 && ncols == 0)
3673 (*lpinorms)->nrows = 0;
3674 (*lpinorms)->ncols = 0;
3676 SCIPdebugMessage(
"storing SoPlex LPi pricing norms in %p (%d rows, %d cols)\n", (
void *) *lpinorms, nrows, ncols);
3678 if( !lpi->
spx->getDualNorms((*lpinorms)->nrows, (*lpinorms)->ncols, (*lpinorms)->norms) )
3683 assert(*lpinorms ==
NULL);
3688 assert(nrows == (*lpinorms)->nrows);
3689 assert(ncols == (*lpinorms)->ncols);
3708 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 3709 assert(blkmem !=
NULL);
3710 assert(lpi !=
NULL);
3714 if( lpinorms ==
NULL )
3717 assert(lpinorms->
nrows <= lpi->
spx->numRowsReal());
3718 assert(lpinorms->
ncols <= lpi->
spx->numColsReal());
3720 if( lpinorms->
nrows == 0 )
3723 SCIPdebugMessage(
"loading LPi simplex norms %p (%d rows, %d cols) into SoPlex LP with %d rows and %d cols\n",
3724 (
void *) lpinorms, lpinorms->
nrows, lpinorms->
ncols, lpi->
spx->numRowsReal(), lpi->
spx->numColsReal());
3739 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 3740 assert(lpi !=
NULL);
3741 assert(lpinorms !=
NULL);
3747 assert(*lpinorms ==
NULL);
3774 assert(lpi !=
NULL);
3776 assert(ival !=
NULL);
3781 *ival = lpi->
spx->getFromScratch();
3784 *ival = lpi->
spx->getLpInfo();
3787 *ival = lpi->
spx->intParam(SoPlex::ITERLIMIT);
3790 *ival = lpi->
spx->intParam(SoPlex::SIMPLIFIER) == SoPlex::SIMPLIFIER_AUTO;
3796 *ival = (
int) (lpi->
spx->intParam(SoPlex::SCALER) != SoPlex::SCALER_OFF);
3798 #if SOPLEX_VERSION >= 201 3800 *ival = (int) (lpi->
spx->intParam(SoPlex::TIMER));
3819 assert(lpi !=
NULL);
3826 lpi->
spx->setFromScratch(
bool(ival));
3830 lpi->
spx->setLpInfo(
bool(ival));
3834 (void) lpi->
spx->setIntParam(SoPlex::ITERLIMIT, ival);
3838 (void) lpi->
spx->setIntParam(SoPlex::SIMPLIFIER, (ival ? SoPlex::SIMPLIFIER_AUTO : SoPlex::SIMPLIFIER_OFF));
3846 (void) lpi->
spx->setIntParam(SoPlex::PRICER, SoPlex::PRICER_AUTO);
3849 (void) lpi->
spx->setIntParam(SoPlex::PRICER, SoPlex::PRICER_STEEP);
3852 (void) lpi->
spx->setIntParam(SoPlex::PRICER, SoPlex::PRICER_PARMULT);
3855 (void) lpi->
spx->setIntParam(SoPlex::PRICER, SoPlex::PRICER_STEEP);
3858 (void) lpi->
spx->setIntParam(SoPlex::PRICER, SoPlex::PRICER_QUICKSTEEP);
3861 (void) lpi->
spx->setIntParam(SoPlex::PRICER, SoPlex::PRICER_DEVEX);
3869 (void) lpi->
spx->setIntParam(SoPlex::SCALER, ( ival ? SoPlex::SCALER_BIEQUI : SoPlex::SCALER_OFF));
3871 #if SOPLEX_VERSION >= 201 3873 assert(ival >= 0 && ival < 3);
3874 (void) lpi->
spx->setIntParam(SoPlex::TIMER, ival);
3893 assert(lpi !=
NULL);
3895 assert(dval !=
NULL);
3900 *dval = lpi->
spx->feastol();
3903 *dval = lpi->
spx->opttol();
3906 *dval = lpi->
spx->realParam(SoPlex::OBJLIMIT_LOWER);
3909 *dval = lpi->
spx->realParam(SoPlex::OBJLIMIT_UPPER);
3912 *dval = lpi->
spx->realParam(SoPlex::TIMELIMIT);
3915 *dval = lpi->
spx->realParam(SoPlex::REPRESENTATION_SWITCH);
3938 assert(lpi !=
NULL);
3944 lpi->
spx->setFeastol(dval);
3947 lpi->
spx->setOpttol(dval);
3950 (void) lpi->
spx->setRealParam(SoPlex::OBJLIMIT_LOWER, dval);
3953 (void) lpi->
spx->setRealParam(SoPlex::OBJLIMIT_UPPER, dval);
3956 (void) lpi->
spx->setRealParam(SoPlex::TIMELIMIT, dval);
3959 assert(dval >= -1.5);
3963 (
void) lpi->
spx->setRealParam(SoPlex::REPRESENTATION_SWITCH, dval);
3995 return lpi->
spx->realParam(SoPlex::INFTY);
4006 return (val >= lpi->
spx->realParam(SoPlex::INFTY));
4024 const char* filename
4029 f = fopen(filename,
"r");
4046 assert(lpi !=
NULL);
4049 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4056 assert(lpi->
spx->intParam(SoPlex::READMODE) == SoPlex::READMODE_REAL);
4057 if( !lpi->
spx->readFile(fname) )
4060 catch(
const SPxException& x)
4063 std::string s = x.what();
4080 assert(lpi !=
NULL);
4085 (void) lpi->
spx->writeFileReal(fname);
4087 catch(
const SPxException& x)
4090 std::string s = x.what();
SCIP_Bool SCIPlpiIsDualFeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetBInvRow(SCIP_LPI *lpi, int r, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiDelColset(SCIP_LPI *lpi, int *dstat)
SCIP_Bool SCIPlpiExistsPrimalRay(SCIP_LPI *lpi)
enum SCIP_LPSolQuality SCIP_LPSOLQUALITY
#define BMSallocBlockMemory(mem, ptr)
SCIP_RETCODE SCIPlpiReadLP(SCIP_LPI *lpi, const char *fname)
SCIP_RETCODE SCIPlpiStrongbranchFrac(SCIP_LPI *lpi, int col, SCIP_Real psol, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
SCIP_RETCODE SCIPlpiSetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int ival)
SCIP_RETCODE SCIPlpiGetNCols(SCIP_LPI *lpi, int *ncols)
enum SCIP_ObjSen SCIP_OBJSEN
SCIP_RETCODE SCIPlpiSolvePrimal(SCIP_LPI *lpi)
void SCIPdecodeDualBit(const SCIP_DUALPACKET *inp, int *out, int count)
interface methods for specific LP solvers
int SCIPlpiGetInternalStatus(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiIsPrimalInfeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiDelRows(SCIP_LPI *lpi, int firstrow, int lastrow)
static SCIP_RETCODE lpistateCreate(SCIP_LPISTATE **lpistate, BMS_BLKMEM *blkmem, int ncols, int nrows)
SCIP_RETCODE SCIPlpiDelRowset(SCIP_LPI *lpi, int *dstat)
static int rowpacketNum(int nrows)
static void invalidateSolution(SCIP_LPI *lpi)
enum SCIP_Retcode SCIP_RETCODE
SCIP_RETCODE SCIPlpiSolveDual(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiIsPrimalFeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiEndStrongbranch(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiAddCols(SCIP_LPI *lpi, int ncols, const SCIP_Real *obj, const SCIP_Real *lb, const SCIP_Real *ub, char **, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
SCIP_RETCODE SCIPlpiGetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int *ival)
enum SCIP_LPParam SCIP_LPPARAM
const char * SCIPlpiGetSolverName(void)
SCIP_RETCODE SCIPlpiSetState(SCIP_LPI *lpi, BMS_BLKMEM *, SCIP_LPISTATE *lpistate)
SCIP_RETCODE SCIPlpiFreeNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
SCIP_RETCODE SCIPlpiGetNRows(SCIP_LPI *lpi, int *nrows)
enum SCIP_Pricing SCIP_PRICING
static void lpistateFree(SCIP_LPISTATE **lpistate, BMS_BLKMEM *blkmem)
#define CHECK_SOPLEX_PARAM(x)
static SCIP_RETCODE ensureRstatMem(SCIP_LPI *lpi, int num)
SCIP_RETCODE SCIPlpiGetObjsen(SCIP_LPI *lpi, SCIP_OBJSEN *objsen)
SCIP_RETCODE SCIPlpiSetBase(SCIP_LPI *lpi, int *cstat, int *rstat)
SCIP_RETCODE SCIPlpiGetPrimalRay(SCIP_LPI *lpi, SCIP_Real *ray)
SCIP_RETCODE SCIPlpiIgnoreInstability(SCIP_LPI *lpi, SCIP_Bool *success)
SCIP_DUALPACKET COLPACKET
SCIP_RETCODE SCIPlpiGetCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real *val)
#define SOPLEX_TRY(messagehdlr, x)
SCIP_RETCODE SCIPlpiReadState(SCIP_LPI *lpi, const char *fname)
SCIP_RETCODE SCIPlpiGetBInvARow(SCIP_LPI *lpi, int r, const SCIP_Real *binvrow, SCIP_Real *coef, int *inds, int *ninds)
void * SCIPlpiGetSolverPointer(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetObjval(SCIP_LPI *lpi, SCIP_Real *objval)
SCIP_RETCODE SCIPlpiLoadColLP(SCIP_LPI *lpi, SCIP_OBJSEN objsen, int ncols, const SCIP_Real *obj, const SCIP_Real *lb, const SCIP_Real *ub, char **colnames, int nrows, const SCIP_Real *lhs, const SCIP_Real *rhs, char **, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
SCIP_Bool SCIPlpiHasPrimalRay(SCIP_LPI *lpi)
static SCIP_RETCODE ensureCstatMem(SCIP_LPI *lpi, int num)
packing single and dual bit values
SCIP_RETCODE SCIPlpiGetNNonz(SCIP_LPI *lpi, int *nnonz)
static int colpacketNum(int ncols)
SCIP_RETCODE SCIPlpiScaleRow(SCIP_LPI *lpi, int row, SCIP_Real scaleval)
SCIP_Bool SCIPlpiIsInfinity(SCIP_LPI *lpi, SCIP_Real val)
SCIP_RETCODE SCIPlpiFree(SCIP_LPI **lpi)
SCIP_RETCODE SCIPlpiSetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS *lpinorms)
SCIP_DUALPACKET ROWPACKET
#define BMSallocMemory(ptr)
void SCIPmessagePrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
SCIP_Bool SCIPlpiIsTimelimExc(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiClear(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiScaleCol(SCIP_LPI *lpi, int col, SCIP_Real scaleval)
SCIP_Bool SCIPlpiExistsDualRay(SCIP_LPI *lpi)
static void setIntParam(SCIP_LPI *lpi, int const param, int const parval)
#define BMSreallocMemoryArray(ptr, num)
static SCIP_RETCODE lpiStrongbranch(SCIP_LPI *lpi, int col, SCIP_Real psol, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
#define BMSfreeMemory(ptr)
SCIP_Bool SCIPlpiIsPrimalUnbounded(SCIP_LPI *lpi)
static SCIP_Bool fileExists(const char *filename)
SCIP_RETCODE SCIPlpiStrongbranchInt(SCIP_LPI *lpi, int col, SCIP_Real psol, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
const char * SCIPlpiGetSolverDesc(void)
void SCIPencodeDualBit(const int *inp, SCIP_DUALPACKET *out, int count)
#define BMSfreeMemoryArrayNull(ptr)
#define SOPLEX_SUBVERSION
SCIP_RETCODE SCIPlpiCreate(SCIP_LPI **lpi, SCIP_MESSAGEHDLR *messagehdlr, const char *name, SCIP_OBJSEN objsen)
SCIP_RETCODE SCIPlpiGetDualfarkas(SCIP_LPI *lpi, SCIP_Real *dualfarkas)
unsigned int SCIP_DUALPACKET
SCIP_RETCODE SCIPlpiWriteLP(SCIP_LPI *lpi, const char *fname)
SCIP_Bool SCIPlpiWasSolved(SCIP_LPI *lpi)
#define BMSallocBlockMemoryArray(mem, ptr, num)
SCIP_RETCODE SCIPlpiGetBounds(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *lbs, SCIP_Real *ubs)
static void setFeastol(SCIP_NLPIPROBLEM *nlpiproblem, SCIP_Real feastol)
SCIP_RETCODE SCIPlpiChgCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real newval)
SCIP_Bool SCIPlpiIsObjlimExc(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetSides(SCIP_LPI *lpi, int firstrow, int lastrow, SCIP_Real *lhss, SCIP_Real *rhss)
SCIP_Real SCIPlpiInfinity(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetSolFeasibility(SCIP_LPI *lpi, SCIP_Bool *primalfeasible, SCIP_Bool *dualfeasible)
#define BMSfreeBlockMemoryArray(mem, ptr, num)
SCIP_RETCODE SCIPlpiStrongbranchesFrac(SCIP_LPI *lpi, int *cols, int ncols, SCIP_Real *psols, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
static void lpistatePack(SCIP_LPISTATE *lpistate, const int *cstat, const int *rstat)
SCIP_RETCODE SCIPlpiGetIterations(SCIP_LPI *lpi, int *iterations)
SCIP_RETCODE SCIPlpiGetSol(SCIP_LPI *lpi, SCIP_Real *objval, SCIP_Real *primsol, SCIP_Real *dualsol, SCIP_Real *activity, SCIP_Real *redcost)
SCIP_RETCODE SCIPlpiDelCols(SCIP_LPI *lpi, int firstcol, int lastcol)
SCIP_RETCODE SCIPlpiStrongbranchesInt(SCIP_LPI *lpi, int *cols, int ncols, SCIP_Real *psols, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
SCIP_RETCODE SCIPlpiGetRealSolQuality(SCIP_LPI *lpi, SCIP_LPSOLQUALITY qualityindicator, SCIP_Real *quality)
#define BMSfreeBlockMemory(mem, ptr)
#define BMSallocMemoryCPP(size)
static SCIP_RETCODE spxSolve(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
SCIP_RETCODE SCIPlpiGetRowNames(SCIP_LPI *lpi, int firstrow, int lastrow, char **rownames, char *namestorage, int namestoragesize, int *storageleft)
SCIP_RETCODE SCIPlpiChgObjsen(SCIP_LPI *lpi, SCIP_OBJSEN objsen)
SCIP_RETCODE SCIPlpiAddRows(SCIP_LPI *lpi, int nrows, const SCIP_Real *lhs, const SCIP_Real *rhs, char **, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
SCIP_RETCODE SCIPlpiGetState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
SCIP_Bool SCIPlpiIsDualInfeasible(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiHasStateBasis(SCIP_LPI *lpi, SCIP_LPISTATE *lpistate)
SCIP_RETCODE SCIPlpiChgBounds(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *lb, const SCIP_Real *ub)
SCIP_Bool SCIPlpiIsOptimal(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetCols(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *lb, SCIP_Real *ub, int *nnonz, int *beg, int *ind, SCIP_Real *val)
static void lpistateUnpack(const SCIP_LPISTATE *lpistate, int *cstat, int *rstat)
SCIP_RETCODE SCIPlpiGetBase(SCIP_LPI *lpi, int *cstat, int *rstat)
public methods for message output
SCIP_Bool SCIPlpiHasDualRay(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiChgObj(SCIP_LPI *lpi, int ncols, int *ind, SCIP_Real *obj)
SCIP_DUALPACKET COLPACKET
SCIP_RETCODE SCIPlpiGetColNames(SCIP_LPI *lpi, int firstcol, int lastcol, char **colnames, char *namestorage, int namestoragesize, int *storageleft)
SCIP_RETCODE SCIPlpiFreeState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
SCIP_Bool SCIPlpiIsDualUnbounded(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetBasisInd(SCIP_LPI *lpi, int *bind)
SCIP_Bool SCIPlpiIsStable(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetObj(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *vals)
SCIP_RETCODE SCIPlpiSolveBarrier(SCIP_LPI *lpi, SCIP_Bool crossover)
SCIP_DUALPACKET ROWPACKET
#define SOPLEX_TRY_ABORT(x)
SCIP_MESSAGEHDLR * messagehdlr
SCIP_RETCODE SCIPlpiGetRows(SCIP_LPI *lpi, int firstrow, int lastrow, SCIP_Real *lhs, SCIP_Real *rhs, int *nnonz, int *beg, int *ind, SCIP_Real *val)
#define BMSallocMemoryArray(ptr, num)
SCIP_RETCODE SCIPlpiSetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real dval)
SCIP_RETCODE SCIPlpiStartStrongbranch(SCIP_LPI *lpi)
struct BMS_BlkMem BMS_BLKMEM
SCIP_RETCODE SCIPlpiWriteState(SCIP_LPI *lpi, const char *fname)
SCIP_Bool SCIPlpiIsIterlimExc(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiClearState(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiChgSides(SCIP_LPI *lpi, int nrows, const int *ind, const SCIP_Real *lhs, const SCIP_Real *rhs)
SCIP_RETCODE SCIPlpiGetBInvCol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiGetBInvACol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiGetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real *dval)