43 #define AUTOPRICING_ITERSWITCH 10000 44 #define STRONGBRANCH_RESTOREBASIS 50 #ifdef SCIP_WITH_LPSCHECK 53 #define CHECK_SPXSOLVE true 54 #define CHECK_SPXSTRONGBRANCH true 56 #define EXIT_AT_WRONG_RESULT false 57 #define EXIT_AT_CPXERROR false 59 #define CPX_CALL(x) do \ 62 if( (_cpxstat_ = (x)) != 0 ) \ 64 SCIPmessagePrintWarning(m_messagehdlr, "CPLEX error <%d>; SoPlex result unchecked\n", _cpxstat_); \ 65 if( EXIT_AT_CPXERROR ) \ 89 #pragma GCC diagnostic ignored "-Wclass-memaccess" 97 #ifndef SOPLEX_SUBVERSION 98 #define SOPLEX_SUBVERSION 0 101 #ifndef SOPLEX_APIVERSION 102 #define SOPLEX_APIVERSION 0 106 #if (SOPLEX_VERSION < 133) 107 #error "This interface is not compatible with SoPlex versions prior to 1.4" 111 #if (SOPLEX_VERSION >= 160) 112 #if (SOPLEX_APIVERSION <= 5) 113 #include "spxgithash.h" 117 #define WITH_BOUNDFLIPPING 118 #if (SOPLEX_APIVERSION <= 5) 120 #include "spxsolver.h" 121 #include "slufactor.h" 122 #include "spxsteeppr.h" 123 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 6) || SOPLEX_VERSION > 160) 124 #include "spxsteepexpr.h" 126 #include "spxparmultpr.h" 127 #include "spxdevexpr.h" 128 #include "spxfastrt.h" 129 #include "spxmainsm.h" 130 #include "spxequilisc.h" 132 #ifdef WITH_BOUNDFLIPPING 133 #include "spxboundflippingrt.h" 145 #if defined(_MSC_VER) && _MSC_VER < 1900 147 #define snprintf _snprintf 151 #define SOPLEX_VERBLEVEL 5 172 #define SOPLEX_TRY(messagehdlr, x) do \ 178 catch( const SPxMemoryException& E ) \ 180 std::string s = E.what(); \ 181 SCIPerrorMessage("SoPlex threw a memory exception: %s\n", s.c_str()); \ 184 catch( const SPxException& E ) \ 186 std::string s = E.what(); \ 187 SCIPmessagePrintWarning((messagehdlr), "SoPlex threw an exception: %s\n", s.c_str()); \ 188 return SCIP_LPERROR; \ 194 #define SOPLEX_TRY(messagehdlr, x) do \ 200 catch( const SPxMemoryException& E ) \ 202 std::string s = E.what(); \ 203 SCIPerrorMessage("SoPlex threw a memory exception: %s\n", s.c_str()); \ 206 catch( const SPxException& ) \ 208 return SCIP_LPERROR; \ 217 #define SOPLEX_TRY_ABORT(x) do \ 223 catch( const SPxException& E ) \ 225 std::string s = E.what(); \ 226 SCIPerrorMessage("SoPlex threw an exception: %s\n", s.c_str()); \ 237 SPxLP::SPxSense m_sense;
239 SPxSteepPR m_price_steep;
240 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 6) || SOPLEX_VERSION > 160) 241 SPxSteepExPR m_price_steep_ex;
243 SPxSteepPR m_price_steep_ex;
245 SPxParMultPR m_price_parmult;
246 SPxDevexPR m_price_devex;
247 #ifdef WITH_BOUNDFLIPPING 248 SPxBoundFlippingRT m_ratio;
265 DataArray<SPxSolver::VarStatus> m_rowstat;
266 DataArray<SPxSolver::VarStatus> m_colstat;
270 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 274 #ifdef SCIP_WITH_LPSCHECK 285 const char* probname =
NULL 289 m_fromscratch(
false),
303 m_messagehdlr(messagehdlr)
305 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 306 setOutstream(m_spxout);
309 setSense(SPxLP::MINIMIZE);
310 #if SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 221 && SOPLEX_SUBVERSION == 4) 311 setBasisSolver(&m_slu);
316 setPricer(&m_price_steep);
319 if ( probname !=
NULL )
322 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 323 m_lpifeastol = SPxSolver::feastol();
324 m_lpiopttol = SPxSolver::opttol();
326 m_lpifeastol = SPxSolver::delta();
327 m_lpiopttol = SPxSolver::delta();
330 #ifdef SCIP_WITH_LPSCHECK 332 m_cpxenv = CPXopenCPLEX(&cpxstat);
333 assert(m_cpxenv !=
NULL);
334 m_cpxlp = CPXcreateprob(m_cpxenv, &cpxstat, probname !=
NULL ? probname :
"spxcheck");
335 (void) CPXsetintparam(m_cpxenv, CPX_PARAM_SCRIND, 0);
337 m_doublecheck =
false;
343 if( m_probname !=
NULL )
344 spx_free(m_probname);
346 freePreStrongbranchingBasis();
348 if( m_rownames !=
NULL )
350 m_rownames->~NameSet();
351 spx_free(m_rownames);
353 if( m_colnames !=
NULL )
355 m_colnames->~NameSet();
356 spx_free(m_colnames);
359 #ifdef SCIP_WITH_LPSCHECK 360 (void) CPXfreeprob(m_cpxenv, &m_cpxlp);
361 (void) CPXcloseCPLEX(&m_cpxenv);
378 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 379 SPxSolver::setFeastol(d);
381 SPxSolver::setDelta(d);
398 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 399 SPxSolver::setOpttol(d);
401 SPxSolver::setDelta(d);
405 bool isPerturbed()
const 408 return (shift() >= 10.0 * epsilon());
412 void setIterationLimit(
421 setPricer(&m_price_devex);
422 m_autopricing =
true;
427 setPricer(&m_price_steep);
428 m_autopricing =
false;
431 void setSteepPricer()
433 setPricer(&m_price_steep_ex);
434 m_autopricing =
false;
437 void setSteepQStartPricer()
439 setPricer(&m_price_steep);
440 m_autopricing =
false;
443 void setParmultPricer()
445 setPricer(&m_price_parmult);
446 m_autopricing =
false;
449 void setDevexPricer()
451 setPricer(&m_price_devex);
452 m_autopricing =
false;
456 int getIterationLimit()
const 461 bool getFromScratch()
const 463 return m_fromscratch;
466 void setFromScratch(
bool fs)
471 int getScaling()
const 476 void setScaling(
int s)
481 bool getPresolving()
const 486 void setPresolving(
bool p)
491 bool getLpInfo()
const 496 void setLpInfo(
bool li)
501 SPxLP::SPxSense getSense()
const 503 assert(m_sense == sense());
508 void setSense(
const SPxLP::SPxSense sen)
510 assert(m_sense == sense());
521 SPxSolver::setTerminationValue(getObjUpLimit());
523 else if( m_sense == SPxLP::MAXIMIZE && getObjLoLimit() > -
soplex::infinity )
526 SPxSolver::setTerminationValue(getObjLoLimit());
531 void setProbname(
const char* probname)
535 assert(probname !=
NULL);
536 if( m_probname !=
NULL )
537 spx_free(m_probname);
539 len = strlen(probname);
540 spx_alloc(m_probname, len + 1);
541 memcpy(m_probname, probname, len + 1);
544 Real getObjLoLimit()
const 549 void setObjLoLimit(Real limit)
551 if( getSense() == SPxLP::MAXIMIZE )
553 SCIPdebugMessage(
"setting termination value from <%g> to <%g>\n", m_objLoLimit, limit);
554 SPxSolver::setTerminationValue(limit);
556 m_objLoLimit = limit;
559 Real getObjUpLimit()
const 564 void setObjUpLimit(Real limit)
566 if( getSense() == SPxLP::MINIMIZE )
568 SCIPdebugMessage(
"setting termination value from <%g> to <%g>\n", m_objUpLimit, limit);
569 SPxSolver::setTerminationValue(limit);
571 m_objUpLimit = limit;
574 void setRep(SPxSolver::Representation p_rep)
578 SCIPdebugMessage(
"switching to %s representation of the basis\n", p_rep == SPxSolver::ROW ?
"row" :
"column");
579 SPxSolver::setRep(p_rep);
583 #ifdef SCIP_WITH_LPSCHECK 584 bool getDoubleCheck()
587 return m_doublecheck && m_checknum + 1 >= CHECK_START;
590 void setDoubleCheck(
bool dc)
595 const char* spxStatusString(
const SPxSolver::Status stat)
599 case SPxSolver::ABORT_TIME:
601 case SPxSolver::ABORT_ITER:
603 case SPxSolver::ABORT_VALUE:
604 return "ABORT_VALUE";
605 case SPxSolver::SINGULAR:
607 case SPxSolver::REGULAR:
611 case SPxSolver::OPTIMAL:
613 case SPxSolver::UNBOUNDED:
615 case SPxSolver::INFEASIBLE:
624 const char* cpxStatusString(
const int stat)
628 case CPX_STAT_ABORT_TIME_LIM:
630 case CPX_STAT_ABORT_IT_LIM:
632 case CPX_STAT_ABORT_OBJ_LIM:
633 return "ABORT_VALUE";
634 case CPX_STAT_OPTIMAL:
636 case CPX_STAT_OPTIMAL_INFEAS:
637 return "CPX_STAT_OPTIMAL_INFEAS: OPT SOL INFEASIBLE AFTER UNSCALING";
638 case CPX_STAT_UNBOUNDED:
640 case CPX_STAT_INFEASIBLE:
642 case CPX_STAT_INForUNBD:
643 return "INFEASIBLE or UNBOUNDED";
644 case CPX_STAT_NUM_BEST:
645 return "CPX_STAT_NUM_BEST: SOL AVAILABLE BUT NOT PROVEN OPTIMAL DUE TO NUM TROUBLE";
655 bool checkConsistentBounds()
const 657 for(
int i = 0; i < nCols(); ++i )
659 if( lower(i) > upper(i) + Param::epsilon() )
661 SCIPerrorMessage(
"inconsistent bounds on column %d: lower=%.17g, upper=%.17g\n",
662 i, lower(i), upper(i));
670 bool checkConsistentSides()
const 672 for(
int i = 0; i < nRows(); ++i )
674 if( lhs(i) > rhs(i) + Param::epsilon() )
686 void trySolve(
bool printwarning =
true)
692 m_stat = SPxSolver::solve();
694 catch(
const SPxException&
x )
696 std::string s = x.what();
701 m_stat = SPxSolver::status();
707 assert( m_stat != SPxSolver::OPTIMAL );
711 m_itused += SPxSolver::iterations();
712 assert(m_itlim < 0 || m_itused <= m_itlim);
715 timespent = SPxSolver::time();
719 timelimit = SPxSolver::terminationTime();
720 if( timelimit > timespent )
721 timelimit -= timespent;
725 assert(timelimit >= 0);
726 SPxSolver::setTerminationTime(timelimit);
730 void doSolve(
bool printwarning =
true)
733 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 734 SPxOut::Verbosity verbosity;
735 verbosity = m_spxout.getVerbosity();
736 m_spxout.setVerbosity(getLpInfo() ? (SPxOut::Verbosity)
SOPLEX_VERBLEVEL : (SPxOut::Verbosity) 0);
739 verbosity = Param::verbose();
743 assert(checkConsistentBounds());
744 assert(checkConsistentSides());
746 #ifdef SCIP_WITH_LPSCHECK 748 if( getDoubleCheck() )
753 setTerminationIter(m_autopricing && (m_itlim < 0 || m_itlim - m_itused >
AUTOPRICING_ITERSWITCH) ? AUTOPRICING_ITERSWITCH : m_itlim - m_itused);
755 trySolve(printwarning);
757 if( m_autopricing && m_stat == SPxSolver::ABORT_ITER && (m_itlim < 0 || m_itlim - m_itused > 0) )
759 setTerminationIter(m_itlim - m_itused);
760 setPricer(&m_price_steep_ex);
762 trySolve(printwarning);
764 setPricer(&m_price_devex);
768 setTerminationIter(m_itlim);
770 if( m_stat == OPTIMAL )
772 Real objval = value();
774 if( (objval > m_objUpLimit) || (objval < m_objLoLimit) )
775 m_stat = ABORT_VALUE;
778 #ifdef SCIP_WITH_LPSCHECK 780 if( getDoubleCheck() && (m_stat == SPxSolver::OPTIMAL || m_stat == SPxSolver::UNBOUNDED || m_stat == SPxSolver::INFEASIBLE || m_stat == SPxSolver::ABORT_VALUE) )
786 CPX_CALL( CPXreadcopyprob(m_cpxenv, m_cpxlp,
"spxcheck.mps",
NULL) );
787 CPX_CALL( CPXreadcopybase(m_cpxenv, m_cpxlp,
"spxcheck.bas") );
790 CPX_CALL( CPXsetdblparam(m_cpxenv, CPX_PARAM_EPOPT,
MAX(opttol(), 1e-9)) );
791 CPX_CALL( CPXsetdblparam(m_cpxenv, CPX_PARAM_EPRHS,
MAX(feastol(), 1e-9)) );
794 CPX_CALL( CPXlpopt(m_cpxenv, m_cpxlp) );
797 CPX_CALL( CPXsolution(m_cpxenv, m_cpxlp, &cpxstat, &cpxobj,
NULL,
NULL,
NULL,
NULL) );
798 if( getSense() == SPxLP::MAXIMIZE )
802 if( cpxstat == CPX_STAT_OPTIMAL_INFEAS )
804 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s)\n",
805 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat));
806 if( EXIT_AT_CPXERROR )
809 else if( (m_stat == SPxSolver::OPTIMAL && cpxstat != CPX_STAT_OPTIMAL)
810 || (m_stat == SPxSolver::UNBOUNDED && cpxstat != CPX_STAT_UNBOUNDED)
811 || (m_stat == SPxSolver::INFEASIBLE && cpxstat != CPX_STAT_INFEASIBLE) )
813 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
814 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat), m_checknum);
815 if( EXIT_AT_WRONG_RESULT )
818 else if( m_stat == SPxSolver::ABORT_VALUE )
822 case CPX_STAT_OPTIMAL:
823 if( (getSense() == SPxSolver::MINIMIZE && LTrel(cpxobj, getObjUpLimit(), 2*opttol()))
824 || (getSense() == SPxSolver::MAXIMIZE && GTrel(cpxobj, getObjLoLimit(), 2*opttol())) )
826 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
827 m_probname, m_stat, spxStatusString(m_stat), cpxobj, getSense() == SPxSolver::MINIMIZE ?
"<" :
">",
828 getSense() == SPxSolver::MINIMIZE ? getObjUpLimit() : getObjLoLimit(), cpxStatusString(cpxstat), m_checknum);
829 if( EXIT_AT_WRONG_RESULT )
832 else if( (getSense() == SPxSolver::MINIMIZE && cpxobj < getObjUpLimit())
833 || (getSense() == SPxSolver::MAXIMIZE && cpxobj > getObjLoLimit()) )
835 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
836 m_probname, m_stat, spxStatusString(m_stat), cpxobj, getSense() == SPxSolver::MINIMIZE ?
"<" :
">",
837 getSense() == SPxSolver::MINIMIZE ? getObjUpLimit() : getObjLoLimit(), cpxStatusString(cpxstat), m_checknum);
840 case CPX_STAT_OPTIMAL_INFEAS:
841 case CPX_STAT_NUM_BEST:
842 if( (getSense() == SPxSolver::MINIMIZE && cpxobj < getObjUpLimit())
843 || (getSense() == SPxSolver::MAXIMIZE && cpxobj > getObjLoLimit()) )
845 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
846 m_probname, m_stat, spxStatusString(m_stat), cpxobj, getSense() == SPxSolver::MINIMIZE ?
"<" :
">",
847 getSense() == SPxSolver::MINIMIZE ? getObjUpLimit() : getObjLoLimit(), cpxStatusString(cpxstat), m_checknum);
850 case CPX_STAT_INFEASIBLE:
852 case CPX_STAT_UNBOUNDED:
853 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
854 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat), m_checknum);
855 if( EXIT_AT_WRONG_RESULT )
858 case CPX_STAT_INForUNBD:
860 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
861 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat), m_checknum);
866 else if( m_stat == SPxSolver::OPTIMAL )
868 if( (getSense() == SPxSolver::MINIMIZE && LTrel(value(), cpxobj, 2*opttol()))
869 || (getSense() == SPxSolver::MAXIMIZE && GTrel(value(), cpxobj, 2*opttol())) )
874 else if( (getSense() == SPxSolver::MINIMIZE && GTrel(value(), cpxobj, 2*opttol()))
875 || (getSense() == SPxSolver::MAXIMIZE && LTrel(value(), cpxobj, 2*opttol())) )
877 SCIPerrorMessage(
"In %s: LP optimal; SoPlex value=%.10f %s CPLEX value=%.10f suboptimal (checknum=%d)\n", value(),
878 m_probname, getSense() == SPxSolver::MINIMIZE ?
">" :
"<", cpxobj, m_checknum);
879 if( EXIT_AT_WRONG_RESULT )
889 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 890 m_spxout.setVerbosity(verbosity);
892 Param::setVerbose(verbosity);
897 virtual Status solve()
899 assert(m_sense == sense());
900 SPxEquiliSC* scaler =
NULL;
901 SPxMainSM* simplifier =
NULL;
903 SPxSimplifier::Result result = SPxSimplifier::OKAY;
906 if ( getFromScratch() )
912 catch(
const SPxException&
x )
914 std::string s = x.what();
916 m_stat = SPxSolver::status();
917 assert( m_stat != SPxSolver::OPTIMAL );
921 assert(!getFromScratch() || getBasisStatus() == SPxBasis::NO_PROBLEM);
924 if( SPxSolver::getBasisStatus() == SPxBasis::NO_PROBLEM && (getScaling() > 0) && nCols() > 0 && nRows() > 0 )
926 spx_alloc(scaler, 1);
927 scaler =
new (scaler) SPxEquiliSC();
928 assert(scaler !=
NULL);
929 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 930 scaler->setOutstream(m_spxout);
934 if( SPxSolver::getBasisStatus() == SPxBasis::NO_PROBLEM && getPresolving() && nCols() > 0 && nRows() > 0 )
936 spx_alloc(simplifier, 1);
937 simplifier =
new (simplifier) SPxMainSM();
938 assert(simplifier !=
NULL);
942 if( scaler !=
NULL || simplifier !=
NULL )
943 origlp = SPxLP(*
this);
952 scaler->scale(*
this);
955 if( simplifier !=
NULL )
958 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 959 SPxOut::Verbosity verbosity;
960 verbosity = m_spxout.getVerbosity();
961 m_spxout.setVerbosity(getLpInfo() ? (SPxOut::Verbosity)
SOPLEX_VERBLEVEL : (SPxOut::Verbosity) 0);
964 verbosity = Param::verbose();
968 #ifdef WITH_BOUNDFLIPPING 969 result = simplifier->simplify(*
this, epsilon(), feastol(), opttol(),
true);
971 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 972 result = simplifier->simplify(*
this, epsilon(), feastol(), opttol());
974 result = simplifier->simplify(*
this, epsilon(), delta());
977 SCIPdebugMessage(
"simplifier ended with status %u (0: OKAY, 1: INFEASIBLE, 2: DUAL_INFEASIBLE, 3: UNBOUNDED, 4: VANISHED)\n", result);
980 if( result == SPxSimplifier::INFEASIBLE || result == SPxSimplifier::DUAL_INFEASIBLE )
982 SCIPdebugMessage(
"simplifier detected primal or dual infeasibility - reloading and solving unsimplified LP\n");
984 simplifier->~SPxMainSM();
985 spx_free(simplifier);
987 SPxSolver::loadLP(origlp);
993 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 994 m_spxout.setVerbosity(verbosity);
996 Param::setVerbose(verbosity);
1001 if( result != SPxSimplifier::VANISHED )
1004 Real objlolimit = getObjLoLimit();
1005 Real objuplimit = getObjUpLimit();
1007 if( simplifier !=
NULL || scaler !=
NULL )
1019 if( simplifier !=
NULL || scaler !=
NULL )
1021 setObjLoLimit(objlolimit);
1022 setObjUpLimit(objuplimit);
1027 if( m_stat != SPxSolver::OPTIMAL && simplifier !=
NULL )
1029 SCIPdebugMessage(
"presolved LP not optimal - reloading and solving original LP\n");
1031 simplifier->~SPxMainSM();
1032 spx_free(simplifier);
1034 SPxSolver::loadLP(origlp);
1041 if( scaler !=
NULL || simplifier !=
NULL )
1043 SPxSolver::VarStatus* cstat =
NULL;
1044 SPxSolver::VarStatus* rstat =
NULL;
1047 if( (simplifier ==
NULL || result != SPxSimplifier::VANISHED) && SPxSolver::getBasisStatus() >= SPxBasis::REGULAR )
1050 spx_alloc(rstat, nRows());
1051 spx_alloc(cstat, nCols());
1052 (void) SPxSolver::getBasis(rstat, cstat);
1056 if( simplifier !=
NULL && SPxSolver::getBasisStatus() >= SPxBasis::REGULAR )
1058 assert((result == SPxSimplifier::VANISHED) == (cstat ==
NULL));
1059 assert((result == SPxSimplifier::VANISHED) == (rstat ==
NULL));
1062 int ncols = result == SPxSimplifier::VANISHED ? 0 : nCols();
1063 int nrows = result == SPxSimplifier::VANISHED ? 0 : nRows();
1066 DVector primals(ncols);
1067 DVector duals(nrows);
1068 DVector slacks(nrows);
1069 DVector redcosts(ncols);
1070 if( result != SPxSimplifier::VANISHED )
1072 (void) SPxSolver::getPrimal(primals);
1073 (void) SPxSolver::getDual(duals);
1074 (void) SPxSolver::getSlacks(slacks);
1075 (void) SPxSolver::getRedCost(redcosts);
1082 simplifier->unsimplify(primals, duals, slacks, redcosts, rstat, cstat);
1084 catch(
const SPxException&
x )
1086 std::string s = x.what();
1087 SCIPmessagePrintWarning(m_messagehdlr,
"SoPlex unsimplification unsuccessful; solving again without LP presolving (SoPlex says %s)\n",
1096 if( simplifier->isUnsimplified() )
1101 spx_alloc(rstat, origlp.nRows());
1102 spx_alloc(cstat, origlp.nCols());
1103 simplifier->getBasis(rstat, cstat);
1109 SPxSolver::loadLP(origlp);
1113 if( rstat !=
NULL && cstat !=
NULL )
1116 SPxSolver::setBasis(rstat, cstat);
1131 if( scaler !=
NULL )
1133 scaler->~SPxEquiliSC();
1136 if( simplifier !=
NULL )
1138 simplifier->~SPxMainSM();
1139 spx_free(simplifier);
1143 if( m_stat == OPTIMAL )
1145 Real objval = value();
1147 if( (objval > m_objUpLimit) || (objval < m_objLoLimit) )
1148 m_stat = ABORT_VALUE;
1155 void savePreStrongbranchingBasis()
1157 m_rowstat.reSize(nRows());
1158 m_colstat.reSize(nCols());
1162 m_stat = getBasis(m_rowstat.get_ptr(), m_colstat.get_ptr());
1165 catch(
const SPxException&
x )
1167 std::string s = x.what();
1174 assert(m_stat != SPxSolver::OPTIMAL);
1177 catch(
const SPxException& )
1184 void restorePreStrongbranchingBasis()
1186 assert(m_rowstat.size() == nRows());
1187 assert(m_colstat.size() == nCols());
1191 setBasis(m_rowstat.get_const_ptr(), m_colstat.get_const_ptr());
1194 catch(
const SPxException&
x )
1196 std::string s = x.what();
1199 catch(
const SPxException& )
1202 m_stat = SPxSolver::status();
1208 assert(m_stat != SPxSolver::OPTIMAL);
1213 void freePreStrongbranchingBasis()
1220 bool preStrongbranchingBasisFreed()
const 1222 return ((m_rowstat.size() == 0 ) && (m_colstat.size() == 0));
1226 DataArray<SPxSolver::VarStatus>& rowStat()
1232 DataArray<SPxSolver::VarStatus>& colStat()
1237 Status getStatus()
const 1242 Status updateStatus()
1244 m_stat = SPxSolver::status();
1248 bool isInitialized()
const 1250 return SPxSolver::isInitialized();
1253 int iterations()
const 1258 virtual void clear()
1261 freePreStrongbranchingBasis();
1262 m_stat = NO_PROBLEM;
1266 bool readLP(
const char* fname)
1270 if ( m_rownames != 0 )
1271 m_rownames->~NameSet();
1273 spx_alloc(m_colnames, 1);
1275 if ( m_colnames != 0 )
1276 m_colnames->~NameSet();
1278 spx_alloc(m_rownames, 1);
1280 m_rownames =
new (m_rownames) NameSet();
1281 m_colnames =
new (m_colnames) NameSet();
1285 m_stat = NO_PROBLEM;
1299 int namestoragesize,
1303 assert( m_colnames !=
NULL );
1306 if ( namestoragesize == 0 )
1309 *storageleft = -m_colnames->memSize();
1313 NameSet* names = m_colnames;
1314 assert( names != 0 );
1315 int sizeleft = namestoragesize;
1316 char* s = namestorage;
1317 for (
int j = firstcol; j <= lastcol; ++j)
1319 const char* t = (*names)[j];
1320 colnames[j-firstcol] = s;
1321 while( *t !=
'\0' && sizeleft >= 0 )
1328 if ( sizeleft == 0 )
1330 *storageleft = namestoragesize - m_colnames->memSize();
1331 assert( *storageleft <= 0 );
1334 *storageleft = sizeleft;
1344 int namestoragesize,
1348 assert( m_rownames !=
NULL );
1351 if ( namestoragesize == 0 )
1354 *storageleft = -m_rownames->memSize();
1358 NameSet* names = m_rownames;
1359 assert( names != 0 );
1360 int sizeleft = namestoragesize;
1361 char* s = namestorage;
1362 for (
int i = firstrow; i <= lastrow; ++i)
1364 const char* t = (*names)[i];
1365 rownames[i-firstrow] = s;
1366 while( *t !=
'\0' && sizeleft >= 0 )
1373 if ( sizeleft == 0 )
1375 *storageleft = m_rownames->memSize() - namestoragesize;
1376 assert( *storageleft <= 0 );
1379 *storageleft = sizeleft;
1395 #define COLS_PER_PACKET SCIP_DUALPACKETSIZE 1397 #define ROWS_PER_PACKET SCIP_DUALPACKETSIZE 1411 SLUFactor* factorization;
1423 COLPACKET* packcstat;
1424 ROWPACKET* packrstat;
1447 assert(lpi !=
NULL);
1457 assert(num <= lpi->cstatsize);
1469 assert(lpi !=
NULL);
1479 assert(num <= lpi->rstatsize);
1517 assert(lpistate !=
NULL);
1533 assert(lpistate !=
NULL);
1550 assert(lpistate !=
NULL);
1551 assert(blkmem !=
NULL);
1572 assert(blkmem !=
NULL);
1573 assert(lpistate !=
NULL);
1574 assert(*lpistate !=
NULL);
1600 return SPxLP::MAXIMIZE;
1602 return SPxLP::MINIMIZE;
1606 return SPxLP::MINIMIZE;
1614 assert(lpi !=
NULL);
1636 #if (SOPLEX_SUBVERSION > 0) 1637 const static char spxname[20]= {
'S',
'o',
'p',
'l',
'e',
'x',
'1',
' ', SOPLEX_VERSION/100 +
'0',
'.', (SOPLEX_VERSION % 100)/10 +
'0',
'.', SOPLEX_VERSION % 10 +
'0',
'.',
SOPLEX_SUBVERSION +
'0'};
1639 const static char spxname[20] = {
'S',
'o',
'p',
'l',
'e',
'x',
'1',
' ', SOPLEX_VERSION/100 +
'0',
'.', (SOPLEX_VERSION % 100)/10 +
'0',
'.', SOPLEX_VERSION % 10 +
'0'};
1646 spxdesc =
new char[200];
1647 (void)snprintf(spxdesc, 200,
"%s [GitHash: %s]",
"Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de)" 1648 #ifdef SCIP_WITH_LPSCHECK
1649 " - including CPLEX double check" 1680 return (
void*) lpi->
spx;
1690 #if (SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 221 && SOPLEX_SUBVERSION >= 3)) 1691 assert(ncols == lpi->
spx->nCols() || (ncols == 0 && intInfo ==
NULL));
1692 lpi->
spx->setIntegralityInformation(ncols, intInfo);
1695 SCIPerrorMessage(
"SCIPlpiSetIntegralityInformation() has not been implemented yet.\n");
1744 assert(lpi !=
NULL);
1745 assert(name !=
NULL);
1752 SOPLEX_TRY( messagehdlr, (*lpi)->spx = new ((*lpi)->spx) SPxSCIP(messagehdlr, name) );
1753 (*lpi)->cstat =
NULL;
1754 (*lpi)->rstat =
NULL;
1755 (*lpi)->cstatsize = 0;
1756 (*lpi)->rstatsize = 0;
1758 (*lpi)->factorization = 0;
1760 (*lpi)->conditionlimit = -1.0;
1761 (*lpi)->checkcondition =
FALSE;
1762 (*lpi)->messagehdlr = messagehdlr;
1780 assert(lpi !=
NULL);
1781 assert(*lpi !=
NULL);
1782 assert((*lpi)->spx !=
NULL);
1785 (*lpi)->spx->~SPxSCIP();
1830 for( j = 0; j < nnonz; j++ )
1831 assert( val[j] != 0 );
1837 assert(lpi !=
NULL);
1839 assert(lhs !=
NULL);
1840 assert(rhs !=
NULL);
1841 assert(obj !=
NULL);
1844 assert(beg !=
NULL);
1845 assert(ind !=
NULL);
1846 assert(val !=
NULL);
1849 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1853 SPxSCIP* spx = lpi->
spx;
1854 LPRowSet rows(nrows);
1855 DSVector emptyVector(0);
1864 for( i = 0; i < nrows; ++i )
1865 rows.add(lhs[i], emptyVector, rhs[i]);
1872 catch(
const SPxException&
x )
1874 std::string s = x.what();
1877 catch(
const SPxException& )
1902 assert(lpi !=
NULL);
1904 assert(obj !=
NULL);
1907 assert(nnonz == 0 || beg !=
NULL);
1908 assert(nnonz == 0 || ind !=
NULL);
1909 assert(nnonz == 0 || val !=
NULL);
1915 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1921 int nrows = lpi->
spx->nRows();
1922 for (
int j = 0; j < nnonz; ++j)
1924 assert( 0 <= ind[j] && ind[j] < nrows );
1925 assert( val[j] != 0.0 );
1930 SPxSCIP* spx = lpi->
spx;
1933 LPColSet cols(ncols);
1934 DSVector colVector(ncols);
1940 for( i = 0; i < ncols; ++i )
1946 last = (i == ncols-1 ? nnonz : beg[i+1]);
1947 colVector.add( last-start, &ind[start], &val[start] );
1949 cols.add(obj[i], lb[i], colVector, ub[i]);
1954 catch(
const SPxException& x )
1956 std::string s = x.what();
1959 catch(
const SPxException& )
1977 assert(lpi !=
NULL);
1979 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
1983 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2003 assert(lpi !=
NULL);
2005 assert(dstat !=
NULL);
2009 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2011 ncols = lpi->
spx->nCols();
2014 for( i = 0; i < ncols; ++i )
2037 assert(lpi !=
NULL);
2039 assert(lhs !=
NULL);
2040 assert(rhs !=
NULL);
2041 assert(nnonz == 0 || beg !=
NULL);
2042 assert(nnonz == 0 || ind !=
NULL);
2043 assert(nnonz == 0 || val !=
NULL);
2047 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2053 int ncols = lpi->
spx->nCols();
2054 for (
int j = 0; j < nnonz; ++j)
2056 assert( 0 <= ind[j] && ind[j] < ncols );
2057 assert( val[j] != 0.0 );
2064 SPxSCIP* spx = lpi->
spx;
2065 LPRowSet rows(nrows);
2072 for( i = 0; i < nrows; ++i )
2078 last = (i == nrows-1 ? nnonz : beg[i+1]);
2079 rowVector.add( last-start, &ind[start], &val[start] );
2081 rows.add(lhs[i], rowVector, rhs[i]);
2086 catch(
const SPxException&
x )
2088 std::string s =
x.what();
2091 catch(
const SPxException& )
2109 assert(lpi !=
NULL);
2111 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
2115 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2135 assert(lpi !=
NULL);
2140 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2142 nrows = lpi->
spx->nRows();
2145 for( i = 0; i < nrows; ++i )
2160 assert(lpi !=
NULL);
2165 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2184 assert(lpi !=
NULL);
2186 assert(ncols == 0 || (ind !=
NULL && lb !=
NULL && ub !=
NULL));
2192 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2196 for( i = 0; i < ncols; ++i )
2198 assert(0 <= ind[i] && ind[i] < lpi->
spx->nCols());
2202 SCIPerrorMessage(
"LP Error: fixing lower bound for variable %d to infinity.\n", ind[i]);
2207 SCIPerrorMessage(
"LP Error: fixing upper bound for variable %d to -infinity.\n", ind[i]);
2211 lpi->
spx->changeBounds(ind[i], lb[i], ub[i]);
2212 assert(lpi->
spx->lower(ind[i]) <= lpi->
spx->upper(ind[i]) + Param::epsilon());
2216 catch(
const SPxException&
x )
2218 std::string s =
x.what();
2221 catch(
const SPxException& )
2243 assert(lpi !=
NULL);
2245 assert(ind !=
NULL);
2246 assert(lhs !=
NULL);
2247 assert(rhs !=
NULL);
2253 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2257 for( i = 0; i < nrows; ++i )
2259 assert(0 <= ind[i] && ind[i] < lpi->
spx->nRows());
2260 lpi->
spx->changeRange(ind[i], lhs[i], rhs[i]);
2261 assert(lpi->
spx->lhs(ind[i]) <= lpi->
spx->rhs(ind[i]) + Param::epsilon());
2265 catch(
const SPxException&
x )
2267 std::string s =
x.what();
2270 catch(
const SPxException& )
2289 assert(lpi !=
NULL);
2291 assert(0 <= row && row < lpi->spx->nRows());
2292 assert(0 <= col && col < lpi->spx->nCols());
2296 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2311 assert(lpi !=
NULL);
2316 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2335 assert(lpi !=
NULL);
2337 assert(ind !=
NULL);
2338 assert(obj !=
NULL);
2342 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2346 for( i = 0; i < ncols; ++i )
2348 assert(0 <= ind[i] && ind[i] < lpi->
spx->nCols());
2349 lpi->
spx->changeObj(ind[i], obj[i]);
2353 catch(
const SPxException&
x )
2355 std::string s =
x.what();
2358 catch(
const SPxException& )
2379 assert(lpi !=
NULL);
2381 assert(scaleval != 0.0);
2387 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2390 SVector rowvec = lpi->
spx->rowVector(row);
2391 lhs = lpi->
spx->lhs(row);
2392 rhs = lpi->
spx->rhs(row);
2400 else if( scaleval < 0.0 )
2404 else if( scaleval < 0.0 )
2406 if( scaleval < 0.0 )
2414 LPRow lprow(lhs, rowvec, rhs);
2417 lpi->
spx->changeRow(row, lprow);
2418 assert(lpi->
spx->lhs(row) <= lpi->
spx->rhs(row));
2421 catch(
const SPxException&
x )
2423 std::string s =
x.what();
2426 catch(
const SPxException& )
2450 assert(lpi !=
NULL);
2452 assert(scaleval != 0.0);
2458 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2461 SVector colvec = lpi->
spx->colVector(col);
2462 obj = lpi->
spx->obj(col);
2463 lb = lpi->
spx->lower(col);
2464 ub = lpi->
spx->upper(col);
2475 else if( scaleval < 0.0 )
2479 else if( scaleval < 0.0 )
2481 if( scaleval < 0.0 )
2489 LPCol lpcol(obj, colvec, ub, lb);
2492 lpi->
spx->changeCol(col, lpcol);
2493 assert(lpi->
spx->lower(col) <= lpi->
spx->upper(col));
2496 catch(
const SPxException&
x )
2498 std::string s =
x.what();
2501 catch(
const SPxException& )
2530 assert(lpi !=
NULL);
2532 assert(nrows !=
NULL);
2534 *nrows = lpi->
spx->nRows();
2547 assert(lpi !=
NULL);
2549 assert(ncols !=
NULL);
2551 *ncols = lpi->
spx->nCols();
2566 assert(lpi !=
NULL);
2568 assert(nnonz !=
NULL);
2572 if( lpi->
spx->nRows() < lpi->
spx->nCols() )
2574 for( i = 0; i < lpi->
spx->nRows(); ++i )
2575 (*nnonz) += lpi->
spx->rowVector(i).size();
2579 for( i = 0; i < lpi->
spx->nCols(); ++i )
2580 (*nnonz) += lpi->
spx->colVector(i).size();
2607 assert(lpi !=
NULL);
2609 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2615 const Vector& lbvec = lpi->
spx->lower();
2616 const Vector& ubvec = lpi->
spx->upper();
2617 for( i = firstcol; i <= lastcol; ++i )
2619 lb[i-firstcol] = lbvec[i];
2620 ub[i-firstcol] = ubvec[i];
2627 for( i = firstcol; i <= lastcol; ++i )
2629 beg[i-firstcol] = *nnonz;
2630 const SVector& cvec = lpi->
spx->colVector(i);
2631 for( j = 0; j < cvec.size(); ++j )
2633 ind[*nnonz] = cvec.index(j);
2634 val[*nnonz] = cvec.value(j);
2664 assert(lpi !=
NULL);
2666 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
2672 const Vector& lhsvec = lpi->
spx->lhs();
2673 const Vector& rhsvec = lpi->
spx->rhs();
2674 for( i = firstrow; i <= lastrow; ++i )
2676 lhs[i-firstrow] = lhsvec[i];
2677 rhs[i-firstrow] = rhsvec[i];
2684 for( i = firstrow; i <= lastrow; ++i )
2686 beg[i-firstrow] = *nnonz;
2687 const SVector& rvec = lpi->
spx->rowVector(i);
2688 for( j = 0; j < rvec.size(); ++j )
2690 ind[*nnonz] = rvec.index(j);
2691 val[*nnonz] = rvec.value(j);
2707 int namestoragesize,
2711 assert( lpi !=
NULL );
2713 assert( colnames !=
NULL || namestoragesize == 0 );
2714 assert( namestorage !=
NULL || namestoragesize == 0 );
2715 assert( namestoragesize >= 0 );
2716 assert( storageleft !=
NULL );
2717 assert( 0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols() );
2721 lpi->
spx->getColNames(firstcol, lastcol, colnames, namestorage, namestoragesize, storageleft);
2733 int namestoragesize,
2737 assert( lpi !=
NULL );
2739 assert( rownames !=
NULL || namestoragesize == 0 );
2740 assert( namestorage !=
NULL || namestoragesize == 0 );
2741 assert( namestoragesize >= 0 );
2742 assert( storageleft !=
NULL );
2743 assert( 0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows() );
2747 lpi->
spx->getRowNames(firstrow, lastrow, rownames, namestorage, namestoragesize, storageleft);
2760 assert(lpi !=
NULL);
2762 assert(objsen !=
NULL);
2781 assert(lpi !=
NULL);
2783 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2784 assert(vals !=
NULL);
2786 for( i = firstcol; i <= lastcol; ++i )
2787 vals[i-firstcol] = lpi->
spx->obj(i);
2805 assert(lpi !=
NULL);
2807 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2809 for( i = firstcol; i <= lastcol; ++i )
2812 lbs[i-firstcol] = lpi->
spx->lower(i);
2814 ubs[i-firstcol] = lpi->
spx->upper(i);
2833 assert(lpi !=
NULL);
2835 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
2837 for( i = firstrow; i <= lastrow; ++i )
2840 lhss[i-firstrow] = lpi->
spx->lhs(i);
2842 rhss[i-firstrow] = lpi->
spx->rhs(i);
2858 assert(lpi !=
NULL);
2860 assert(0 <= col && col < lpi->spx->nCols());
2861 assert(0 <= row && row < lpi->spx->nRows());
2862 assert(val !=
NULL);
2864 *val = lpi->
spx->colVector(col)[row];
2885 SPxSolver::Representation rep,
2889 assert( lpi !=
NULL );
2891 assert( rep == SPxSolver::ROW || rep == SPxSolver::COLUMN );
2892 assert( type == SPxSolver::ENTER || type == SPxSolver::LEAVE );
2894 SCIPdebugMessage(
"calling SoPlex solve(): %d cols, %d rows, rep=%s\n", lpi->
spx->nCols(), lpi->
spx->nRows(),
2895 rep == SPxSolver::COLUMN ?
"column" :
"row");
2899 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2902 lpi->
spx->setRep(rep);
2903 lpi->
spx->setType(type);
2905 #ifdef SCIP_WITH_LPSCHECK 2906 lpi->
spx->setDoubleCheck(CHECK_SPXSOLVE);
2909 SPxSolver::Status status = lpi->
spx->solve();
2910 SCIPdebugMessage(
" -> SoPlex status: %d, basis status: %d\n", lpi->
spx->getStatus(), lpi->
spx->basis().status());
2915 case SPxSolver::ABORT_TIME:
2916 case SPxSolver::ABORT_ITER:
2917 case SPxSolver::ABORT_VALUE:
2918 case SPxSolver::SINGULAR:
2919 case SPxSolver::REGULAR:
2921 case SPxSolver::OPTIMAL:
2922 case SPxSolver::UNBOUNDED:
2923 case SPxSolver::INFEASIBLE:
2940 assert(lpi !=
NULL);
2947 rowrep = lpi->
spx->rep() == SPxSolver::ROW;
2967 retcode = rowrep ?
spxSolve(lpi, SPxSolver::ROW, SPxSolver::LEAVE) :
spxSolve(lpi, SPxSolver::COLUMN, SPxSolver::ENTER);
2968 assert(!rowrep || lpi->
spx->rep() == SPxSolver::ROW);
2969 assert(rowrep || lpi->
spx->rep() == SPxSolver::COLUMN);
2984 assert(lpi !=
NULL);
2991 rowrep = lpi->
spx->rep() == SPxSolver::ROW;
3011 retcode = rowrep ?
spxSolve(lpi, SPxSolver::ROW, SPxSolver::ENTER) :
spxSolve(lpi, SPxSolver::COLUMN, SPxSolver::LEAVE);
3012 assert(!rowrep || lpi->
spx->rep() == SPxSolver::ROW);
3013 assert(rowrep || lpi->
spx->rep() == SPxSolver::COLUMN);
3024 assert(lpi !=
NULL);
3039 assert(lpi !=
NULL);
3042 assert( lpi->
spx->preStrongbranchingBasisFreed() );
3043 lpi->
spx->savePreStrongbranchingBasis();
3053 assert(lpi !=
NULL);
3056 assert( ! lpi->
spx->preStrongbranchingBasisFreed() );
3057 lpi->
spx->restorePreStrongbranchingBasis();
3058 lpi->
spx->freePreStrongbranchingBasis();
3080 SPxSolver::Status status;
3085 bool fromparentbasis;
3089 SCIPdebugMessage(
"calling SCIPlpiStrongbranch() on variable %d (%d iterations)\n", col, itlim);
3091 assert(lpi !=
NULL);
3095 assert(downvalid !=
NULL);
3096 assert(upvalid !=
NULL);
3100 fromparentbasis =
false;
3102 oldItlim = spx->getIterationLimit();
3105 oldlb = spx->lower(col);
3106 oldub = spx->upper(col);
3115 lpi->
spx->setType( lpi->
spx->rep() == SPxSolver::ROW ? SPxSolver::ENTER : SPxSolver::LEAVE);
3118 newub =
EPSCEIL(psol-1.0, lpi->
spx->feastol());
3119 if( newub >= oldlb - 0.5 && down !=
NULL )
3121 SCIPdebugMessage(
"strong branching down on x%d (%g) with %d iterations\n", col, psol, itlim);
3123 spx->changeUpper(col, newub);
3124 assert(spx->lower(col) <= spx->upper(col));
3126 spx->setIterationLimit(itlim);
3129 #ifdef SCIP_WITH_LPSCHECK 3130 spx->setDoubleCheck(CHECK_SPXSTRONGBRANCH);
3132 status = spx->solve();
3136 case SPxSolver::OPTIMAL:
3137 *down = spx->value();
3141 case SPxSolver::ABORT_TIME:
3142 case SPxSolver::ABORT_ITER:
3143 case SPxSolver::ABORT_CYCLING:
3144 *down = spx->value();
3146 case SPxSolver::ABORT_VALUE:
3147 case SPxSolver::INFEASIBLE:
3148 *down = spx->terminationValue();
3156 (*iter) += spx->iterations();
3158 #ifdef STRONGBRANCH_RESTOREBASIS 3160 assert( ! spx->preStrongbranchingBasisFreed() );
3161 spx->restorePreStrongbranchingBasis();
3162 fromparentbasis =
false;
3166 if( (status == SPxSolver::ABORT_CYCLING || status == SPxSolver::SINGULAR) && !fromparentbasis && spx->iterations() < itlim )
3168 SCIPdebugMessage(
" --> Repeat strong branching down with %d iterations after restoring basis\n", itlim - spx->iterations());
3169 spx->setIterationLimit(itlim - spx->iterations());
3170 spx->restorePreStrongbranchingBasis();
3171 fromparentbasis =
true;
3176 fromparentbasis =
false;
3179 while( fromparentbasis );
3181 spx->changeUpper(col, oldub);
3182 assert(spx->lower(col) <= spx->upper(col));
3184 else if( down !=
NULL )
3186 *down = spx->terminationValue();
3196 if( newlb <= oldub + 0.5 && up !=
NULL )
3198 SCIPdebugMessage(
"strong branching up on x%d (%g) with %d iterations\n", col, psol, itlim);
3200 spx->changeLower(col, newlb);
3201 assert(spx->lower(col) <= spx->upper(col));
3203 spx->setIterationLimit(itlim);
3206 #ifdef SCIP_WITH_LPSCHECK 3207 spx->setDoubleCheck(CHECK_SPXSTRONGBRANCH);
3209 status = spx->solve();
3213 case SPxSolver::OPTIMAL:
3218 case SPxSolver::ABORT_TIME:
3219 case SPxSolver::ABORT_ITER:
3220 case SPxSolver::ABORT_CYCLING:
3223 case SPxSolver::ABORT_VALUE:
3224 case SPxSolver::INFEASIBLE:
3225 *up = spx->terminationValue();
3233 (*iter) += spx->iterations();
3235 #ifdef STRONGBRANCH_RESTOREBASIS 3237 assert( ! spx->preStrongbranchingBasisFreed() );
3238 spx->restorePreStrongbranchingBasis();
3239 fromparentbasis =
false;
3243 if( (status == SPxSolver::ABORT_CYCLING || status == SPxSolver::SINGULAR) && !fromparentbasis && spx->iterations() < itlim )
3245 SCIPdebugMessage(
" --> Repeat strong branching up with %d iterations after restoring basis\n", itlim - spx->iterations());
3246 spx->restorePreStrongbranchingBasis();
3247 spx->setIterationLimit(itlim - spx->iterations());
3249 fromparentbasis =
true;
3253 fromparentbasis =
false;
3256 while( fromparentbasis );
3258 spx->changeLower(col, oldlb);
3259 assert(spx->lower(col) <= spx->upper(col));
3261 else if( up !=
NULL )
3263 *up = spx->terminationValue();
3271 spx->setIterationLimit(oldItlim);
3275 SCIPdebugMessage(
"SCIPlpiStrongbranch() returned SoPlex status %d\n",
int(status));
3300 retcode =
lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter);
3330 assert( cols !=
NULL );
3331 assert( psols !=
NULL );
3332 assert( down !=
NULL );
3333 assert( up !=
NULL );
3334 assert( downvalid !=
NULL );
3335 assert( upvalid !=
NULL );
3336 assert( down !=
NULL );
3341 for (
int j = 0; j < ncols; ++j)
3344 retcode =
lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter);
3374 retcode =
lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter);
3404 assert( cols !=
NULL );
3405 assert( psols !=
NULL );
3406 assert( down !=
NULL );
3407 assert( up !=
NULL );
3408 assert( downvalid !=
NULL );
3409 assert( upvalid !=
NULL );
3410 assert( down !=
NULL );
3415 for (
int j = 0; j < ncols; ++j)
3418 retcode =
lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter);
3447 assert(lpi !=
NULL);
3470 assert(lpi !=
NULL);
3471 assert(primalfeasible !=
NULL);
3472 assert(dualfeasible !=
NULL);
3489 assert(lpi !=
NULL);
3492 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED);
3504 assert(lpi !=
NULL);
3507 #if ((SOPLEX_VERSION == 150 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 150) 3508 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED);
3521 assert(lpi !=
NULL);
3524 assert(lpi->
spx->getStatus() != SPxSolver::UNBOUNDED || lpi->
spx->basis().status() == SPxBasis::UNBOUNDED);
3529 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED && !lpi->
spx->isPerturbed());
3539 assert(lpi !=
NULL);
3542 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE);
3550 SPxBasis::SPxStatus basestatus;
3554 assert(lpi !=
NULL);
3557 basestatus = lpi->
spx->basis().status();
3562 assert(basestatus == SPxBasis::OPTIMAL || lpi->
spx->getStatus() != SPxSolver::OPTIMAL);
3564 return basestatus == SPxBasis::OPTIMAL ||
3565 ((basestatus == SPxBasis::PRIMAL || basestatus == SPxBasis::UNBOUNDED) && !lpi->
spx->isPerturbed());
3577 assert(lpi !=
NULL);
3580 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE);
3592 assert(lpi !=
NULL);
3595 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE);
3605 assert(lpi !=
NULL);
3608 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE && lpi->
spx->basis().status() == SPxBasis::DUAL
3609 && !lpi->
spx->isPerturbed());
3619 assert(lpi !=
NULL);
3622 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED);
3632 assert(lpi !=
NULL);
3638 assert(lpi->
spx->basis().status() == SPxBasis::OPTIMAL || lpi->
spx->getStatus() != SPxSolver::OPTIMAL);
3640 return (lpi->
spx->basis().status() == SPxBasis::OPTIMAL) ||
3641 (lpi->
spx->basis().status() == SPxBasis::DUAL && !lpi->
spx->isPerturbed());
3651 assert(lpi !=
NULL);
3653 assert((lpi->
spx->basis().status() == SPxBasis::OPTIMAL)
3659 return (lpi->
spx->basis().status() == SPxBasis::OPTIMAL);
3675 assert(lpi !=
NULL);
3678 #if ((SOPLEX_VERSION == 172 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 172) 3711 assert(lpi !=
NULL);
3714 return (lpi->
spx->getStatus() == SPxSolver::ABORT_VALUE);
3724 assert(lpi !=
NULL);
3727 return (lpi->
spx->getStatus() == SPxSolver::ABORT_ITER);
3737 assert(lpi !=
NULL);
3740 return (lpi->
spx->getStatus() == SPxSolver::ABORT_TIME);
3750 assert(lpi !=
NULL);
3753 return static_cast<int>(lpi->
spx->getStatus());
3764 assert(lpi !=
NULL);
3766 assert(success !=
NULL);
3782 assert(lpi !=
NULL);
3784 assert(objval !=
NULL);
3786 *objval = lpi->
spx->value();
3807 assert(lpi !=
NULL);
3810 if( objval !=
NULL )
3811 *objval = lpi->
spx->value();
3815 if( primsol !=
NULL )
3817 Vector tmp(lpi->
spx->nCols(), primsol);
3818 (void)lpi->
spx->getPrimal(tmp);
3820 if( dualsol !=
NULL )
3822 Vector tmp(lpi->
spx->nRows(), dualsol);
3823 (void)lpi->
spx->getDual(tmp);
3825 if( activity !=
NULL )
3827 Vector tmp(lpi->
spx->nRows(), activity);
3828 (void)lpi->
spx->getSlacks(tmp);
3830 if( redcost !=
NULL )
3832 Vector tmp(lpi->
spx->nCols(), redcost);
3833 (void)lpi->
spx->getRedCost(tmp);
3837 catch(
const SPxException&
x )
3839 std::string s =
x.what();
3842 catch(
const SPxException& )
3859 assert(lpi !=
NULL);
3861 assert(ray !=
NULL);
3863 #if ((SOPLEX_VERSION == 150 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 150) 3866 Vector tmp(lpi->
spx->nCols(), ray);
3867 (void)lpi->
spx->getPrimalray(tmp);
3870 catch(
const SPxException&
x )
3872 std::string s =
x.what();
3875 catch(
const SPxException& )
3883 SCIPerrorMessage(
"SCIPlpiGetPrimalRay() not supported by SoPlex versions <= 1.5.0\n");
3896 assert(lpi !=
NULL);
3898 assert(dualfarkas !=
NULL);
3902 Vector tmp(lpi->
spx->nRows(), dualfarkas);
3903 (void)lpi->
spx->getDualfarkas(tmp);
3906 catch(
const SPxException&
x )
3908 std::string s =
x.what();
3911 catch(
const SPxException& )
3928 assert(lpi !=
NULL);
3930 assert(iterations !=
NULL);
3932 *iterations = lpi->
spx->iterations();
3950 assert(lpi !=
NULL);
3951 assert(quality !=
NULL);
3953 #if ((SOPLEX_VERSION == 172 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 172) 3957 SCIPdebugMessage(
"requesting solution quality from SoPlex: quality %d\n", qualityindicator);
3959 switch( qualityindicator )
3976 *quality = lpi->
spx->basis().condition(maxiter, tolerance);
3999 assert( spx !=
NULL );
4006 if (! spx->isInitialized() )
4009 assert( 0 <= col && col < spx->nCols() );
4011 if( spx->rep() == SPxSolver::COLUMN )
4014 if (spx->getSense() == SPxLP::MINIMIZE)
4015 *val = spx->pVec()[col] - spx->maxObj()[col];
4017 *val = spx->maxObj()[col] - spx->pVec()[col];
4021 assert( spx->rep() == SPxSolver::ROW );
4024 #ifdef SCIP_DISABLED_CODE 4027 if ( spx->getSense() == SPxLP::MINIMIZE )
4030 if ( spx->isColBasic(col) )
4033 for (
int i = spx->dim() - 1; i >= 0; --i)
4035 SPxId
id = spx->basis().baseId(i);
4036 if (
id.isSPxColId() && col == spx->number(SPxColId(
id)) )
4038 *val = sign * spx->fVec()[i];
4062 assert(lpi !=
NULL);
4065 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4069 for( i = 0; i < lpi->
spx->nRows(); ++i )
4071 switch( lpi->
spx->getBasisRowStatus(i) )
4073 case SPxSolver::BASIC:
4076 case SPxSolver::FIXED:
4077 case SPxSolver::ON_LOWER:
4080 case SPxSolver::ON_UPPER:
4083 case SPxSolver::ZERO:
4084 SCIPerrorMessage(
"slack variable has basis status ZERO (should not occur)\n");
4086 case SPxSolver::UNDEFINED:
4097 for( i = 0; i < lpi->
spx->nCols(); ++i )
4100 switch( lpi->
spx->getBasisColStatus(i) )
4102 case SPxSolver::BASIC:
4105 case SPxSolver::FIXED:
4117 case SPxSolver::ON_LOWER:
4120 case SPxSolver::ON_UPPER:
4123 case SPxSolver::ZERO:
4126 case SPxSolver::UNDEFINED:
4151 assert(lpi !=
NULL);
4157 assert(cstat !=
NULL || ncols == 0);
4158 assert(rstat !=
NULL || nrows == 0);
4160 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4163 DataArray<SPxSolver::VarStatus>& m_colstat = lpi->
spx->colStat();
4164 DataArray<SPxSolver::VarStatus>& m_rowstat = lpi->
spx->rowStat();
4166 m_colstat.reSize(ncols);
4167 m_rowstat.reSize(nrows);
4169 for( i = 0; i < nrows; ++i )
4171 assert( rstat != 0 );
4175 m_rowstat[i] = SPxSolver::ON_LOWER;
4178 m_rowstat[i] = SPxSolver::BASIC;
4181 m_rowstat[i] = SPxSolver::ON_UPPER;
4184 SCIPerrorMessage(
"slack variable has basis status ZERO (should not occur)\n");
4193 for( i = 0; i < ncols; ++i )
4195 assert( cstat != 0 );
4199 m_colstat[i] = SPxSolver::ON_LOWER;
4202 m_colstat[i] = SPxSolver::BASIC;
4205 m_colstat[i] = SPxSolver::ON_UPPER;
4208 m_colstat[i] = SPxSolver::ZERO;
4218 (void) lpi->
spx->updateStatus();
4220 lpi->
spx->freePreStrongbranchingBasis();
4235 assert(lpi !=
NULL);
4237 assert(bind !=
NULL);
4239 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4247 if( spx->rep() == SPxSolver::COLUMN )
4249 for(
int i = 0; i < spx->nRows(); ++i )
4251 SPxId
id = spx->basis().baseId(i);
4253 bind[i] = (
id.isSPxColId() ? spx->number(
id) : - 1 - spx->number(
id));
4260 int nrows = spx->nRows();
4261 int ncols = spx->nCols();
4263 assert( spx->rep() == SPxSolver::ROW );
4265 for(
int i = 0; i < nrows; ++i )
4267 if( !spx->isRowBasic(i) )
4275 for(
int j = 0; j < ncols && k < nrows; ++j )
4277 if( !spx->isColBasic(j) )
4294 SCIPdebugMessage(
"Preparing factorization for computation of basis inverse.\n");
4304 DataArray <const SVector*> matrix(spx->nRows());
4307 for (
int i = 0; i < spx->nRows(); ++i)
4309 if ( ! spx->isRowBasic(i) )
4310 matrix[k++] =
new UnitVector(i);
4312 for (
int j = 0; j < spx->nCols(); ++j)
4314 if ( ! spx->isColBasic(j) )
4315 matrix[k++] = &spx->colVector(j);
4317 assert( k == spx->nRows() );
4318 assert( k == matrix.size() );
4323 SLinSolver::Status status = lpi->
factorization->load(matrix.get_ptr(), k);
4327 assert( status == SLinSolver::OK );
4332 for (
int i = 0; i < spx->nRows(); ++i)
4334 if ( ! spx->isRowBasic(i) )
4340 catch(
const SPxException&
x )
4342 std::string s = x.what();
4345 catch(
const SPxException& )
4372 assert( lpi !=
NULL );
4374 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4375 assert(coef !=
NULL);
4377 int nCols = lpi->
spx->nCols();
4378 int nRows = lpi->
spx->nRows();
4388 if ( spx->rep() == SPxSolver::COLUMN )
4391 spx->basis().coSolve(x, spx->unitVector(r));
4394 if( ninds !=
NULL && inds !=
NULL )
4400 for(
int i = 0; i < *ninds; ++i )
4411 Vector
y(nRows, coef);
4419 assert(spx->rep() == SPxSolver::ROW);
4436 Vector
x(nRows, coef);
4438 DSVector rhs(nCols);
4460 assert(idx < nRows);
4461 assert(!spx->isRowBasic(idx));
4464 rhs = spx->rowVector(idx);
4471 assert(idx < nCols);
4472 assert(!spx->isColBasic(idx));
4475 rhs = spx->unitVector(idx);
4479 spx->basis().solve(y, rhs);
4485 for(
int i = 0; i < nCols; ++i )
4487 SPxId
id = spx->basis().baseId(i);
4489 if(
id.isSPxRowId() )
4491 assert(spx->number(
id) >= 0);
4492 assert(spx->number(
id) < nRows);
4493 assert(bind[r] >= 0 || spx->number(
id) != idx);
4495 x[spx->number(
id)] = y[i];
4502 assert(x[idx] == 0.0);
4516 catch(
const SPxException& x )
4518 std::string s = x.what();
4521 catch(
const SPxException& )
4540 assert(lpi !=
NULL);
4542 assert(lpi->
spx->preStrongbranchingBasisFreed());
4543 assert(rhs !=
NULL);
4544 assert(coef !=
NULL);
4546 int nCols = lpi->
spx->nCols();
4547 int nRows = lpi->
spx->nRows();
4552 Vector v(nRows, rhs);
4553 Vector
x(nRows, coef);
4556 if( spx->rep() == SPxSolver::COLUMN )
4559 spx->basis().solve(x, v);
4563 assert(spx->rep() == SPxSolver::ROW);
4574 DSVector rowrhs(nCols);
4586 for(
int i = 0; i < nCols; ++i )
4588 SPxId
id = spx->basis().baseId(i);
4590 if(
id.isSPxRowId() )
4592 assert(spx->number(
id) >= 0);
4593 assert(spx->number(
id) < nRows);
4595 rowrhs.add(i, v[spx->number(
id)]);
4599 assert(rowrhs[i] == 0.0);
4604 spx->basis().coSolve(y, rowrhs);
4607 for(
int i = 0; i < nRows; ++i )
4619 assert(idx < nRows);
4620 assert(!spx->isRowBasic(idx));
4622 x[i] = v[idx] - (spx->rowVector(idx) * Vector(nCols, y.get_ptr()));
4628 assert(idx < nCols);
4629 assert(!spx->isColBasic(idx));
4641 catch(
const SPxException& x )
4643 std::string s = x.what();
4646 catch(
const SPxException& )
4676 assert( lpi !=
NULL );
4678 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4679 assert(coef !=
NULL);
4686 DVector e(lpi->
spx->nRows());
4691 assert(c < lpi->spx->nRows());
4724 assert(lpi !=
NULL);
4726 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4727 assert(coef !=
NULL);
4729 nrows = lpi->
spx->nRows();
4730 ncols = lpi->
spx->nCols();
4734 if( binvrow ==
NULL )
4743 assert(binv !=
NULL);
4750 soplex::Vector binvvec(nrows, binv);
4751 for( c = 0; c < ncols; ++c )
4752 coef[c] = binvvec * lpi->
spx->colVector(c);
4775 DVector col(lpi->
spx->nRows());
4779 assert( lpi !=
NULL );
4781 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4782 assert(coef !=
NULL);
4786 assert(c < lpi->spx->nCols());
4793 col = lpi->
spx->colVector(c);
4794 col.reDim(lpi->
spx->nRows());
4826 assert(blkmem !=
NULL);
4827 assert(lpi !=
NULL);
4829 assert(lpistate !=
NULL);
4831 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4833 ncols = lpi->
spx->nCols();
4834 nrows = lpi->
spx->nRows();
4849 (*lpistate)->ncols = ncols;
4850 (*lpistate)->nrows = nrows;
4871 assert(lpi !=
NULL);
4873 assert(lpistate !=
NULL);
4876 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4878 lpncols = lpi->
spx->nCols();
4879 lpnrows = lpi->
spx->nRows();
4880 assert(lpistate->
ncols <= lpncols);
4881 assert(lpistate->
nrows <= lpnrows);
4891 for( i = lpistate->
ncols; i < lpncols; ++i )
4897 bnd = lpi->
spx->lower(i);
4906 for( i = lpistate->
nrows; i < lpnrows; ++i )
4922 assert(lpi !=
NULL);
4930 catch(
const SPxException&
x )
4932 std::string s = x.what();
4935 catch(
const SPxException& )
4938 assert( lpi->
spx->getStatus() != SPxSolver::OPTIMAL );
4954 assert(lpi !=
NULL);
4955 assert(lpistate !=
NULL);
4956 assert(blkmem !=
NULL);
4958 if ( *lpistate !=
NULL )
4970 assert(lpi !=
NULL);
4981 assert(lpi !=
NULL);
4983 assert(fname !=
NULL);
4985 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4999 assert(lpi !=
NULL);
5001 assert(fname !=
NULL);
5004 assert( lpi->
spx->preStrongbranchingBasisFreed() );
5036 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 5040 assert(blkmem !=
NULL);
5041 assert(lpi !=
NULL);
5043 assert(lpinorms !=
NULL);
5045 lpi->
spx->getNdualNorms(nrows, ncols);
5047 if( nrows == 0 && ncols == 0)
5056 (*lpinorms)->nrows = 0;
5057 (*lpinorms)->ncols = 0;
5059 SCIPdebugMessage(
"storing SoPlex LPi pricing norms in %p (%d rows, %d cols)\n", (
void *) *lpinorms, nrows, ncols);
5061 if( !lpi->
spx->getDualNorms((*lpinorms)->nrows, (*lpinorms)->ncols, (*lpinorms)->norms) )
5066 assert(*lpinorms ==
NULL);
5071 assert(nrows == (*lpinorms)->nrows);
5072 assert(ncols == (*lpinorms)->ncols);
5091 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 5092 assert(blkmem !=
NULL);
5093 assert(lpi !=
NULL);
5097 if( lpinorms ==
NULL )
5100 assert(lpinorms->
nrows <= lpi->
spx->nRows());
5101 assert(lpinorms->
ncols <= lpi->
spx->nCols());
5103 if( lpinorms->
nrows == 0 )
5106 SCIPdebugMessage(
"loading LPi simplex norms %p (%d rows, %d cols) into SoPlex LP with %d rows and %d cols\n",
5107 (
const void *) lpinorms, lpinorms->
nrows, lpinorms->ncols, lpi->
spx->nRows(), lpi->
spx->nCols());
5109 if( !lpi->
spx->setDualNorms(lpinorms->nrows, lpinorms->ncols, lpinorms->norms) )
5123 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 5124 assert(lpi !=
NULL);
5125 assert(lpinorms !=
NULL);
5131 assert(*lpinorms ==
NULL);
5158 assert(lpi !=
NULL);
5160 assert(ival !=
NULL);
5165 *ival = lpi->
spx->getFromScratch();
5168 *ival = lpi->
spx->getLpInfo();
5171 *ival = lpi->
spx->getIterationLimit();
5176 *ival = lpi->
spx->getPresolving();
5182 *ival = lpi->
spx->getScaling();
5184 #if SOPLEX_VERSION >= 201 5186 *ival = (int) lpi->
spx->getTiming();
5189 #if SOPLEX_VERSION >= 230 || (SOPLEX_VERSION == 220 && SOPLEX_SUBVERSION >= 3) 5191 *ival = (int) lpi->
spx->random.getSeed();
5210 assert(lpi !=
NULL);
5217 lpi->
spx->setFromScratch(
bool(ival));
5221 lpi->
spx->setLpInfo(
bool(ival));
5224 assert( ival >= 0 );
5226 if( ival >= INT_MAX )
5228 lpi->
spx->setIterationLimit(ival);
5232 lpi->
spx->setPresolving(
bool(ival));
5240 lpi->
spx->setAutoPricer();
5243 lpi->
spx->setFullPricer();
5246 lpi->
spx->setParmultPricer();
5249 lpi->
spx->setSteepPricer();
5252 lpi->
spx->setSteepQStartPricer();
5255 lpi->
spx->setDevexPricer();
5263 lpi->
spx->setScaling(ival);
5265 #if SOPLEX_VERSION >= 201 5267 assert(ival >= 0 && ival < 3);
5268 lpi->
spx->setTiming((Timer::TYPE) ival);
5271 #if SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 220 && SOPLEX_SUBVERSION >= 2) 5273 lpi->
spx->random.setSeed((
unsigned int) ival);
5276 #if SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 221 && SOPLEX_SUBVERSION >= 3) 5278 assert(ival >= 0 && ival < 3);
5279 lpi->
spx->setSolutionPolishing((SPxSolver::SolutionPolish) ival);
5299 assert(lpi !=
NULL);
5301 assert(dval !=
NULL);
5306 *dval = lpi->
spx->feastol();
5308 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 5310 *dval = lpi->
spx->opttol();
5314 if ( lpi->
spx->getSense() == SPxLP::MINIMIZE )
5315 *dval = lpi->
spx->getObjUpLimit();
5317 *dval = lpi->
spx->getObjLoLimit();
5320 *dval = lpi->
spx->terminationTime();
5344 assert(lpi !=
NULL);
5351 assert( dval > 0.0 );
5352 lpi->
spx->setFeastol(dval);
5354 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 5357 assert( dval > 0.0 );
5358 lpi->
spx->setOpttol(dval);
5362 if ( lpi->
spx->getSense() == SPxLP::MINIMIZE )
5363 lpi->
spx->setObjUpLimit(dval);
5365 lpi->
spx->setObjLoLimit(dval);
5368 assert( dval > 0.0 );
5373 lpi->
spx->setTerminationTime(dval);
5376 assert( dval >= 0.0 || dval == -1.0 );
5397 assert(lpi !=
NULL);
5450 const char* filename
5455 f = fopen(filename,
"r");
5472 assert(lpi !=
NULL);
5474 assert(fname !=
NULL);
5476 assert( lpi->
spx->preStrongbranchingBasisFreed() );
5483 if( !lpi->
spx->readLP(fname) )
5487 catch(
const SPxException&
x )
5489 std::string s =
x.what();
5492 catch(
const SPxException& )
5509 assert(lpi !=
NULL);
5511 assert(fname !=
NULL);
5515 lpi->
spx->writeFile(fname);
5518 catch(
const SPxException&
x )
5520 std::string s =
x.what();
5523 catch(
const SPxException& )
static SCIP_RETCODE lpiGetBInvVec(SCIP_LPI *lpi, SCIP_Real *rhs, SCIP_Real *coef)
SCIP_RETCODE SCIPlpiGetBInvCol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiGetNRows(SCIP_LPI *lpi, int *nrows)
enum SCIP_LPSolQuality SCIP_LPSOLQUALITY
SCIP_RETCODE SCIPlpiFree(SCIP_LPI **lpi)
SCIP_RETCODE SCIPlpiSetState(SCIP_LPI *lpi, BMS_BLKMEM *, const SCIP_LPISTATE *lpistate)
SCIP_Bool SCIPlpiIsInfinity(SCIP_LPI *, SCIP_Real val)
#define BMSfreeMemoryArrayNull(ptr)
SCIP_Bool SCIPlpiIsDualUnbounded(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiSetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, const SCIP_LPINORMS *lpinorms)
SCIP_RETCODE SCIPlpiGetDualfarkas(SCIP_LPI *lpi, SCIP_Real *dualfarkas)
SCIP_RETCODE SCIPlpiStartStrongbranch(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetSol(SCIP_LPI *lpi, SCIP_Real *objval, SCIP_Real *primsol, SCIP_Real *dualsol, SCIP_Real *activity, SCIP_Real *redcost)
SCIP_RETCODE SCIPlpiSetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int ival)
enum SCIP_ObjSen SCIP_OBJSEN
SCIP_RETCODE SCIPlpiSolvePrimal(SCIP_LPI *lpi)
void * SCIPlpiGetSolverPointer(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetBase(SCIP_LPI *lpi, int *cstat, int *rstat)
void SCIPdecodeDualBit(const SCIP_DUALPACKET *inp, int *out, int count)
SCIP_RETCODE SCIPlpiChgSides(SCIP_LPI *lpi, int nrows, const int *ind, const SCIP_Real *lhs, const SCIP_Real *rhs)
SCIP_RETCODE SCIPlpiGetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int *ival)
interface methods for specific LP solvers
SCIP_RETCODE SCIPlpiGetIterations(SCIP_LPI *lpi, int *iterations)
static SCIP_RETCODE readFile(SCIP *scip, CMININPUT *cmininput, const char *filename)
static SCIP_RETCODE lpistateCreate(SCIP_LPISTATE **lpistate, BMS_BLKMEM *blkmem, int ncols, int nrows)
SCIP_RETCODE SCIPlpiGetNNonz(SCIP_LPI *lpi, int *nnonz)
#define AUTOPRICING_ITERSWITCH
static int rowpacketNum(int nrows)
static void invalidateSolution(SCIP_LPI *lpi)
static SCIP_RETCODE getRedCostEst(SPxSCIP *spx, int col, SCIP_Real *val)
enum SCIP_Retcode SCIP_RETCODE
SCIP_RETCODE SCIPlpiSetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real dval)
static SCIP_RETCODE spxSolve(SCIP_LPI *lpi, SPxSolver::Representation rep, SPxSolver::Type type)
SCIP_Bool SCIPlpiHasPrimalRay(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
enum SCIP_LPParam SCIP_LPPARAM
SCIP_RETCODE SCIPlpiGetNCols(SCIP_LPI *lpi, int *ncols)
#define BMSallocMemoryArray(ptr, num)
SCIP_RETCODE SCIPlpiReadState(SCIP_LPI *lpi, const char *fname)
SCIP_Bool SCIPlpiHasDualSolve(void)
SCIP_RETCODE SCIPlpiGetBounds(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *lbs, SCIP_Real *ubs)
SCIP_RETCODE SCIPlpiClear(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetRealSolQuality(SCIP_LPI *lpi, SCIP_LPSOLQUALITY qualityindicator, SCIP_Real *quality)
SCIP_RETCODE SCIPlpiScaleCol(SCIP_LPI *lpi, int col, SCIP_Real scaleval)
SCIP_RETCODE SCIPlpiGetObjsen(SCIP_LPI *lpi, SCIP_OBJSEN *objsen)
#define BMSfreeMemory(ptr)
SCIP_RETCODE SCIPlpiSetIntegralityInformation(SCIP_LPI *lpi, int ncols, int *intInfo)
enum SCIP_Pricing SCIP_PRICING
static void lpistateFree(SCIP_LPISTATE **lpistate, BMS_BLKMEM *blkmem)
SCIP_RETCODE SCIPlpiClearState(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)
SCIP_RETCODE SCIPlpiCreate(SCIP_LPI **lpi, SCIP_MESSAGEHDLR *messagehdlr, const char *name, SCIP_OBJSEN objsen)
static SCIP_RETCODE ensureRstatMem(SCIP_LPI *lpi, int num)
SCIP_RETCODE SCIPlpiGetBInvARow(SCIP_LPI *lpi, int r, const SCIP_Real *binvrow, SCIP_Real *coef, int *inds, int *ninds)
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_Bool SCIPlpiIsPrimalUnbounded(SCIP_LPI *lpi)
int SCIPlpiGetInternalStatus(SCIP_LPI *lpi)
#define SOPLEX_TRY(messagehdlr, x)
SCIP_RETCODE SCIPlpiSolveDual(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiIsStable(SCIP_LPI *lpi)
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 SCIPlpiWriteLP(SCIP_LPI *lpi, const char *fname)
static SCIP_RETCODE ensureCstatMem(SCIP_LPI *lpi, int num)
packing single and dual bit values
#define BMSfreeMemoryArray(ptr)
static int colpacketNum(int ncols)
SCIP_RETCODE SCIPlpiGetBasisInd(SCIP_LPI *lpi, int *bind)
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 SPxLP::SPxSense spxObjsen(SCIP_OBJSEN objsen)
SCIP_RETCODE SCIPlpiFreeState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
SCIP_Bool SCIPlpiIsPrimalInfeasible(SCIP_LPI *lpi)
static const char spxname[20]
SCIP_RETCODE SCIPlpiGetColNames(SCIP_LPI *lpi, int firstcol, int lastcol, char **colnames, char *namestorage, int namestoragesize, int *storageleft)
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)
void SCIPmessagePrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
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)
const char * SCIPlpiGetSolverDesc(void)
SCIP_Bool SCIPlpiHasBarrierSolve(void)
SCIP_RETCODE SCIPlpiGetSolFeasibility(SCIP_LPI *lpi, SCIP_Bool *primalfeasible, SCIP_Bool *dualfeasible)
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)
SCIP_RETCODE SCIPlpiFreeNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
SCIP_RETCODE SCIPlpiDelRows(SCIP_LPI *lpi, int firstrow, int lastrow)
static SCIP_Bool fileExists(const char *filename)
void SCIPencodeDualBit(const int *inp, SCIP_DUALPACKET *out, int count)
SCIP_RETCODE SCIPlpiReadLP(SCIP_LPI *lpi, const char *fname)
#define SOPLEX_SUBVERSION
SCIP_Bool SCIPlpiWasSolved(SCIP_LPI *lpi)
#define BMSfreeBlockMemory(mem, ptr)
SCIP_Bool SCIPlpiExistsPrimalRay(SCIP_LPI *lpi)
unsigned int SCIP_DUALPACKET
SCIP_RETCODE SCIPlpiGetObjval(SCIP_LPI *lpi, SCIP_Real *objval)
SCIP_RETCODE SCIPlpiDelRowset(SCIP_LPI *lpi, int *dstat)
SCIP_Bool SCIPlpiHasStateBasis(SCIP_LPI *lpi, SCIP_LPISTATE *lpistate)
SCIP_RETCODE SCIPlpiDelCols(SCIP_LPI *lpi, int firstcol, int lastcol)
#define BMSallocBlockMemoryArray(mem, ptr, num)
SCIP_RETCODE SCIPlpiWriteState(SCIP_LPI *lpi, const char *fname)
SCIP_Real SCIPlpiInfinity(SCIP_LPI *)
SCIP_RETCODE SCIPlpiChgCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real newval)
SCIP_Bool SCIPlpiIsDualFeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
SCIP_Bool SCIPlpiIsDualInfeasible(SCIP_LPI *lpi)
#define BMSallocMemoryCPP(size)
#define BMSfreeBlockMemoryArray(mem, ptr, num)
SCIP_RETCODE SCIPlpiGetRowNames(SCIP_LPI *lpi, int firstrow, int lastrow, char **rownames, char *namestorage, int namestoragesize, int *storageleft)
static void lpistatePack(SCIP_LPISTATE *lpistate, const int *cstat, const int *rstat)
SCIP_RETCODE SCIPlpiSetBase(SCIP_LPI *lpi, const int *cstat, const int *rstat)
SCIP_Bool SCIPlpiIsOptimal(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiHasPrimalSolve(void)
SCIP_RETCODE SCIPlpiChgBounds(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *lb, const SCIP_Real *ub)
SCIP_Bool SCIPlpiIsTimelimExc(SCIP_LPI *lpi)
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)
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)
SCIP_RETCODE SCIPlpiSolveBarrier(SCIP_LPI *lpi, SCIP_Bool crossover)
SCIP_RETCODE SCIPlpiGetPrimalRay(SCIP_LPI *lpi, SCIP_Real *ray)
SCIP_RETCODE SCIPlpiEndStrongbranch(SCIP_LPI *lpi)
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)
SLUFactor * factorization
SCIP_RETCODE SCIPlpiScaleRow(SCIP_LPI *lpi, int row, SCIP_Real scaleval)
SCIP_RETCODE SCIPlpiGetSides(SCIP_LPI *lpi, int firstrow, int lastrow, SCIP_Real *lhss, SCIP_Real *rhss)
static void lpistateUnpack(const SCIP_LPISTATE *lpistate, int *cstat, int *rstat)
SCIP_Bool SCIPlpiHasDualRay(SCIP_LPI *lpi)
public methods for message output
SCIP_RETCODE SCIPlpiGetBInvACol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiGetObj(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *vals)
SCIP_Bool SCIPlpiIsObjlimExc(SCIP_LPI *lpi)
SCIP_DUALPACKET COLPACKET
SCIP_Bool SCIPlpiIsPrimalFeasible(SCIP_LPI *lpi)
#define BMSallocMemory(ptr)
#define BMSreallocMemoryArray(ptr, num)
SCIP_DUALPACKET ROWPACKET
#define SOPLEX_TRY_ABORT(x)
SCIP_RETCODE SCIPlpiChgObj(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *obj)
SCIP_Bool SCIPlpiExistsDualRay(SCIP_LPI *lpi)
SCIP_MESSAGEHDLR * messagehdlr
#define BMSallocBlockMemory(mem, ptr)
SCIP_RETCODE SCIPlpiInterrupt(SCIP_LPI *lpi, SCIP_Bool interrupt)
SCIP_Bool SCIPlpiIsIterlimExc(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real *val)
#define BMSclearMemoryArray(ptr, num)
struct BMS_BlkMem BMS_BLKMEM
SCIP_RETCODE SCIPlpiChgObjsen(SCIP_LPI *lpi, SCIP_OBJSEN objsen)
SCIP_RETCODE SCIPlpiGetBInvRow(SCIP_LPI *lpi, int r, SCIP_Real *coef, int *inds, int *ninds)
const char * SCIPlpiGetSolverName(void)
SCIP_RETCODE SCIPlpiIgnoreInstability(SCIP_LPI *lpi, SCIP_Bool *success)
SCIP_RETCODE SCIPlpiGetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real *dval)
SCIP_RETCODE SCIPlpiDelColset(SCIP_LPI *lpi, int *dstat)