34 #define AUTOPRICING_ITERSWITCH 10000 35 #define STRONGBRANCH_RESTOREBASIS 41 #ifdef SCIP_WITH_LPSCHECK 44 #define CHECK_SPXSOLVE true 45 #define CHECK_SPXSTRONGBRANCH true 47 #define EXIT_AT_WRONG_RESULT false 48 #define EXIT_AT_CPXERROR false 50 #define CPX_CALL(x) do \ 53 if( (_cpxstat_ = (x)) != 0 ) \ 55 SCIPmessagePrintWarning(m_messagehdlr, "CPLEX error <%d>; SoPlex result unchecked\n", _cpxstat_); \ 56 if( EXIT_AT_CPXERROR ) \ 80 #pragma GCC diagnostic ignored "-Wclass-memaccess" 88 #ifndef SOPLEX_SUBVERSION 89 #define SOPLEX_SUBVERSION 0 92 #ifndef SOPLEX_APIVERSION 93 #define SOPLEX_APIVERSION 0 97 #if (SOPLEX_VERSION < 133) 98 #error "This interface is not compatible with SoPlex versions prior to 1.4" 102 #if (SOPLEX_VERSION >= 160) 103 #if (SOPLEX_APIVERSION <= 5) 104 #include "spxgithash.h" 108 #define WITH_BOUNDFLIPPING 109 #if (SOPLEX_APIVERSION <= 5) 111 #include "spxsolver.h" 112 #include "slufactor.h" 113 #include "spxsteeppr.h" 114 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 6) || SOPLEX_VERSION > 160) 115 #include "spxsteepexpr.h" 117 #include "spxparmultpr.h" 118 #include "spxdevexpr.h" 119 #include "spxfastrt.h" 120 #include "spxmainsm.h" 121 #include "spxequilisc.h" 123 #ifdef WITH_BOUNDFLIPPING 124 #include "spxboundflippingrt.h" 136 #if defined(_MSC_VER) && _MSC_VER < 1900 138 #define snprintf _snprintf 142 #define SOPLEX_VERBLEVEL 5 163 #define SOPLEX_TRY(messagehdlr, x) do \ 169 catch( const SPxMemoryException& E ) \ 171 std::string s = E.what(); \ 172 SCIPerrorMessage("SoPlex threw a memory exception: %s\n", s.c_str()); \ 175 catch( const SPxException& E ) \ 177 std::string s = E.what(); \ 178 SCIPmessagePrintWarning((messagehdlr), "SoPlex threw an exception: %s\n", s.c_str()); \ 179 return SCIP_LPERROR; \ 185 #define SOPLEX_TRY(messagehdlr, x) do \ 191 catch( const SPxMemoryException& E ) \ 193 std::string s = E.what(); \ 194 SCIPerrorMessage("SoPlex threw a memory exception: %s\n", s.c_str()); \ 197 catch( const SPxException& ) \ 199 return SCIP_LPERROR; \ 208 #define SOPLEX_TRY_ABORT(x) do \ 214 catch( const SPxException& E ) \ 216 std::string s = E.what(); \ 217 SCIPerrorMessage("SoPlex threw an exception: %s\n", s.c_str()); \ 228 SPxLP::SPxSense m_sense;
230 SPxSteepPR m_price_steep;
231 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 6) || SOPLEX_VERSION > 160) 232 SPxSteepExPR m_price_steep_ex;
234 SPxSteepPR m_price_steep_ex;
236 SPxParMultPR m_price_parmult;
237 SPxDevexPR m_price_devex;
238 #ifdef WITH_BOUNDFLIPPING 239 SPxBoundFlippingRT m_ratio;
256 DataArray<SPxSolver::VarStatus> m_rowstat;
257 DataArray<SPxSolver::VarStatus> m_colstat;
261 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 265 #ifdef SCIP_WITH_LPSCHECK 276 const char* probname =
NULL 280 m_fromscratch(
false),
294 m_messagehdlr(messagehdlr)
296 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 297 setOutstream(m_spxout);
300 setSense(SPxLP::MINIMIZE);
301 #if SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 221 && SOPLEX_SUBVERSION == 4) 302 setBasisSolver(&m_slu);
307 setPricer(&m_price_steep);
310 if ( probname !=
NULL )
313 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 314 m_lpifeastol = SPxSolver::feastol();
315 m_lpiopttol = SPxSolver::opttol();
317 m_lpifeastol = SPxSolver::delta();
318 m_lpiopttol = SPxSolver::delta();
321 #ifdef SCIP_WITH_LPSCHECK 323 m_cpxenv = CPXopenCPLEX(&cpxstat);
324 assert(m_cpxenv !=
NULL);
325 m_cpxlp = CPXcreateprob(m_cpxenv, &cpxstat, probname !=
NULL ? probname :
"spxcheck");
326 (void) CPXsetintparam(m_cpxenv, CPX_PARAM_SCRIND, 0);
328 m_doublecheck =
false;
334 if( m_probname !=
NULL )
335 spx_free(m_probname);
337 freePreStrongbranchingBasis();
339 if( m_rownames !=
NULL )
341 m_rownames->~NameSet();
342 spx_free(m_rownames);
344 if( m_colnames !=
NULL )
346 m_colnames->~NameSet();
347 spx_free(m_colnames);
350 #ifdef SCIP_WITH_LPSCHECK 351 (void) CPXfreeprob(m_cpxenv, &m_cpxlp);
352 (void) CPXcloseCPLEX(&m_cpxenv);
369 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 370 SPxSolver::setFeastol(d);
372 SPxSolver::setDelta(d);
389 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 390 SPxSolver::setOpttol(d);
392 SPxSolver::setDelta(d);
396 bool isPerturbed()
const 399 return (shift() >= 10.0 * epsilon());
403 void setIterationLimit(
412 setPricer(&m_price_devex);
413 m_autopricing =
true;
418 setPricer(&m_price_steep);
419 m_autopricing =
false;
422 void setSteepPricer()
424 setPricer(&m_price_steep_ex);
425 m_autopricing =
false;
428 void setSteepQStartPricer()
430 setPricer(&m_price_steep);
431 m_autopricing =
false;
434 void setParmultPricer()
436 setPricer(&m_price_parmult);
437 m_autopricing =
false;
440 void setDevexPricer()
442 setPricer(&m_price_devex);
443 m_autopricing =
false;
447 int getIterationLimit()
const 452 bool getFromScratch()
const 454 return m_fromscratch;
457 void setFromScratch(
bool fs)
462 int getScaling()
const 467 void setScaling(
int s)
472 bool getPresolving()
const 477 void setPresolving(
bool p)
482 bool getLpInfo()
const 487 void setLpInfo(
bool li)
492 SPxLP::SPxSense getSense()
const 494 assert(m_sense == sense());
499 void setSense(
const SPxLP::SPxSense sen)
501 assert(m_sense == sense());
512 SPxSolver::setTerminationValue(getObjUpLimit());
514 else if( m_sense == SPxLP::MAXIMIZE && getObjLoLimit() > -
soplex::infinity )
517 SPxSolver::setTerminationValue(getObjLoLimit());
522 void setProbname(
const char* probname)
526 assert(probname !=
NULL);
527 if( m_probname !=
NULL )
528 spx_free(m_probname);
530 len = strlen(probname);
531 spx_alloc(m_probname, len + 1);
532 memcpy(m_probname, probname, len + 1);
535 Real getObjLoLimit()
const 540 void setObjLoLimit(Real limit)
542 if( getSense() == SPxLP::MAXIMIZE )
544 SCIPdebugMessage(
"setting termination value from <%g> to <%g>\n", m_objLoLimit, limit);
545 SPxSolver::setTerminationValue(limit);
547 m_objLoLimit = limit;
550 Real getObjUpLimit()
const 555 void setObjUpLimit(Real limit)
557 if( getSense() == SPxLP::MINIMIZE )
559 SCIPdebugMessage(
"setting termination value from <%g> to <%g>\n", m_objUpLimit, limit);
560 SPxSolver::setTerminationValue(limit);
562 m_objUpLimit = limit;
565 void setRep(SPxSolver::Representation p_rep)
569 SCIPdebugMessage(
"switching to %s representation of the basis\n", p_rep == SPxSolver::ROW ?
"row" :
"column");
570 SPxSolver::setRep(p_rep);
574 #ifdef SCIP_WITH_LPSCHECK 575 bool getDoubleCheck()
578 return m_doublecheck && m_checknum + 1 >= CHECK_START;
581 void setDoubleCheck(
bool dc)
590 case SPxSolver::ABORT_TIME:
592 case SPxSolver::ABORT_ITER:
594 case SPxSolver::ABORT_VALUE:
595 return "ABORT_VALUE";
596 case SPxSolver::SINGULAR:
598 case SPxSolver::REGULAR:
602 case SPxSolver::OPTIMAL:
604 case SPxSolver::UNBOUNDED:
606 case SPxSolver::INFEASIBLE:
615 const char* cpxStatusString(
const int stat)
619 case CPX_STAT_ABORT_TIME_LIM:
621 case CPX_STAT_ABORT_IT_LIM:
623 case CPX_STAT_ABORT_OBJ_LIM:
624 return "ABORT_VALUE";
625 case CPX_STAT_OPTIMAL:
627 case CPX_STAT_OPTIMAL_INFEAS:
628 return "CPX_STAT_OPTIMAL_INFEAS: OPT SOL INFEASIBLE AFTER UNSCALING";
629 case CPX_STAT_UNBOUNDED:
631 case CPX_STAT_INFEASIBLE:
633 case CPX_STAT_INForUNBD:
634 return "INFEASIBLE or UNBOUNDED";
635 case CPX_STAT_NUM_BEST:
636 return "CPX_STAT_NUM_BEST: SOL AVAILABLE BUT NOT PROVEN OPTIMAL DUE TO NUM TROUBLE";
646 bool checkConsistentBounds()
const 648 for(
int i = 0; i < nCols(); ++i )
650 if( lower(i) > upper(i) + Param::epsilon() )
652 SCIPerrorMessage(
"inconsistent bounds on column %d: lower=%.17g, upper=%.17g\n",
653 i, lower(i), upper(i));
661 bool checkConsistentSides()
const 663 for(
int i = 0; i < nRows(); ++i )
665 if( lhs(i) > rhs(i) + Param::epsilon() )
677 void trySolve(
bool printwarning =
true)
683 m_stat = SPxSolver::solve();
685 catch(
const SPxException&
x )
687 std::string s = x.what();
692 m_stat = SPxSolver::status();
698 assert( m_stat != SPxSolver::OPTIMAL );
702 m_itused += SPxSolver::iterations();
703 assert(m_itlim < 0 || m_itused <= m_itlim);
706 timespent = SPxSolver::time();
710 timelimit = SPxSolver::terminationTime();
711 if( timelimit > timespent )
712 timelimit -= timespent;
716 assert(timelimit >= 0);
717 SPxSolver::setTerminationTime(timelimit);
721 void doSolve(
bool printwarning =
true)
724 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 725 SPxOut::Verbosity verbosity;
726 verbosity = m_spxout.getVerbosity();
727 m_spxout.setVerbosity(getLpInfo() ? (SPxOut::Verbosity)
SOPLEX_VERBLEVEL : (SPxOut::Verbosity) 0);
730 verbosity = Param::verbose();
734 assert(checkConsistentBounds());
735 assert(checkConsistentSides());
737 #ifdef SCIP_WITH_LPSCHECK 739 if( getDoubleCheck() )
744 setTerminationIter(m_autopricing && (m_itlim < 0 || m_itlim - m_itused >
AUTOPRICING_ITERSWITCH) ? AUTOPRICING_ITERSWITCH : m_itlim - m_itused);
746 trySolve(printwarning);
748 if( m_autopricing && m_stat == SPxSolver::ABORT_ITER && (m_itlim < 0 || m_itlim - m_itused > 0) )
750 setTerminationIter(m_itlim - m_itused);
751 setPricer(&m_price_steep_ex);
753 trySolve(printwarning);
755 setPricer(&m_price_devex);
759 setTerminationIter(m_itlim);
761 if( m_stat == OPTIMAL )
763 Real objval = value();
765 if( (objval > m_objUpLimit) || (objval < m_objLoLimit) )
766 m_stat = ABORT_VALUE;
769 #ifdef SCIP_WITH_LPSCHECK 771 if( getDoubleCheck() && (m_stat == SPxSolver::OPTIMAL || m_stat == SPxSolver::UNBOUNDED || m_stat == SPxSolver::INFEASIBLE || m_stat == SPxSolver::ABORT_VALUE) )
777 CPX_CALL( CPXreadcopyprob(m_cpxenv, m_cpxlp,
"spxcheck.mps",
NULL) );
778 CPX_CALL( CPXreadcopybase(m_cpxenv, m_cpxlp,
"spxcheck.bas") );
781 CPX_CALL( CPXsetdblparam(m_cpxenv, CPX_PARAM_EPOPT,
MAX(opttol(), 1e-9)) );
782 CPX_CALL( CPXsetdblparam(m_cpxenv, CPX_PARAM_EPRHS,
MAX(feastol(), 1e-9)) );
785 CPX_CALL( CPXlpopt(m_cpxenv, m_cpxlp) );
788 CPX_CALL( CPXsolution(m_cpxenv, m_cpxlp, &cpxstat, &cpxobj,
NULL,
NULL,
NULL,
NULL) );
789 if( getSense() == SPxLP::MAXIMIZE )
793 if( cpxstat == CPX_STAT_OPTIMAL_INFEAS )
795 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s)\n",
796 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat));
797 if( EXIT_AT_CPXERROR )
800 else if( (m_stat == SPxSolver::OPTIMAL && cpxstat != CPX_STAT_OPTIMAL)
801 || (m_stat == SPxSolver::UNBOUNDED && cpxstat != CPX_STAT_UNBOUNDED)
802 || (m_stat == SPxSolver::INFEASIBLE && cpxstat != CPX_STAT_INFEASIBLE) )
804 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
805 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat), m_checknum);
806 if( EXIT_AT_WRONG_RESULT )
809 else if( m_stat == SPxSolver::ABORT_VALUE )
813 case CPX_STAT_OPTIMAL:
814 if( (getSense() == SPxSolver::MINIMIZE && LTrel(cpxobj, getObjUpLimit(), 2*opttol()))
815 || (getSense() == SPxSolver::MAXIMIZE && GTrel(cpxobj, getObjLoLimit(), 2*opttol())) )
817 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
818 m_probname, m_stat, spxStatusString(m_stat), cpxobj, getSense() == SPxSolver::MINIMIZE ?
"<" :
">",
819 getSense() == SPxSolver::MINIMIZE ? getObjUpLimit() : getObjLoLimit(), cpxStatusString(cpxstat), m_checknum);
820 if( EXIT_AT_WRONG_RESULT )
823 else if( (getSense() == SPxSolver::MINIMIZE && cpxobj < getObjUpLimit())
824 || (getSense() == SPxSolver::MAXIMIZE && cpxobj > getObjLoLimit()) )
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);
831 case CPX_STAT_OPTIMAL_INFEAS:
832 case CPX_STAT_NUM_BEST:
833 if( (getSense() == SPxSolver::MINIMIZE && cpxobj < getObjUpLimit())
834 || (getSense() == SPxSolver::MAXIMIZE && cpxobj > getObjLoLimit()) )
836 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
837 m_probname, m_stat, spxStatusString(m_stat), cpxobj, getSense() == SPxSolver::MINIMIZE ?
"<" :
">",
838 getSense() == SPxSolver::MINIMIZE ? getObjUpLimit() : getObjLoLimit(), cpxStatusString(cpxstat), m_checknum);
841 case CPX_STAT_INFEASIBLE:
843 case CPX_STAT_UNBOUNDED:
844 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
845 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat), m_checknum);
846 if( EXIT_AT_WRONG_RESULT )
849 case CPX_STAT_INForUNBD:
851 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
852 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat), m_checknum);
857 else if( m_stat == SPxSolver::OPTIMAL )
859 if( (getSense() == SPxSolver::MINIMIZE && LTrel(value(), cpxobj, 2*opttol()))
860 || (getSense() == SPxSolver::MAXIMIZE && GTrel(value(), cpxobj, 2*opttol())) )
865 else if( (getSense() == SPxSolver::MINIMIZE && GTrel(value(), cpxobj, 2*opttol()))
866 || (getSense() == SPxSolver::MAXIMIZE && LTrel(value(), cpxobj, 2*opttol())) )
868 SCIPerrorMessage(
"In %s: LP optimal; SoPlex value=%.10f %s CPLEX value=%.10f suboptimal (checknum=%d)\n", value(),
869 m_probname, getSense() == SPxSolver::MINIMIZE ?
">" :
"<", cpxobj, m_checknum);
870 if( EXIT_AT_WRONG_RESULT )
880 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 881 m_spxout.setVerbosity(verbosity);
883 Param::setVerbose(verbosity);
890 assert(m_sense == sense());
891 SPxEquiliSC* scaler =
NULL;
892 SPxMainSM* simplifier =
NULL;
897 if ( getFromScratch() )
903 catch(
const SPxException&
x )
905 std::string s = x.what();
907 m_stat = SPxSolver::status();
908 assert( m_stat != SPxSolver::OPTIMAL );
912 assert(!getFromScratch() || getBasisStatus() == SPxBasis::NO_PROBLEM);
915 if( SPxSolver::getBasisStatus() == SPxBasis::NO_PROBLEM && (getScaling() > 0) && nCols() > 0 && nRows() > 0 )
917 spx_alloc(scaler, 1);
918 scaler =
new (scaler) SPxEquiliSC();
919 assert(scaler !=
NULL);
920 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 921 scaler->setOutstream(m_spxout);
925 if( SPxSolver::getBasisStatus() == SPxBasis::NO_PROBLEM && getPresolving() && nCols() > 0 && nRows() > 0 )
927 spx_alloc(simplifier, 1);
928 simplifier =
new (simplifier) SPxMainSM();
929 assert(simplifier !=
NULL);
933 if( scaler !=
NULL || simplifier !=
NULL )
934 origlp = SPxLP(*
this);
943 scaler->scale(*
this);
946 if( simplifier !=
NULL )
949 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 950 SPxOut::Verbosity verbosity;
951 verbosity = m_spxout.getVerbosity();
952 m_spxout.setVerbosity(getLpInfo() ? (SPxOut::Verbosity)
SOPLEX_VERBLEVEL : (SPxOut::Verbosity) 0);
955 verbosity = Param::verbose();
959 #ifdef WITH_BOUNDFLIPPING 960 result = simplifier->simplify(*
this, epsilon(), feastol(), opttol(),
true);
962 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 963 result = simplifier->simplify(*
this, epsilon(), feastol(), opttol());
965 result = simplifier->simplify(*
this, epsilon(), delta());
968 SCIPdebugMessage(
"simplifier ended with status %u (0: OKAY, 1: INFEASIBLE, 2: DUAL_INFEASIBLE, 3: UNBOUNDED, 4: VANISHED)\n", result);
971 if( result == SPxSimplifier::INFEASIBLE || result == SPxSimplifier::DUAL_INFEASIBLE )
973 SCIPdebugMessage(
"simplifier detected primal or dual infeasibility - reloading and solving unsimplified LP\n");
975 simplifier->~SPxMainSM();
976 spx_free(simplifier);
978 SPxSolver::loadLP(origlp);
984 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 985 m_spxout.setVerbosity(verbosity);
987 Param::setVerbose(verbosity);
992 if( result != SPxSimplifier::VANISHED )
995 Real objlolimit = getObjLoLimit();
996 Real objuplimit = getObjUpLimit();
998 if( simplifier !=
NULL || scaler !=
NULL )
1010 if( simplifier !=
NULL || scaler !=
NULL )
1012 setObjLoLimit(objlolimit);
1013 setObjUpLimit(objuplimit);
1018 if( m_stat != SPxSolver::OPTIMAL && simplifier !=
NULL )
1020 SCIPdebugMessage(
"presolved LP not optimal - reloading and solving original LP\n");
1022 simplifier->~SPxMainSM();
1023 spx_free(simplifier);
1025 SPxSolver::loadLP(origlp);
1032 if( scaler !=
NULL || simplifier !=
NULL )
1034 SPxSolver::VarStatus* cstat =
NULL;
1035 SPxSolver::VarStatus* rstat =
NULL;
1038 if( (simplifier ==
NULL || result != SPxSimplifier::VANISHED) && SPxSolver::getBasisStatus() >= SPxBasis::REGULAR )
1041 spx_alloc(rstat, nRows());
1042 spx_alloc(cstat, nCols());
1043 (void) SPxSolver::getBasis(rstat, cstat);
1047 if( simplifier !=
NULL && SPxSolver::getBasisStatus() >= SPxBasis::REGULAR )
1049 assert((result == SPxSimplifier::VANISHED) == (cstat ==
NULL));
1050 assert((result == SPxSimplifier::VANISHED) == (rstat ==
NULL));
1053 int ncols = result == SPxSimplifier::VANISHED ? 0 : nCols();
1054 int nrows = result == SPxSimplifier::VANISHED ? 0 : nRows();
1057 DVector primals(ncols);
1058 DVector duals(nrows);
1059 DVector slacks(nrows);
1060 DVector redcosts(ncols);
1061 if( result != SPxSimplifier::VANISHED )
1063 (void) SPxSolver::getPrimal(primals);
1064 (void) SPxSolver::getDual(duals);
1065 (void) SPxSolver::getSlacks(slacks);
1066 (void) SPxSolver::getRedCost(redcosts);
1073 simplifier->unsimplify(primals, duals, slacks, redcosts, rstat, cstat);
1075 catch(
const SPxException&
x )
1077 std::string s = x.what();
1078 SCIPmessagePrintWarning(m_messagehdlr,
"SoPlex unsimplification unsuccessful; solving again without LP presolving (SoPlex says %s)\n",
1087 if( simplifier->isUnsimplified() )
1092 spx_alloc(rstat, origlp.nRows());
1093 spx_alloc(cstat, origlp.nCols());
1094 simplifier->getBasis(rstat, cstat);
1100 SPxSolver::loadLP(origlp);
1104 if( rstat !=
NULL && cstat !=
NULL )
1107 SPxSolver::setBasis(rstat, cstat);
1122 if( scaler !=
NULL )
1124 scaler->~SPxEquiliSC();
1127 if( simplifier !=
NULL )
1129 simplifier->~SPxMainSM();
1130 spx_free(simplifier);
1134 if( m_stat == OPTIMAL )
1136 Real objval = value();
1138 if( (objval > m_objUpLimit) || (objval < m_objLoLimit) )
1139 m_stat = ABORT_VALUE;
1146 void savePreStrongbranchingBasis()
1148 m_rowstat.reSize(nRows());
1149 m_colstat.reSize(nCols());
1153 m_stat = getBasis(m_rowstat.get_ptr(), m_colstat.get_ptr());
1156 catch(
const SPxException&
x )
1158 std::string s = x.what();
1165 assert(m_stat != SPxSolver::OPTIMAL);
1168 catch(
const SPxException& )
1175 void restorePreStrongbranchingBasis()
1177 assert(m_rowstat.size() == nRows());
1178 assert(m_colstat.size() == nCols());
1182 setBasis(m_rowstat.get_const_ptr(), m_colstat.get_const_ptr());
1185 catch(
const SPxException&
x )
1187 std::string s = x.what();
1190 catch(
const SPxException& )
1193 m_stat = SPxSolver::status();
1199 assert(m_stat != SPxSolver::OPTIMAL);
1204 void freePreStrongbranchingBasis()
1211 bool preStrongbranchingBasisFreed()
const 1213 return ((m_rowstat.size() == 0 ) && (m_colstat.size() == 0));
1217 DataArray<SPxSolver::VarStatus>& rowStat()
1223 DataArray<SPxSolver::VarStatus>& colStat()
1235 m_stat = SPxSolver::status();
1239 bool isInitialized()
const 1241 return SPxSolver::isInitialized();
1244 int iterations()
const 1249 virtual void clear()
1252 freePreStrongbranchingBasis();
1253 m_stat = NO_PROBLEM;
1257 bool readLP(
const char* fname)
1261 if ( m_rownames != 0 )
1262 m_rownames->~NameSet();
1264 spx_alloc(m_colnames, 1);
1266 if ( m_colnames != 0 )
1267 m_colnames->~NameSet();
1269 spx_alloc(m_rownames, 1);
1271 m_rownames =
new (m_rownames) NameSet();
1272 m_colnames =
new (m_colnames) NameSet();
1276 m_stat = NO_PROBLEM;
1290 int namestoragesize,
1294 assert( m_colnames !=
NULL );
1297 if ( namestoragesize == 0 )
1300 *storageleft = -m_colnames->memSize();
1304 NameSet* names = m_colnames;
1305 assert( names != 0 );
1306 int sizeleft = namestoragesize;
1307 char* s = namestorage;
1308 for (
int j = firstcol; j <= lastcol; ++j)
1310 const char* t = (*names)[j];
1311 colnames[j-firstcol] = s;
1312 while( *t !=
'\0' && sizeleft >= 0 )
1319 if ( sizeleft == 0 )
1321 *storageleft = namestoragesize - m_colnames->memSize();
1322 assert( *storageleft <= 0 );
1325 *storageleft = sizeleft;
1335 int namestoragesize,
1339 assert( m_rownames !=
NULL );
1342 if ( namestoragesize == 0 )
1345 *storageleft = -m_rownames->memSize();
1349 NameSet* names = m_rownames;
1350 assert( names != 0 );
1351 int sizeleft = namestoragesize;
1352 char* s = namestorage;
1353 for (
int i = firstrow; i <= lastrow; ++i)
1355 const char* t = (*names)[i];
1356 rownames[i-firstrow] = s;
1357 while( *t !=
'\0' && sizeleft >= 0 )
1364 if ( sizeleft == 0 )
1366 *storageleft = m_rownames->memSize() - namestoragesize;
1367 assert( *storageleft <= 0 );
1370 *storageleft = sizeleft;
1386 #define COLS_PER_PACKET SCIP_DUALPACKETSIZE 1388 #define ROWS_PER_PACKET SCIP_DUALPACKETSIZE 1402 SLUFactor* factorization;
1414 COLPACKET* packcstat;
1415 ROWPACKET* packrstat;
1438 assert(lpi !=
NULL);
1448 assert(num <= lpi->cstatsize);
1460 assert(lpi !=
NULL);
1470 assert(num <= lpi->rstatsize);
1508 assert(lpistate !=
NULL);
1524 assert(lpistate !=
NULL);
1541 assert(lpistate !=
NULL);
1542 assert(blkmem !=
NULL);
1563 assert(blkmem !=
NULL);
1564 assert(lpistate !=
NULL);
1565 assert(*lpistate !=
NULL);
1591 return SPxLP::MAXIMIZE;
1593 return SPxLP::MINIMIZE;
1597 return SPxLP::MINIMIZE;
1605 assert(lpi !=
NULL);
1627 #if (SOPLEX_SUBVERSION > 0) 1628 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'};
1630 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'};
1637 spxdesc =
new char[200];
1638 (void)snprintf(spxdesc, 200,
"%s [GitHash: %s]",
"Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de)" 1639 #ifdef SCIP_WITH_LPSCHECK
1640 " - including CPLEX double check" 1671 return (
void*) lpi->
spx;
1681 #if (SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 221 && SOPLEX_SUBVERSION >= 3)) 1682 assert(ncols == lpi->
spx->nCols() || (ncols == 0 && intInfo ==
NULL));
1683 lpi->
spx->setIntegralityInformation(ncols, intInfo);
1686 SCIPerrorMessage(
"SCIPlpiSetIntegralityInformation() has not been implemented yet.\n");
1735 assert(lpi !=
NULL);
1736 assert(name !=
NULL);
1743 SOPLEX_TRY( messagehdlr, (*lpi)->spx = new ((*lpi)->spx) SPxSCIP(messagehdlr, name) );
1744 (*lpi)->cstat =
NULL;
1745 (*lpi)->rstat =
NULL;
1746 (*lpi)->cstatsize = 0;
1747 (*lpi)->rstatsize = 0;
1749 (*lpi)->factorization = 0;
1751 (*lpi)->conditionlimit = -1.0;
1752 (*lpi)->checkcondition =
FALSE;
1753 (*lpi)->messagehdlr = messagehdlr;
1771 assert(lpi !=
NULL);
1772 assert(*lpi !=
NULL);
1773 assert((*lpi)->spx !=
NULL);
1776 (*lpi)->spx->~SPxSCIP();
1821 for( j = 0; j < nnonz; j++ )
1822 assert( val[j] != 0 );
1828 assert(lpi !=
NULL);
1830 assert(lhs !=
NULL);
1831 assert(rhs !=
NULL);
1832 assert(obj !=
NULL);
1835 assert(beg !=
NULL);
1836 assert(ind !=
NULL);
1837 assert(val !=
NULL);
1840 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1844 SPxSCIP* spx = lpi->
spx;
1845 LPRowSet rows(nrows);
1846 DSVector emptyVector(0);
1855 for( i = 0; i < nrows; ++i )
1856 rows.add(lhs[i], emptyVector, rhs[i]);
1863 catch(
const SPxException&
x )
1865 std::string s = x.what();
1868 catch(
const SPxException& )
1893 assert(lpi !=
NULL);
1895 assert(obj !=
NULL);
1898 assert(nnonz == 0 || beg !=
NULL);
1899 assert(nnonz == 0 || ind !=
NULL);
1900 assert(nnonz == 0 || val !=
NULL);
1906 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1912 int nrows = lpi->
spx->nRows();
1913 for (
int j = 0; j < nnonz; ++j)
1915 assert( 0 <= ind[j] && ind[j] < nrows );
1916 assert( val[j] != 0.0 );
1921 SPxSCIP* spx = lpi->
spx;
1924 LPColSet cols(ncols);
1925 DSVector colVector(ncols);
1931 for( i = 0; i < ncols; ++i )
1937 last = (i == ncols-1 ? nnonz : beg[i+1]);
1938 colVector.add( last-start, &ind[start], &val[start] );
1940 cols.add(obj[i], lb[i], colVector, ub[i]);
1945 catch(
const SPxException& x )
1947 std::string s = x.what();
1950 catch(
const SPxException& )
1968 assert(lpi !=
NULL);
1970 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
1974 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1994 assert(lpi !=
NULL);
1996 assert(dstat !=
NULL);
2000 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2002 ncols = lpi->
spx->nCols();
2005 for( i = 0; i < ncols; ++i )
2028 assert(lpi !=
NULL);
2030 assert(lhs !=
NULL);
2031 assert(rhs !=
NULL);
2032 assert(nnonz == 0 || beg !=
NULL);
2033 assert(nnonz == 0 || ind !=
NULL);
2034 assert(nnonz == 0 || val !=
NULL);
2038 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2044 int ncols = lpi->
spx->nCols();
2045 for (
int j = 0; j < nnonz; ++j)
2047 assert( 0 <= ind[j] && ind[j] < ncols );
2048 assert( val[j] != 0.0 );
2055 SPxSCIP* spx = lpi->
spx;
2056 LPRowSet rows(nrows);
2063 for( i = 0; i < nrows; ++i )
2069 last = (i == nrows-1 ? nnonz : beg[i+1]);
2070 rowVector.add( last-start, &ind[start], &val[start] );
2072 rows.add(lhs[i], rowVector, rhs[i]);
2077 catch(
const SPxException&
x )
2079 std::string s =
x.what();
2082 catch(
const SPxException& )
2100 assert(lpi !=
NULL);
2102 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
2106 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2126 assert(lpi !=
NULL);
2131 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2133 nrows = lpi->
spx->nRows();
2136 for( i = 0; i < nrows; ++i )
2151 assert(lpi !=
NULL);
2156 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2175 assert(lpi !=
NULL);
2177 assert(ncols == 0 || (ind !=
NULL && lb !=
NULL && ub !=
NULL));
2183 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2187 for( i = 0; i < ncols; ++i )
2189 assert(0 <= ind[i] && ind[i] < lpi->
spx->nCols());
2193 SCIPerrorMessage(
"LP Error: fixing lower bound for variable %d to infinity.\n", ind[i]);
2198 SCIPerrorMessage(
"LP Error: fixing upper bound for variable %d to -infinity.\n", ind[i]);
2202 lpi->
spx->changeBounds(ind[i], lb[i], ub[i]);
2203 assert(lpi->
spx->lower(ind[i]) <= lpi->
spx->upper(ind[i]) + Param::epsilon());
2207 catch(
const SPxException&
x )
2209 std::string s =
x.what();
2212 catch(
const SPxException& )
2234 assert(lpi !=
NULL);
2236 assert(ind !=
NULL);
2237 assert(lhs !=
NULL);
2238 assert(rhs !=
NULL);
2244 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2248 for( i = 0; i < nrows; ++i )
2250 assert(0 <= ind[i] && ind[i] < lpi->
spx->nRows());
2251 lpi->
spx->changeRange(ind[i], lhs[i], rhs[i]);
2252 assert(lpi->
spx->lhs(ind[i]) <= lpi->
spx->rhs(ind[i]) + Param::epsilon());
2256 catch(
const SPxException&
x )
2258 std::string s =
x.what();
2261 catch(
const SPxException& )
2280 assert(lpi !=
NULL);
2282 assert(0 <= row && row < lpi->spx->nRows());
2283 assert(0 <= col && col < lpi->spx->nCols());
2287 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2302 assert(lpi !=
NULL);
2307 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2326 assert(lpi !=
NULL);
2328 assert(ind !=
NULL);
2329 assert(obj !=
NULL);
2333 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2337 for( i = 0; i < ncols; ++i )
2339 assert(0 <= ind[i] && ind[i] < lpi->
spx->nCols());
2340 lpi->
spx->changeObj(ind[i], obj[i]);
2344 catch(
const SPxException&
x )
2346 std::string s =
x.what();
2349 catch(
const SPxException& )
2370 assert(lpi !=
NULL);
2372 assert(scaleval != 0.0);
2378 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2381 SVector rowvec = lpi->
spx->rowVector(row);
2382 lhs = lpi->
spx->lhs(row);
2383 rhs = lpi->
spx->rhs(row);
2391 else if( scaleval < 0.0 )
2395 else if( scaleval < 0.0 )
2397 if( scaleval < 0.0 )
2405 LPRow lprow(lhs, rowvec, rhs);
2408 lpi->
spx->changeRow(row, lprow);
2409 assert(lpi->
spx->lhs(row) <= lpi->
spx->rhs(row));
2412 catch(
const SPxException&
x )
2414 std::string s =
x.what();
2417 catch(
const SPxException& )
2441 assert(lpi !=
NULL);
2443 assert(scaleval != 0.0);
2449 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2452 SVector colvec = lpi->
spx->colVector(col);
2453 obj = lpi->
spx->obj(col);
2454 lb = lpi->
spx->lower(col);
2455 ub = lpi->
spx->upper(col);
2466 else if( scaleval < 0.0 )
2470 else if( scaleval < 0.0 )
2472 if( scaleval < 0.0 )
2480 LPCol lpcol(obj, colvec, ub, lb);
2483 lpi->
spx->changeCol(col, lpcol);
2484 assert(lpi->
spx->lower(col) <= lpi->
spx->upper(col));
2487 catch(
const SPxException&
x )
2489 std::string s =
x.what();
2492 catch(
const SPxException& )
2521 assert(lpi !=
NULL);
2523 assert(nrows !=
NULL);
2525 *nrows = lpi->
spx->nRows();
2538 assert(lpi !=
NULL);
2540 assert(ncols !=
NULL);
2542 *ncols = lpi->
spx->nCols();
2557 assert(lpi !=
NULL);
2559 assert(nnonz !=
NULL);
2563 if( lpi->
spx->nRows() < lpi->
spx->nCols() )
2565 for( i = 0; i < lpi->
spx->nRows(); ++i )
2566 (*nnonz) += lpi->
spx->rowVector(i).size();
2570 for( i = 0; i < lpi->
spx->nCols(); ++i )
2571 (*nnonz) += lpi->
spx->colVector(i).size();
2598 assert(lpi !=
NULL);
2600 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2606 const Vector& lbvec = lpi->
spx->lower();
2607 const Vector& ubvec = lpi->
spx->upper();
2608 for( i = firstcol; i <= lastcol; ++i )
2610 lb[i-firstcol] = lbvec[i];
2611 ub[i-firstcol] = ubvec[i];
2618 for( i = firstcol; i <= lastcol; ++i )
2620 beg[i-firstcol] = *nnonz;
2621 const SVector& cvec = lpi->
spx->colVector(i);
2622 for( j = 0; j < cvec.size(); ++j )
2624 ind[*nnonz] = cvec.index(j);
2625 val[*nnonz] = cvec.value(j);
2655 assert(lpi !=
NULL);
2657 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
2663 const Vector& lhsvec = lpi->
spx->lhs();
2664 const Vector& rhsvec = lpi->
spx->rhs();
2665 for( i = firstrow; i <= lastrow; ++i )
2667 lhs[i-firstrow] = lhsvec[i];
2668 rhs[i-firstrow] = rhsvec[i];
2675 for( i = firstrow; i <= lastrow; ++i )
2677 beg[i-firstrow] = *nnonz;
2678 const SVector& rvec = lpi->
spx->rowVector(i);
2679 for( j = 0; j < rvec.size(); ++j )
2681 ind[*nnonz] = rvec.index(j);
2682 val[*nnonz] = rvec.value(j);
2698 int namestoragesize,
2702 assert( lpi !=
NULL );
2704 assert( colnames !=
NULL || namestoragesize == 0 );
2705 assert( namestorage !=
NULL || namestoragesize == 0 );
2706 assert( namestoragesize >= 0 );
2707 assert( storageleft !=
NULL );
2708 assert( 0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols() );
2712 lpi->
spx->getColNames(firstcol, lastcol, colnames, namestorage, namestoragesize, storageleft);
2724 int namestoragesize,
2728 assert( lpi !=
NULL );
2730 assert( rownames !=
NULL || namestoragesize == 0 );
2731 assert( namestorage !=
NULL || namestoragesize == 0 );
2732 assert( namestoragesize >= 0 );
2733 assert( storageleft !=
NULL );
2734 assert( 0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows() );
2738 lpi->
spx->getRowNames(firstrow, lastrow, rownames, namestorage, namestoragesize, storageleft);
2751 assert(lpi !=
NULL);
2753 assert(objsen !=
NULL);
2772 assert(lpi !=
NULL);
2774 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2775 assert(vals !=
NULL);
2777 for( i = firstcol; i <= lastcol; ++i )
2778 vals[i-firstcol] = lpi->
spx->obj(i);
2796 assert(lpi !=
NULL);
2798 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2800 for( i = firstcol; i <= lastcol; ++i )
2803 lbs[i-firstcol] = lpi->
spx->lower(i);
2805 ubs[i-firstcol] = lpi->
spx->upper(i);
2824 assert(lpi !=
NULL);
2826 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
2828 for( i = firstrow; i <= lastrow; ++i )
2831 lhss[i-firstrow] = lpi->
spx->lhs(i);
2833 rhss[i-firstrow] = lpi->
spx->rhs(i);
2849 assert(lpi !=
NULL);
2851 assert(0 <= col && col < lpi->spx->nCols());
2852 assert(0 <= row && row < lpi->spx->nRows());
2853 assert(val !=
NULL);
2855 *val = lpi->
spx->colVector(col)[row];
2876 SPxSolver::Representation rep,
2880 assert( lpi !=
NULL );
2882 assert( rep == SPxSolver::ROW || rep == SPxSolver::COLUMN );
2883 assert( type == SPxSolver::ENTER || type == SPxSolver::LEAVE );
2885 SCIPdebugMessage(
"calling SoPlex solve(): %d cols, %d rows, rep=%s\n", lpi->
spx->nCols(), lpi->
spx->nRows(),
2886 rep == SPxSolver::COLUMN ?
"column" :
"row");
2890 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2893 lpi->
spx->setRep(rep);
2894 lpi->
spx->setType(type);
2896 #ifdef SCIP_WITH_LPSCHECK 2897 lpi->
spx->setDoubleCheck(CHECK_SPXSOLVE);
2901 SCIPdebugMessage(
" -> SoPlex status: %d, basis status: %d\n", lpi->
spx->getStatus(), lpi->
spx->basis().status());
2906 case SPxSolver::ABORT_TIME:
2907 case SPxSolver::ABORT_ITER:
2908 case SPxSolver::ABORT_VALUE:
2909 case SPxSolver::SINGULAR:
2910 case SPxSolver::REGULAR:
2912 case SPxSolver::OPTIMAL:
2913 case SPxSolver::UNBOUNDED:
2914 case SPxSolver::INFEASIBLE:
2931 assert(lpi !=
NULL);
2938 rowrep = lpi->
spx->rep() == SPxSolver::ROW;
2958 retcode = rowrep ?
spxSolve(lpi, SPxSolver::ROW, SPxSolver::LEAVE) :
spxSolve(lpi, SPxSolver::COLUMN, SPxSolver::ENTER);
2959 assert(!rowrep || lpi->
spx->rep() == SPxSolver::ROW);
2960 assert(rowrep || lpi->
spx->rep() == SPxSolver::COLUMN);
2975 assert(lpi !=
NULL);
2982 rowrep = lpi->
spx->rep() == SPxSolver::ROW;
3002 retcode = rowrep ?
spxSolve(lpi, SPxSolver::ROW, SPxSolver::ENTER) :
spxSolve(lpi, SPxSolver::COLUMN, SPxSolver::LEAVE);
3003 assert(!rowrep || lpi->
spx->rep() == SPxSolver::ROW);
3004 assert(rowrep || lpi->
spx->rep() == SPxSolver::COLUMN);
3015 assert(lpi !=
NULL);
3030 assert(lpi !=
NULL);
3033 assert( lpi->
spx->preStrongbranchingBasisFreed() );
3034 lpi->
spx->savePreStrongbranchingBasis();
3044 assert(lpi !=
NULL);
3047 assert( ! lpi->
spx->preStrongbranchingBasisFreed() );
3048 lpi->
spx->restorePreStrongbranchingBasis();
3049 lpi->
spx->freePreStrongbranchingBasis();
3076 bool fromparentbasis;
3080 SCIPdebugMessage(
"calling SCIPlpiStrongbranch() on variable %d (%d iterations)\n", col, itlim);
3082 assert(lpi !=
NULL);
3086 assert(downvalid !=
NULL);
3087 assert(upvalid !=
NULL);
3091 fromparentbasis =
false;
3093 oldItlim = spx->getIterationLimit();
3096 oldlb = spx->lower(col);
3097 oldub = spx->upper(col);
3106 lpi->
spx->setType( lpi->
spx->rep() == SPxSolver::ROW ? SPxSolver::ENTER : SPxSolver::LEAVE);
3109 newub =
EPSCEIL(psol-1.0, lpi->
spx->feastol());
3110 if( newub >= oldlb - 0.5 && down !=
NULL )
3112 SCIPdebugMessage(
"strong branching down on x%d (%g) with %d iterations\n", col, psol, itlim);
3114 spx->changeUpper(col, newub);
3115 assert(spx->lower(col) <= spx->upper(col));
3117 spx->setIterationLimit(itlim);
3120 #ifdef SCIP_WITH_LPSCHECK 3121 spx->setDoubleCheck(CHECK_SPXSTRONGBRANCH);
3123 status = spx->solve();
3127 case SPxSolver::OPTIMAL:
3128 *down = spx->value();
3132 case SPxSolver::ABORT_TIME:
3133 case SPxSolver::ABORT_ITER:
3134 case SPxSolver::ABORT_CYCLING:
3135 *down = spx->value();
3137 case SPxSolver::ABORT_VALUE:
3138 case SPxSolver::INFEASIBLE:
3139 *down = spx->terminationValue();
3147 (*iter) += spx->iterations();
3149 #ifdef STRONGBRANCH_RESTOREBASIS 3151 assert( ! spx->preStrongbranchingBasisFreed() );
3152 spx->restorePreStrongbranchingBasis();
3153 fromparentbasis =
false;
3157 if( (status == SPxSolver::ABORT_CYCLING || status == SPxSolver::SINGULAR) && !fromparentbasis && spx->iterations() < itlim )
3159 SCIPdebugMessage(
" --> Repeat strong branching down with %d iterations after restoring basis\n", itlim - spx->iterations());
3160 spx->setIterationLimit(itlim - spx->iterations());
3161 spx->restorePreStrongbranchingBasis();
3162 fromparentbasis =
true;
3167 fromparentbasis =
false;
3170 while( fromparentbasis );
3172 spx->changeUpper(col, oldub);
3173 assert(spx->lower(col) <= spx->upper(col));
3175 else if( down !=
NULL )
3177 *down = spx->terminationValue();
3187 if( newlb <= oldub + 0.5 && up !=
NULL )
3189 SCIPdebugMessage(
"strong branching up on x%d (%g) with %d iterations\n", col, psol, itlim);
3191 spx->changeLower(col, newlb);
3192 assert(spx->lower(col) <= spx->upper(col));
3194 spx->setIterationLimit(itlim);
3197 #ifdef SCIP_WITH_LPSCHECK 3198 spx->setDoubleCheck(CHECK_SPXSTRONGBRANCH);
3200 status = spx->solve();
3204 case SPxSolver::OPTIMAL:
3209 case SPxSolver::ABORT_TIME:
3210 case SPxSolver::ABORT_ITER:
3211 case SPxSolver::ABORT_CYCLING:
3214 case SPxSolver::ABORT_VALUE:
3215 case SPxSolver::INFEASIBLE:
3216 *up = spx->terminationValue();
3224 (*iter) += spx->iterations();
3226 #ifdef STRONGBRANCH_RESTOREBASIS 3228 assert( ! spx->preStrongbranchingBasisFreed() );
3229 spx->restorePreStrongbranchingBasis();
3230 fromparentbasis =
false;
3234 if( (status == SPxSolver::ABORT_CYCLING || status == SPxSolver::SINGULAR) && !fromparentbasis && spx->iterations() < itlim )
3236 SCIPdebugMessage(
" --> Repeat strong branching up with %d iterations after restoring basis\n", itlim - spx->iterations());
3237 spx->restorePreStrongbranchingBasis();
3238 spx->setIterationLimit(itlim - spx->iterations());
3240 fromparentbasis =
true;
3244 fromparentbasis =
false;
3247 while( fromparentbasis );
3249 spx->changeLower(col, oldlb);
3250 assert(spx->lower(col) <= spx->upper(col));
3252 else if( up !=
NULL )
3254 *up = spx->terminationValue();
3262 spx->setIterationLimit(oldItlim);
3266 SCIPdebugMessage(
"SCIPlpiStrongbranch() returned SoPlex status %d\n",
int(status));
3291 retcode =
lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter);
3321 assert( cols !=
NULL );
3322 assert( psols !=
NULL );
3323 assert( down !=
NULL );
3324 assert( up !=
NULL );
3325 assert( downvalid !=
NULL );
3326 assert( upvalid !=
NULL );
3327 assert( down !=
NULL );
3332 for (
int j = 0; j < ncols; ++j)
3335 retcode =
lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter);
3365 retcode =
lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter);
3395 assert( cols !=
NULL );
3396 assert( psols !=
NULL );
3397 assert( down !=
NULL );
3398 assert( up !=
NULL );
3399 assert( downvalid !=
NULL );
3400 assert( upvalid !=
NULL );
3401 assert( down !=
NULL );
3406 for (
int j = 0; j < ncols; ++j)
3409 retcode =
lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter);
3438 assert(lpi !=
NULL);
3461 assert(lpi !=
NULL);
3462 assert(primalfeasible !=
NULL);
3463 assert(dualfeasible !=
NULL);
3480 assert(lpi !=
NULL);
3483 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED);
3495 assert(lpi !=
NULL);
3498 #if ((SOPLEX_VERSION == 150 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 150) 3499 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED);
3512 assert(lpi !=
NULL);
3515 assert(lpi->
spx->getStatus() != SPxSolver::UNBOUNDED || lpi->
spx->basis().status() == SPxBasis::UNBOUNDED);
3520 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED && !lpi->
spx->isPerturbed());
3530 assert(lpi !=
NULL);
3533 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE);
3541 SPxBasis::SPxStatus basestatus;
3545 assert(lpi !=
NULL);
3548 basestatus = lpi->
spx->basis().status();
3553 assert(basestatus == SPxBasis::OPTIMAL || lpi->
spx->getStatus() != SPxSolver::OPTIMAL);
3555 return basestatus == SPxBasis::OPTIMAL ||
3556 ((basestatus == SPxBasis::PRIMAL || basestatus == SPxBasis::UNBOUNDED) && !lpi->
spx->isPerturbed());
3568 assert(lpi !=
NULL);
3571 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE);
3583 assert(lpi !=
NULL);
3586 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE);
3596 assert(lpi !=
NULL);
3599 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE && lpi->
spx->basis().status() == SPxBasis::DUAL
3600 && !lpi->
spx->isPerturbed());
3610 assert(lpi !=
NULL);
3613 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED);
3623 assert(lpi !=
NULL);
3629 assert(lpi->
spx->basis().status() == SPxBasis::OPTIMAL || lpi->
spx->getStatus() != SPxSolver::OPTIMAL);
3631 return (lpi->
spx->basis().status() == SPxBasis::OPTIMAL) ||
3632 (lpi->
spx->basis().status() == SPxBasis::DUAL && !lpi->
spx->isPerturbed());
3642 assert(lpi !=
NULL);
3644 assert((lpi->
spx->basis().status() == SPxBasis::OPTIMAL)
3650 return (lpi->
spx->basis().status() == SPxBasis::OPTIMAL);
3666 assert(lpi !=
NULL);
3669 #if ((SOPLEX_VERSION == 172 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 172) 3702 assert(lpi !=
NULL);
3705 return (lpi->
spx->getStatus() == SPxSolver::ABORT_VALUE);
3715 assert(lpi !=
NULL);
3718 return (lpi->
spx->getStatus() == SPxSolver::ABORT_ITER);
3728 assert(lpi !=
NULL);
3731 return (lpi->
spx->getStatus() == SPxSolver::ABORT_TIME);
3741 assert(lpi !=
NULL);
3744 return static_cast<int>(lpi->
spx->getStatus());
3755 assert(lpi !=
NULL);
3757 assert(success !=
NULL);
3773 assert(lpi !=
NULL);
3775 assert(objval !=
NULL);
3777 *objval = lpi->
spx->value();
3798 assert(lpi !=
NULL);
3801 if( objval !=
NULL )
3802 *objval = lpi->
spx->value();
3806 if( primsol !=
NULL )
3808 Vector tmp(lpi->
spx->nCols(), primsol);
3809 (void)lpi->
spx->getPrimal(tmp);
3811 if( dualsol !=
NULL )
3813 Vector tmp(lpi->
spx->nRows(), dualsol);
3814 (void)lpi->
spx->getDual(tmp);
3816 if( activity !=
NULL )
3818 Vector tmp(lpi->
spx->nRows(), activity);
3819 (void)lpi->
spx->getSlacks(tmp);
3821 if( redcost !=
NULL )
3823 Vector tmp(lpi->
spx->nCols(), redcost);
3824 (void)lpi->
spx->getRedCost(tmp);
3828 catch(
const SPxException&
x )
3830 std::string s =
x.what();
3833 catch(
const SPxException& )
3850 assert(lpi !=
NULL);
3852 assert(ray !=
NULL);
3854 #if ((SOPLEX_VERSION == 150 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 150) 3857 Vector tmp(lpi->
spx->nCols(), ray);
3858 (void)lpi->
spx->getPrimalray(tmp);
3861 catch(
const SPxException&
x )
3863 std::string s =
x.what();
3866 catch(
const SPxException& )
3874 SCIPerrorMessage(
"SCIPlpiGetPrimalRay() not supported by SoPlex versions <= 1.5.0\n");
3887 assert(lpi !=
NULL);
3889 assert(dualfarkas !=
NULL);
3893 Vector tmp(lpi->
spx->nRows(), dualfarkas);
3894 (void)lpi->
spx->getDualfarkas(tmp);
3897 catch(
const SPxException&
x )
3899 std::string s =
x.what();
3902 catch(
const SPxException& )
3919 assert(lpi !=
NULL);
3921 assert(iterations !=
NULL);
3923 *iterations = lpi->
spx->iterations();
3941 assert(lpi !=
NULL);
3942 assert(quality !=
NULL);
3944 #if ((SOPLEX_VERSION == 172 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 172) 3948 SCIPdebugMessage(
"requesting solution quality from SoPlex: quality %d\n", qualityindicator);
3950 switch( qualityindicator )
3967 *quality = lpi->
spx->basis().condition(maxiter, tolerance);
3990 assert( spx !=
NULL );
3997 if (! spx->isInitialized() )
4000 assert( 0 <= col && col < spx->nCols() );
4002 if( spx->rep() == SPxSolver::COLUMN )
4005 if (spx->getSense() == SPxLP::MINIMIZE)
4006 *val = spx->pVec()[col] - spx->maxObj()[col];
4008 *val = spx->maxObj()[col] - spx->pVec()[col];
4012 assert( spx->rep() == SPxSolver::ROW );
4015 #ifdef SCIP_DISABLED_CODE 4018 if ( spx->getSense() == SPxLP::MINIMIZE )
4021 if ( spx->isColBasic(col) )
4024 for (
int i = spx->dim() - 1; i >= 0; --i)
4026 SPxId
id = spx->basis().baseId(i);
4027 if (
id.isSPxColId() && col == spx->number(SPxColId(
id)) )
4029 *val = sign * spx->fVec()[i];
4053 assert(lpi !=
NULL);
4056 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4060 for( i = 0; i < lpi->
spx->nRows(); ++i )
4062 switch( lpi->
spx->getBasisRowStatus(i) )
4064 case SPxSolver::BASIC:
4068 case SPxSolver::ON_LOWER:
4071 case SPxSolver::ON_UPPER:
4074 case SPxSolver::ZERO:
4075 SCIPerrorMessage(
"slack variable has basis status ZERO (should not occur)\n");
4077 case SPxSolver::UNDEFINED:
4088 for( i = 0; i < lpi->
spx->nCols(); ++i )
4091 switch( lpi->
spx->getBasisColStatus(i) )
4093 case SPxSolver::BASIC:
4108 case SPxSolver::ON_LOWER:
4111 case SPxSolver::ON_UPPER:
4114 case SPxSolver::ZERO:
4117 case SPxSolver::UNDEFINED:
4142 assert(lpi !=
NULL);
4148 assert(cstat !=
NULL || ncols == 0);
4149 assert(rstat !=
NULL || nrows == 0);
4151 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4154 DataArray<SPxSolver::VarStatus>& m_colstat = lpi->
spx->colStat();
4155 DataArray<SPxSolver::VarStatus>& m_rowstat = lpi->
spx->rowStat();
4157 m_colstat.reSize(ncols);
4158 m_rowstat.reSize(nrows);
4160 for( i = 0; i < nrows; ++i )
4162 assert( rstat != 0 );
4166 m_rowstat[i] = SPxSolver::ON_LOWER;
4169 m_rowstat[i] = SPxSolver::BASIC;
4172 m_rowstat[i] = SPxSolver::ON_UPPER;
4175 SCIPerrorMessage(
"slack variable has basis status ZERO (should not occur)\n");
4184 for( i = 0; i < ncols; ++i )
4186 assert( cstat != 0 );
4190 m_colstat[i] = SPxSolver::ON_LOWER;
4193 m_colstat[i] = SPxSolver::BASIC;
4196 m_colstat[i] = SPxSolver::ON_UPPER;
4199 m_colstat[i] = SPxSolver::ZERO;
4209 (void) lpi->
spx->updateStatus();
4211 lpi->
spx->freePreStrongbranchingBasis();
4226 assert(lpi !=
NULL);
4228 assert(bind !=
NULL);
4230 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4238 if( spx->rep() == SPxSolver::COLUMN )
4240 for(
int i = 0; i < spx->nRows(); ++i )
4242 SPxId
id = spx->basis().baseId(i);
4244 bind[i] = (
id.isSPxColId() ? spx->number(
id) : - 1 - spx->number(
id));
4251 int nrows = spx->nRows();
4252 int ncols = spx->nCols();
4254 assert( spx->rep() == SPxSolver::ROW );
4256 for(
int i = 0; i < nrows; ++i )
4258 if( !spx->isRowBasic(i) )
4266 for(
int j = 0; j < ncols && k < nrows; ++j )
4268 if( !spx->isColBasic(j) )
4285 SCIPdebugMessage(
"Preparing factorization for computation of basis inverse.\n");
4295 DataArray <const SVector*> matrix(spx->nRows());
4298 for (
int i = 0; i < spx->nRows(); ++i)
4300 if ( ! spx->isRowBasic(i) )
4301 matrix[k++] =
new UnitVector(i);
4303 for (
int j = 0; j < spx->nCols(); ++j)
4305 if ( ! spx->isColBasic(j) )
4306 matrix[k++] = &spx->colVector(j);
4308 assert( k == spx->nRows() );
4309 assert( k == matrix.size() );
4318 assert( status == SLinSolver::OK );
4323 for (
int i = 0; i < spx->nRows(); ++i)
4325 if ( ! spx->isRowBasic(i) )
4331 catch(
const SPxException&
x )
4333 std::string s = x.what();
4336 catch(
const SPxException& )
4363 assert( lpi !=
NULL );
4365 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4366 assert(coef !=
NULL);
4368 int nCols = lpi->
spx->nCols();
4369 int nRows = lpi->
spx->nRows();
4379 if ( spx->rep() == SPxSolver::COLUMN )
4382 spx->basis().coSolve(x, spx->unitVector(r));
4385 if( ninds !=
NULL && inds !=
NULL )
4391 for(
int i = 0; i < *ninds; ++i )
4402 Vector
y(nRows, coef);
4410 assert(spx->rep() == SPxSolver::ROW);
4427 Vector
x(nRows, coef);
4429 DSVector rhs(nCols);
4451 assert(idx < nRows);
4452 assert(!spx->isRowBasic(idx));
4455 rhs = spx->rowVector(idx);
4462 assert(idx < nCols);
4463 assert(!spx->isColBasic(idx));
4466 rhs = spx->unitVector(idx);
4470 spx->basis().solve(y, rhs);
4476 for(
int i = 0; i < nCols; ++i )
4478 SPxId
id = spx->basis().baseId(i);
4480 if(
id.isSPxRowId() )
4482 assert(spx->number(
id) >= 0);
4483 assert(spx->number(
id) < nRows);
4484 assert(bind[r] >= 0 || spx->number(
id) != idx);
4486 x[spx->number(
id)] = y[i];
4493 assert(x[idx] == 0.0);
4507 catch(
const SPxException& x )
4509 std::string s = x.what();
4512 catch(
const SPxException& )
4531 assert(lpi !=
NULL);
4533 assert(lpi->
spx->preStrongbranchingBasisFreed());
4534 assert(rhs !=
NULL);
4535 assert(coef !=
NULL);
4537 int nCols = lpi->
spx->nCols();
4538 int nRows = lpi->
spx->nRows();
4543 Vector v(nRows, rhs);
4544 Vector
x(nRows, coef);
4547 if( spx->rep() == SPxSolver::COLUMN )
4550 spx->basis().solve(x, v);
4554 assert(spx->rep() == SPxSolver::ROW);
4565 DSVector rowrhs(nCols);
4577 for(
int i = 0; i < nCols; ++i )
4579 SPxId
id = spx->basis().baseId(i);
4581 if(
id.isSPxRowId() )
4583 assert(spx->number(
id) >= 0);
4584 assert(spx->number(
id) < nRows);
4586 rowrhs.add(i, v[spx->number(
id)]);
4590 assert(rowrhs[i] == 0.0);
4595 spx->basis().coSolve(y, rowrhs);
4598 for(
int i = 0; i < nRows; ++i )
4610 assert(idx < nRows);
4611 assert(!spx->isRowBasic(idx));
4613 x[i] = v[idx] - (spx->rowVector(idx) * Vector(nCols, y.get_ptr()));
4619 assert(idx < nCols);
4620 assert(!spx->isColBasic(idx));
4632 catch(
const SPxException& x )
4634 std::string s = x.what();
4637 catch(
const SPxException& )
4667 assert( lpi !=
NULL );
4669 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4670 assert(coef !=
NULL);
4677 DVector e(lpi->
spx->nRows());
4682 assert(c < lpi->spx->nRows());
4715 assert(lpi !=
NULL);
4717 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4718 assert(coef !=
NULL);
4720 nrows = lpi->
spx->nRows();
4721 ncols = lpi->
spx->nCols();
4725 if( binvrow ==
NULL )
4734 assert(binv !=
NULL);
4741 soplex::Vector binvvec(nrows, binv);
4742 for( c = 0; c < ncols; ++c )
4743 coef[c] = binvvec * lpi->
spx->colVector(c);
4766 DVector col(lpi->
spx->nRows());
4770 assert( lpi !=
NULL );
4772 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4773 assert(coef !=
NULL);
4777 assert(c < lpi->spx->nCols());
4784 col = lpi->
spx->colVector(c);
4785 col.reDim(lpi->
spx->nRows());
4817 assert(blkmem !=
NULL);
4818 assert(lpi !=
NULL);
4820 assert(lpistate !=
NULL);
4822 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4824 ncols = lpi->
spx->nCols();
4825 nrows = lpi->
spx->nRows();
4840 (*lpistate)->ncols = ncols;
4841 (*lpistate)->nrows = nrows;
4862 assert(lpi !=
NULL);
4864 assert(lpistate !=
NULL);
4867 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4869 lpncols = lpi->
spx->nCols();
4870 lpnrows = lpi->
spx->nRows();
4871 assert(lpistate->
ncols <= lpncols);
4872 assert(lpistate->
nrows <= lpnrows);
4882 for( i = lpistate->
ncols; i < lpncols; ++i )
4888 bnd = lpi->
spx->lower(i);
4897 for( i = lpistate->
nrows; i < lpnrows; ++i )
4913 assert(lpi !=
NULL);
4921 catch(
const SPxException&
x )
4923 std::string s = x.what();
4926 catch(
const SPxException& )
4929 assert( lpi->
spx->getStatus() != SPxSolver::OPTIMAL );
4945 assert(lpi !=
NULL);
4946 assert(lpistate !=
NULL);
4947 assert(blkmem !=
NULL);
4949 if ( *lpistate !=
NULL )
4961 assert(lpi !=
NULL);
4972 assert(lpi !=
NULL);
4974 assert(fname !=
NULL);
4976 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4990 assert(lpi !=
NULL);
4992 assert(fname !=
NULL);
4995 assert( lpi->
spx->preStrongbranchingBasisFreed() );
5027 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 5031 assert(blkmem !=
NULL);
5032 assert(lpi !=
NULL);
5034 assert(lpinorms !=
NULL);
5036 lpi->
spx->getNdualNorms(nrows, ncols);
5038 if( nrows == 0 && ncols == 0)
5047 (*lpinorms)->nrows = 0;
5048 (*lpinorms)->ncols = 0;
5050 SCIPdebugMessage(
"storing SoPlex LPi pricing norms in %p (%d rows, %d cols)\n", (
void *) *lpinorms, nrows, ncols);
5052 if( !lpi->
spx->getDualNorms((*lpinorms)->nrows, (*lpinorms)->ncols, (*lpinorms)->norms) )
5057 assert(*lpinorms ==
NULL);
5062 assert(nrows == (*lpinorms)->nrows);
5063 assert(ncols == (*lpinorms)->ncols);
5082 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 5083 assert(blkmem !=
NULL);
5084 assert(lpi !=
NULL);
5088 if( lpinorms ==
NULL )
5091 assert(lpinorms->
nrows <= lpi->
spx->nRows());
5092 assert(lpinorms->
ncols <= lpi->
spx->nCols());
5094 if( lpinorms->
nrows == 0 )
5097 SCIPdebugMessage(
"loading LPi simplex norms %p (%d rows, %d cols) into SoPlex LP with %d rows and %d cols\n",
5098 (
const void *) lpinorms, lpinorms->
nrows, lpinorms->ncols, lpi->
spx->nRows(), lpi->
spx->nCols());
5100 if( !lpi->
spx->setDualNorms(lpinorms->nrows, lpinorms->ncols, lpinorms->norms) )
5114 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 5115 assert(lpi !=
NULL);
5116 assert(lpinorms !=
NULL);
5122 assert(*lpinorms ==
NULL);
5149 assert(lpi !=
NULL);
5151 assert(ival !=
NULL);
5156 *ival = lpi->
spx->getFromScratch();
5159 *ival = lpi->
spx->getLpInfo();
5162 *ival = lpi->
spx->getIterationLimit();
5167 *ival = lpi->
spx->getPresolving();
5173 *ival = lpi->
spx->getScaling();
5175 #if SOPLEX_VERSION >= 201 5177 *ival = (int) lpi->
spx->getTiming();
5180 #if SOPLEX_VERSION >= 230 || (SOPLEX_VERSION == 220 && SOPLEX_SUBVERSION >= 3) 5182 *ival = (int) lpi->
spx->random.getSeed();
5201 assert(lpi !=
NULL);
5208 lpi->
spx->setFromScratch(
bool(ival));
5212 lpi->
spx->setLpInfo(
bool(ival));
5215 assert( ival >= 0 );
5217 if( ival >= INT_MAX )
5219 lpi->
spx->setIterationLimit(ival);
5223 lpi->
spx->setPresolving(
bool(ival));
5231 lpi->
spx->setAutoPricer();
5234 lpi->
spx->setFullPricer();
5237 lpi->
spx->setParmultPricer();
5240 lpi->
spx->setSteepPricer();
5243 lpi->
spx->setSteepQStartPricer();
5246 lpi->
spx->setDevexPricer();
5254 lpi->
spx->setScaling(ival);
5256 #if SOPLEX_VERSION >= 201 5258 assert(ival >= 0 && ival < 3);
5259 lpi->
spx->setTiming((Timer::TYPE) ival);
5262 #if SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 220 && SOPLEX_SUBVERSION >= 2) 5264 lpi->
spx->random.setSeed((
unsigned int) ival);
5267 #if SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 221 && SOPLEX_SUBVERSION >= 3) 5269 assert(ival >= 0 && ival < 3);
5270 lpi->
spx->setSolutionPolishing((SPxSolver::SolutionPolish) ival);
5290 assert(lpi !=
NULL);
5292 assert(dval !=
NULL);
5297 *dval = lpi->
spx->feastol();
5299 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 5301 *dval = lpi->
spx->opttol();
5305 if ( lpi->
spx->getSense() == SPxLP::MINIMIZE )
5306 *dval = lpi->
spx->getObjUpLimit();
5308 *dval = lpi->
spx->getObjLoLimit();
5311 *dval = lpi->
spx->terminationTime();
5335 assert(lpi !=
NULL);
5342 assert( dval > 0.0 );
5343 lpi->
spx->setFeastol(dval);
5345 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 5348 assert( dval > 0.0 );
5349 lpi->
spx->setOpttol(dval);
5353 if ( lpi->
spx->getSense() == SPxLP::MINIMIZE )
5354 lpi->
spx->setObjUpLimit(dval);
5356 lpi->
spx->setObjLoLimit(dval);
5359 assert( dval > 0.0 );
5364 lpi->
spx->setTerminationTime(dval);
5367 assert( dval >= 0.0 || dval == -1.0 );
5388 assert(lpi !=
NULL);
5441 const char* filename
5446 f = fopen(filename,
"r");
5463 assert(lpi !=
NULL);
5465 assert(fname !=
NULL);
5467 assert( lpi->
spx->preStrongbranchingBasisFreed() );
5474 if( !lpi->
spx->readLP(fname) )
5478 catch(
const SPxException&
x )
5480 std::string s =
x.what();
5483 catch(
const SPxException& )
5500 assert(lpi !=
NULL);
5502 assert(fname !=
NULL);
5506 lpi->
spx->writeFile(fname);
5509 catch(
const SPxException&
x )
5511 std::string s =
x.what();
5514 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)
std::pair< SolType, OutcomeType > Result
A result comprises of a solution/ray in feasible space and a corresponding outcome in objective space...
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)
polyscip::Polyscip::PolyscipStatus Status
abbreviation
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)
static SCIP_RETCODE pricing(SCIP *scip, SCIP_PRICER *pricer, SCIP_Real *lowerbound, SCIP_Bool farkas)
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)
struct fixed_graph_components FIXED
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)