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);
1638 #if (SOPLEX_SUBVERSION > 0) 1639 snprintf(spxname, 100,
"SoPlex1 %d.%d.%d.%d", SOPLEX_VERSION/100, (SOPLEX_VERSION % 100)/10, SOPLEX_VERSION % 10,
SOPLEX_SUBVERSION);
1641 snprintf(spxname, 100,
"SoPlex1 %d.%d.%d", SOPLEX_VERSION/100, (SOPLEX_VERSION % 100)/10, SOPLEX_VERSION % 10);
1651 #if (SOPLEX_VERSION >= 160) 1652 snprintf(spxdesc, 200,
"Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de) [GitHash: %s]" 1653 #ifdef SCIP_WITH_LPSCHECK
1654 " - including CPLEX double check" 1658 snprintf(spxdesc, 200,
"Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de)" 1659 #ifdef SCIP_WITH_LPSCHECK
1660 " - including CPLEX double check" 1672 return (
void*) lpi->
spx;
1682 #if (SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 221 && SOPLEX_SUBVERSION >= 3)) 1683 assert(ncols == lpi->
spx->nCols() || (ncols == 0 && intInfo ==
NULL));
1684 lpi->
spx->setIntegralityInformation(ncols, intInfo);
1687 SCIPerrorMessage(
"SCIPlpiSetIntegralityInformation() has not been implemented yet.\n");
1736 assert(lpi !=
NULL);
1737 assert(name !=
NULL);
1744 SOPLEX_TRY( messagehdlr, (*lpi)->spx = new ((*lpi)->spx) SPxSCIP(messagehdlr, name) );
1745 (*lpi)->cstat =
NULL;
1746 (*lpi)->rstat =
NULL;
1747 (*lpi)->cstatsize = 0;
1748 (*lpi)->rstatsize = 0;
1750 (*lpi)->factorization = 0;
1752 (*lpi)->conditionlimit = -1.0;
1753 (*lpi)->checkcondition =
FALSE;
1754 (*lpi)->messagehdlr = messagehdlr;
1772 assert(lpi !=
NULL);
1773 assert(*lpi !=
NULL);
1774 assert((*lpi)->spx !=
NULL);
1777 (*lpi)->spx->~SPxSCIP();
1822 for( j = 0; j < nnonz; j++ )
1823 assert( val[j] != 0 );
1829 assert(lpi !=
NULL);
1831 assert(lhs !=
NULL);
1832 assert(rhs !=
NULL);
1833 assert(obj !=
NULL);
1836 assert(beg !=
NULL);
1837 assert(ind !=
NULL);
1838 assert(val !=
NULL);
1841 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1845 SPxSCIP* spx = lpi->
spx;
1846 LPRowSet rows(nrows);
1847 DSVector emptyVector(0);
1856 for( i = 0; i < nrows; ++i )
1857 rows.add(lhs[i], emptyVector, rhs[i]);
1864 catch(
const SPxException&
x )
1866 std::string s =
x.what();
1869 catch(
const SPxException& )
1894 assert(lpi !=
NULL);
1896 assert(obj !=
NULL);
1899 assert(nnonz == 0 || beg !=
NULL);
1900 assert(nnonz == 0 || ind !=
NULL);
1901 assert(nnonz == 0 || val !=
NULL);
1907 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1913 int nrows = lpi->
spx->nRows();
1914 for (
int j = 0; j < nnonz; ++j)
1916 assert( 0 <= ind[j] && ind[j] < nrows );
1917 assert( val[j] != 0.0 );
1922 SPxSCIP* spx = lpi->
spx;
1925 LPColSet cols(ncols);
1926 DSVector colVector(ncols);
1932 for( i = 0; i < ncols; ++i )
1938 last = (i == ncols-1 ? nnonz : beg[i+1]);
1939 colVector.add( last-start, &ind[start], &val[start] );
1941 cols.add(obj[i], lb[i], colVector, ub[i]);
1946 catch(
const SPxException&
x )
1948 std::string s =
x.what();
1951 catch(
const SPxException& )
1969 assert(lpi !=
NULL);
1971 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
1975 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1995 assert(lpi !=
NULL);
1997 assert(dstat !=
NULL);
2001 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2003 ncols = lpi->
spx->nCols();
2006 for( i = 0; i < ncols; ++i )
2029 assert(lpi !=
NULL);
2031 assert(lhs !=
NULL);
2032 assert(rhs !=
NULL);
2033 assert(nnonz == 0 || beg !=
NULL);
2034 assert(nnonz == 0 || ind !=
NULL);
2035 assert(nnonz == 0 || val !=
NULL);
2039 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2045 int ncols = lpi->
spx->nCols();
2046 for (
int j = 0; j < nnonz; ++j)
2048 assert( 0 <= ind[j] && ind[j] < ncols );
2049 assert( val[j] != 0.0 );
2056 SPxSCIP* spx = lpi->
spx;
2057 LPRowSet rows(nrows);
2064 for( i = 0; i < nrows; ++i )
2070 last = (i == nrows-1 ? nnonz : beg[i+1]);
2071 rowVector.add( last-start, &ind[start], &val[start] );
2073 rows.add(lhs[i], rowVector, rhs[i]);
2078 catch(
const SPxException&
x )
2080 std::string s =
x.what();
2083 catch(
const SPxException& )
2101 assert(lpi !=
NULL);
2103 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
2107 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2127 assert(lpi !=
NULL);
2132 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2134 nrows = lpi->
spx->nRows();
2137 for( i = 0; i < nrows; ++i )
2152 assert(lpi !=
NULL);
2157 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2176 assert(lpi !=
NULL);
2178 assert(ncols == 0 || (ind !=
NULL && lb !=
NULL && ub !=
NULL));
2184 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2188 for( i = 0; i < ncols; ++i )
2190 assert(0 <= ind[i] && ind[i] < lpi->
spx->nCols());
2194 SCIPerrorMessage(
"LP Error: fixing lower bound for variable %d to infinity.\n", ind[i]);
2199 SCIPerrorMessage(
"LP Error: fixing upper bound for variable %d to -infinity.\n", ind[i]);
2203 lpi->
spx->changeBounds(ind[i], lb[i], ub[i]);
2204 assert(lpi->
spx->lower(ind[i]) <= lpi->
spx->upper(ind[i]) + Param::epsilon());
2208 catch(
const SPxException&
x )
2210 std::string s =
x.what();
2213 catch(
const SPxException& )
2235 assert(lpi !=
NULL);
2237 assert(ind !=
NULL);
2238 assert(lhs !=
NULL);
2239 assert(rhs !=
NULL);
2245 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2249 for( i = 0; i < nrows; ++i )
2251 assert(0 <= ind[i] && ind[i] < lpi->
spx->nRows());
2252 lpi->
spx->changeRange(ind[i], lhs[i], rhs[i]);
2253 assert(lpi->
spx->lhs(ind[i]) <= lpi->
spx->rhs(ind[i]) + Param::epsilon());
2257 catch(
const SPxException&
x )
2259 std::string s =
x.what();
2262 catch(
const SPxException& )
2281 assert(lpi !=
NULL);
2283 assert(0 <= row && row < lpi->spx->nRows());
2284 assert(0 <= col && col < lpi->spx->nCols());
2288 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2303 assert(lpi !=
NULL);
2308 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2327 assert(lpi !=
NULL);
2329 assert(ind !=
NULL);
2330 assert(obj !=
NULL);
2334 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2338 for( i = 0; i < ncols; ++i )
2340 assert(0 <= ind[i] && ind[i] < lpi->
spx->nCols());
2341 lpi->
spx->changeObj(ind[i], obj[i]);
2345 catch(
const SPxException&
x )
2347 std::string s =
x.what();
2350 catch(
const SPxException& )
2371 assert(lpi !=
NULL);
2373 assert(scaleval != 0.0);
2379 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2382 SVector rowvec = lpi->
spx->rowVector(row);
2383 lhs = lpi->
spx->lhs(row);
2384 rhs = lpi->
spx->rhs(row);
2392 else if( scaleval < 0.0 )
2396 else if( scaleval < 0.0 )
2398 if( scaleval < 0.0 )
2406 LPRow lprow(lhs, rowvec, rhs);
2409 lpi->
spx->changeRow(row, lprow);
2410 assert(lpi->
spx->lhs(row) <= lpi->
spx->rhs(row));
2413 catch(
const SPxException&
x )
2415 std::string s =
x.what();
2418 catch(
const SPxException& )
2442 assert(lpi !=
NULL);
2444 assert(scaleval != 0.0);
2450 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2453 SVector colvec = lpi->
spx->colVector(col);
2454 obj = lpi->
spx->obj(col);
2455 lb = lpi->
spx->lower(col);
2456 ub = lpi->
spx->upper(col);
2467 else if( scaleval < 0.0 )
2471 else if( scaleval < 0.0 )
2473 if( scaleval < 0.0 )
2481 LPCol lpcol(obj, colvec, ub, lb);
2484 lpi->
spx->changeCol(col, lpcol);
2485 assert(lpi->
spx->lower(col) <= lpi->
spx->upper(col));
2488 catch(
const SPxException&
x )
2490 std::string s =
x.what();
2493 catch(
const SPxException& )
2522 assert(lpi !=
NULL);
2524 assert(nrows !=
NULL);
2526 *nrows = lpi->
spx->nRows();
2539 assert(lpi !=
NULL);
2541 assert(ncols !=
NULL);
2543 *ncols = lpi->
spx->nCols();
2558 assert(lpi !=
NULL);
2560 assert(nnonz !=
NULL);
2564 if( lpi->
spx->nRows() < lpi->
spx->nCols() )
2566 for( i = 0; i < lpi->
spx->nRows(); ++i )
2567 (*nnonz) += lpi->
spx->rowVector(i).size();
2571 for( i = 0; i < lpi->
spx->nCols(); ++i )
2572 (*nnonz) += lpi->
spx->colVector(i).size();
2599 assert(lpi !=
NULL);
2601 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2607 const Vector& lbvec = lpi->
spx->lower();
2608 const Vector& ubvec = lpi->
spx->upper();
2609 for( i = firstcol; i <= lastcol; ++i )
2611 lb[i-firstcol] = lbvec[i];
2612 ub[i-firstcol] = ubvec[i];
2619 for( i = firstcol; i <= lastcol; ++i )
2621 beg[i-firstcol] = *nnonz;
2622 const SVector& cvec = lpi->
spx->colVector(i);
2623 for( j = 0; j < cvec.size(); ++j )
2625 ind[*nnonz] = cvec.index(j);
2626 val[*nnonz] = cvec.value(j);
2656 assert(lpi !=
NULL);
2658 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
2664 const Vector& lhsvec = lpi->
spx->lhs();
2665 const Vector& rhsvec = lpi->
spx->rhs();
2666 for( i = firstrow; i <= lastrow; ++i )
2668 lhs[i-firstrow] = lhsvec[i];
2669 rhs[i-firstrow] = rhsvec[i];
2676 for( i = firstrow; i <= lastrow; ++i )
2678 beg[i-firstrow] = *nnonz;
2679 const SVector& rvec = lpi->
spx->rowVector(i);
2680 for( j = 0; j < rvec.size(); ++j )
2682 ind[*nnonz] = rvec.index(j);
2683 val[*nnonz] = rvec.value(j);
2699 int namestoragesize,
2703 assert( lpi !=
NULL );
2705 assert( colnames !=
NULL || namestoragesize == 0 );
2706 assert( namestorage !=
NULL || namestoragesize == 0 );
2707 assert( namestoragesize >= 0 );
2708 assert( storageleft !=
NULL );
2709 assert( 0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols() );
2713 lpi->
spx->getColNames(firstcol, lastcol, colnames, namestorage, namestoragesize, storageleft);
2725 int namestoragesize,
2729 assert( lpi !=
NULL );
2731 assert( rownames !=
NULL || namestoragesize == 0 );
2732 assert( namestorage !=
NULL || namestoragesize == 0 );
2733 assert( namestoragesize >= 0 );
2734 assert( storageleft !=
NULL );
2735 assert( 0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows() );
2739 lpi->
spx->getRowNames(firstrow, lastrow, rownames, namestorage, namestoragesize, storageleft);
2752 assert(lpi !=
NULL);
2754 assert(objsen !=
NULL);
2773 assert(lpi !=
NULL);
2775 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2776 assert(vals !=
NULL);
2778 for( i = firstcol; i <= lastcol; ++i )
2779 vals[i-firstcol] = lpi->
spx->obj(i);
2797 assert(lpi !=
NULL);
2799 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2801 for( i = firstcol; i <= lastcol; ++i )
2804 lbs[i-firstcol] = lpi->
spx->lower(i);
2806 ubs[i-firstcol] = lpi->
spx->upper(i);
2825 assert(lpi !=
NULL);
2827 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
2829 for( i = firstrow; i <= lastrow; ++i )
2832 lhss[i-firstrow] = lpi->
spx->lhs(i);
2834 rhss[i-firstrow] = lpi->
spx->rhs(i);
2850 assert(lpi !=
NULL);
2852 assert(0 <= col && col < lpi->spx->nCols());
2853 assert(0 <= row && row < lpi->spx->nRows());
2854 assert(val !=
NULL);
2856 *val = lpi->
spx->colVector(col)[row];
2877 SPxSolver::Representation rep,
2881 assert( lpi !=
NULL );
2883 assert( rep == SPxSolver::ROW || rep == SPxSolver::COLUMN );
2884 assert( type == SPxSolver::ENTER || type == SPxSolver::LEAVE );
2886 SCIPdebugMessage(
"calling SoPlex solve(): %d cols, %d rows, rep=%s\n", lpi->
spx->nCols(), lpi->
spx->nRows(),
2887 rep == SPxSolver::COLUMN ?
"column" :
"row");
2891 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2894 lpi->
spx->setRep(rep);
2895 lpi->
spx->setType(type);
2897 #ifdef SCIP_WITH_LPSCHECK 2898 lpi->
spx->setDoubleCheck(CHECK_SPXSOLVE);
2902 SCIPdebugMessage(
" -> SoPlex status: %d, basis status: %d\n", lpi->
spx->getStatus(), lpi->
spx->basis().status());
2907 case SPxSolver::ABORT_TIME:
2908 case SPxSolver::ABORT_ITER:
2909 case SPxSolver::ABORT_VALUE:
2910 case SPxSolver::SINGULAR:
2911 case SPxSolver::REGULAR:
2913 case SPxSolver::OPTIMAL:
2914 case SPxSolver::UNBOUNDED:
2915 case SPxSolver::INFEASIBLE:
2932 assert(lpi !=
NULL);
2939 rowrep = lpi->
spx->rep() == SPxSolver::ROW;
2959 retcode = rowrep ?
spxSolve(lpi, SPxSolver::ROW, SPxSolver::LEAVE) :
spxSolve(lpi, SPxSolver::COLUMN, SPxSolver::ENTER);
2960 assert(!rowrep || lpi->
spx->rep() == SPxSolver::ROW);
2961 assert(rowrep || lpi->
spx->rep() == SPxSolver::COLUMN);
2976 assert(lpi !=
NULL);
2983 rowrep = lpi->
spx->rep() == SPxSolver::ROW;
3003 retcode = rowrep ?
spxSolve(lpi, SPxSolver::ROW, SPxSolver::ENTER) :
spxSolve(lpi, SPxSolver::COLUMN, SPxSolver::LEAVE);
3004 assert(!rowrep || lpi->
spx->rep() == SPxSolver::ROW);
3005 assert(rowrep || lpi->
spx->rep() == SPxSolver::COLUMN);
3016 assert(lpi !=
NULL);
3031 assert(lpi !=
NULL);
3034 assert( lpi->
spx->preStrongbranchingBasisFreed() );
3035 lpi->
spx->savePreStrongbranchingBasis();
3045 assert(lpi !=
NULL);
3048 assert( ! lpi->
spx->preStrongbranchingBasisFreed() );
3049 lpi->
spx->restorePreStrongbranchingBasis();
3050 lpi->
spx->freePreStrongbranchingBasis();
3077 bool fromparentbasis;
3081 SCIPdebugMessage(
"calling SCIPlpiStrongbranch() on variable %d (%d iterations)\n", col, itlim);
3083 assert(lpi !=
NULL);
3087 assert(downvalid !=
NULL);
3088 assert(upvalid !=
NULL);
3092 fromparentbasis =
false;
3094 oldItlim = spx->getIterationLimit();
3097 oldlb = spx->lower(col);
3098 oldub = spx->upper(col);
3107 lpi->
spx->setType( lpi->
spx->rep() == SPxSolver::ROW ? SPxSolver::ENTER : SPxSolver::LEAVE);
3110 newub =
EPSCEIL(psol-1.0, lpi->
spx->feastol());
3111 if( newub >= oldlb - 0.5 && down !=
NULL )
3113 SCIPdebugMessage(
"strong branching down on x%d (%g) with %d iterations\n", col, psol, itlim);
3115 spx->changeUpper(col, newub);
3116 assert(spx->lower(col) <= spx->upper(col));
3118 spx->setIterationLimit(itlim);
3121 #ifdef SCIP_WITH_LPSCHECK 3122 spx->setDoubleCheck(CHECK_SPXSTRONGBRANCH);
3124 status = spx->solve();
3128 case SPxSolver::OPTIMAL:
3129 *down = spx->value();
3133 case SPxSolver::ABORT_TIME:
3134 case SPxSolver::ABORT_ITER:
3135 case SPxSolver::ABORT_CYCLING:
3136 *down = spx->value();
3138 case SPxSolver::ABORT_VALUE:
3139 case SPxSolver::INFEASIBLE:
3140 *down = spx->terminationValue();
3148 (*iter) += spx->iterations();
3150 #ifdef STRONGBRANCH_RESTOREBASIS 3152 assert( ! spx->preStrongbranchingBasisFreed() );
3153 spx->restorePreStrongbranchingBasis();
3154 fromparentbasis =
false;
3158 if( (status == SPxSolver::ABORT_CYCLING || status == SPxSolver::SINGULAR) && !fromparentbasis && spx->iterations() < itlim )
3160 SCIPdebugMessage(
" --> Repeat strong branching down with %d iterations after restoring basis\n", itlim - spx->iterations());
3161 spx->setIterationLimit(itlim - spx->iterations());
3162 spx->restorePreStrongbranchingBasis();
3163 fromparentbasis =
true;
3168 fromparentbasis =
false;
3171 while( fromparentbasis );
3173 spx->changeUpper(col, oldub);
3174 assert(spx->lower(col) <= spx->upper(col));
3176 else if( down !=
NULL )
3178 *down = spx->terminationValue();
3188 if( newlb <= oldub + 0.5 && up !=
NULL )
3190 SCIPdebugMessage(
"strong branching up on x%d (%g) with %d iterations\n", col, psol, itlim);
3192 spx->changeLower(col, newlb);
3193 assert(spx->lower(col) <= spx->upper(col));
3195 spx->setIterationLimit(itlim);
3198 #ifdef SCIP_WITH_LPSCHECK 3199 spx->setDoubleCheck(CHECK_SPXSTRONGBRANCH);
3201 status = spx->solve();
3205 case SPxSolver::OPTIMAL:
3210 case SPxSolver::ABORT_TIME:
3211 case SPxSolver::ABORT_ITER:
3212 case SPxSolver::ABORT_CYCLING:
3215 case SPxSolver::ABORT_VALUE:
3216 case SPxSolver::INFEASIBLE:
3217 *up = spx->terminationValue();
3225 (*iter) += spx->iterations();
3227 #ifdef STRONGBRANCH_RESTOREBASIS 3229 assert( ! spx->preStrongbranchingBasisFreed() );
3230 spx->restorePreStrongbranchingBasis();
3231 fromparentbasis =
false;
3235 if( (status == SPxSolver::ABORT_CYCLING || status == SPxSolver::SINGULAR) && !fromparentbasis && spx->iterations() < itlim )
3237 SCIPdebugMessage(
" --> Repeat strong branching up with %d iterations after restoring basis\n", itlim - spx->iterations());
3238 spx->restorePreStrongbranchingBasis();
3239 spx->setIterationLimit(itlim - spx->iterations());
3241 fromparentbasis =
true;
3245 fromparentbasis =
false;
3248 while( fromparentbasis );
3250 spx->changeLower(col, oldlb);
3251 assert(spx->lower(col) <= spx->upper(col));
3253 else if( up !=
NULL )
3255 *up = spx->terminationValue();
3263 spx->setIterationLimit(oldItlim);
3267 SCIPdebugMessage(
"SCIPlpiStrongbranch() returned SoPlex status %d\n",
int(status));
3292 retcode =
lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter);
3322 assert( cols !=
NULL );
3323 assert( psols !=
NULL );
3324 assert( down !=
NULL );
3325 assert( up !=
NULL );
3326 assert( downvalid !=
NULL );
3327 assert( upvalid !=
NULL );
3328 assert( down !=
NULL );
3333 for (
int j = 0; j < ncols; ++j)
3336 retcode =
lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter);
3366 retcode =
lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter);
3396 assert( cols !=
NULL );
3397 assert( psols !=
NULL );
3398 assert( down !=
NULL );
3399 assert( up !=
NULL );
3400 assert( downvalid !=
NULL );
3401 assert( upvalid !=
NULL );
3402 assert( down !=
NULL );
3407 for (
int j = 0; j < ncols; ++j)
3410 retcode =
lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter);
3439 assert(lpi !=
NULL);
3462 assert(lpi !=
NULL);
3463 assert(primalfeasible !=
NULL);
3464 assert(dualfeasible !=
NULL);
3481 assert(lpi !=
NULL);
3484 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED);
3496 assert(lpi !=
NULL);
3499 #if ((SOPLEX_VERSION == 150 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 150) 3500 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED);
3513 assert(lpi !=
NULL);
3516 assert(lpi->
spx->getStatus() != SPxSolver::UNBOUNDED || lpi->
spx->basis().status() == SPxBasis::UNBOUNDED);
3521 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED && !lpi->
spx->isPerturbed());
3531 assert(lpi !=
NULL);
3534 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE);
3542 SPxBasis::SPxStatus basestatus;
3546 assert(lpi !=
NULL);
3549 basestatus = lpi->
spx->basis().status();
3554 assert(basestatus == SPxBasis::OPTIMAL || lpi->
spx->getStatus() != SPxSolver::OPTIMAL);
3556 return basestatus == SPxBasis::OPTIMAL ||
3557 ((basestatus == SPxBasis::PRIMAL || basestatus == SPxBasis::UNBOUNDED) && !lpi->
spx->isPerturbed());
3569 assert(lpi !=
NULL);
3572 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE);
3584 assert(lpi !=
NULL);
3587 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE);
3597 assert(lpi !=
NULL);
3600 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE && lpi->
spx->basis().status() == SPxBasis::DUAL
3601 && !lpi->
spx->isPerturbed());
3611 assert(lpi !=
NULL);
3614 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED);
3624 assert(lpi !=
NULL);
3630 assert(lpi->
spx->basis().status() == SPxBasis::OPTIMAL || lpi->
spx->getStatus() != SPxSolver::OPTIMAL);
3632 return (lpi->
spx->basis().status() == SPxBasis::OPTIMAL) ||
3633 (lpi->
spx->basis().status() == SPxBasis::DUAL && !lpi->
spx->isPerturbed());
3643 assert(lpi !=
NULL);
3645 assert((lpi->
spx->basis().status() == SPxBasis::OPTIMAL)
3651 return (lpi->
spx->basis().status() == SPxBasis::OPTIMAL);
3667 assert(lpi !=
NULL);
3670 #if ((SOPLEX_VERSION == 172 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 172) 3703 assert(lpi !=
NULL);
3706 return (lpi->
spx->getStatus() == SPxSolver::ABORT_VALUE);
3716 assert(lpi !=
NULL);
3719 return (lpi->
spx->getStatus() == SPxSolver::ABORT_ITER);
3729 assert(lpi !=
NULL);
3732 return (lpi->
spx->getStatus() == SPxSolver::ABORT_TIME);
3742 assert(lpi !=
NULL);
3745 return static_cast<int>(lpi->
spx->getStatus());
3756 assert(lpi !=
NULL);
3758 assert(success !=
NULL);
3774 assert(lpi !=
NULL);
3776 assert(objval !=
NULL);
3778 *objval = lpi->
spx->value();
3799 assert(lpi !=
NULL);
3802 if( objval !=
NULL )
3803 *objval = lpi->
spx->value();
3807 if( primsol !=
NULL )
3809 Vector tmp(lpi->
spx->nCols(), primsol);
3810 (void)lpi->
spx->getPrimal(tmp);
3812 if( dualsol !=
NULL )
3814 Vector tmp(lpi->
spx->nRows(), dualsol);
3815 (void)lpi->
spx->getDual(tmp);
3817 if( activity !=
NULL )
3819 Vector tmp(lpi->
spx->nRows(), activity);
3820 (void)lpi->
spx->getSlacks(tmp);
3822 if( redcost !=
NULL )
3824 Vector tmp(lpi->
spx->nCols(), redcost);
3825 (void)lpi->
spx->getRedCost(tmp);
3829 catch(
const SPxException&
x )
3831 std::string s =
x.what();
3834 catch(
const SPxException& )
3851 assert(lpi !=
NULL);
3853 assert(ray !=
NULL);
3855 #if ((SOPLEX_VERSION == 150 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 150) 3858 Vector tmp(lpi->
spx->nCols(), ray);
3859 (void)lpi->
spx->getPrimalray(tmp);
3862 catch(
const SPxException&
x )
3864 std::string s =
x.what();
3867 catch(
const SPxException& )
3875 SCIPerrorMessage(
"SCIPlpiGetPrimalRay() not supported by SoPlex versions <= 1.5.0\n");
3888 assert(lpi !=
NULL);
3890 assert(dualfarkas !=
NULL);
3894 Vector tmp(lpi->
spx->nRows(), dualfarkas);
3895 (void)lpi->
spx->getDualfarkas(tmp);
3898 catch(
const SPxException&
x )
3900 std::string s =
x.what();
3903 catch(
const SPxException& )
3920 assert(lpi !=
NULL);
3922 assert(iterations !=
NULL);
3924 *iterations = lpi->
spx->iterations();
3942 assert(lpi !=
NULL);
3943 assert(quality !=
NULL);
3945 #if ((SOPLEX_VERSION == 172 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 172) 3949 SCIPdebugMessage(
"requesting solution quality from SoPlex: quality %d\n", qualityindicator);
3951 switch( qualityindicator )
3968 *quality = lpi->
spx->basis().condition(maxiter, tolerance);
3991 assert( spx !=
NULL );
3998 if (! spx->isInitialized() )
4001 assert( 0 <= col && col < spx->nCols() );
4003 if( spx->rep() == SPxSolver::COLUMN )
4006 if (spx->getSense() == SPxLP::MINIMIZE)
4007 *val = spx->pVec()[col] - spx->maxObj()[col];
4009 *val = spx->maxObj()[col] - spx->pVec()[col];
4013 assert( spx->rep() == SPxSolver::ROW );
4016 #ifdef SCIP_DISABLED_CODE 4019 if ( spx->getSense() == SPxLP::MINIMIZE )
4022 if ( spx->isColBasic(col) )
4025 for (
int i = spx->dim() - 1; i >= 0; --i)
4027 SPxId
id = spx->basis().baseId(i);
4028 if (
id.isSPxColId() && col == spx->number(SPxColId(
id)) )
4030 *val = sign * spx->fVec()[i];
4054 assert(lpi !=
NULL);
4057 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4061 for( i = 0; i < lpi->
spx->nRows(); ++i )
4063 switch( lpi->
spx->getBasisRowStatus(i) )
4065 case SPxSolver::BASIC:
4069 case SPxSolver::ON_LOWER:
4072 case SPxSolver::ON_UPPER:
4075 case SPxSolver::ZERO:
4076 SCIPerrorMessage(
"slack variable has basis status ZERO (should not occur)\n");
4078 case SPxSolver::UNDEFINED:
4089 for( i = 0; i < lpi->
spx->nCols(); ++i )
4092 switch( lpi->
spx->getBasisColStatus(i) )
4094 case SPxSolver::BASIC:
4109 case SPxSolver::ON_LOWER:
4112 case SPxSolver::ON_UPPER:
4115 case SPxSolver::ZERO:
4118 case SPxSolver::UNDEFINED:
4143 assert(lpi !=
NULL);
4149 assert(cstat !=
NULL || ncols == 0);
4150 assert(rstat !=
NULL || nrows == 0);
4152 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4155 DataArray<SPxSolver::VarStatus>& m_colstat = lpi->
spx->colStat();
4156 DataArray<SPxSolver::VarStatus>& m_rowstat = lpi->
spx->rowStat();
4158 m_colstat.reSize(ncols);
4159 m_rowstat.reSize(nrows);
4161 for( i = 0; i < nrows; ++i )
4163 assert( rstat != 0 );
4167 m_rowstat[i] = SPxSolver::ON_LOWER;
4170 m_rowstat[i] = SPxSolver::BASIC;
4173 m_rowstat[i] = SPxSolver::ON_UPPER;
4176 SCIPerrorMessage(
"slack variable has basis status ZERO (should not occur)\n");
4185 for( i = 0; i < ncols; ++i )
4187 assert( cstat != 0 );
4191 m_colstat[i] = SPxSolver::ON_LOWER;
4194 m_colstat[i] = SPxSolver::BASIC;
4197 m_colstat[i] = SPxSolver::ON_UPPER;
4200 m_colstat[i] = SPxSolver::ZERO;
4210 (void) lpi->
spx->updateStatus();
4212 lpi->
spx->freePreStrongbranchingBasis();
4227 assert(lpi !=
NULL);
4229 assert(bind !=
NULL);
4231 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4239 if( spx->rep() == SPxSolver::COLUMN )
4241 for(
int i = 0; i < spx->nRows(); ++i )
4243 SPxId
id = spx->basis().baseId(i);
4245 bind[i] = (
id.isSPxColId() ? spx->number(
id) : - 1 - spx->number(
id));
4252 int nrows = spx->nRows();
4253 int ncols = spx->nCols();
4255 assert( spx->rep() == SPxSolver::ROW );
4257 for(
int i = 0; i < nrows; ++i )
4259 if( !spx->isRowBasic(i) )
4267 for(
int j = 0; j < ncols && k < nrows; ++j )
4269 if( !spx->isColBasic(j) )
4286 SCIPdebugMessage(
"Preparing factorization for computation of basis inverse.\n");
4296 DataArray <const SVector*> matrix(spx->nRows());
4299 for (
int i = 0; i < spx->nRows(); ++i)
4301 if ( ! spx->isRowBasic(i) )
4302 matrix[k++] =
new UnitVector(i);
4304 for (
int j = 0; j < spx->nCols(); ++j)
4306 if ( ! spx->isColBasic(j) )
4307 matrix[k++] = &spx->colVector(j);
4309 assert( k == spx->nRows() );
4310 assert( k == matrix.size() );
4319 assert( status == SLinSolver::OK );
4324 for (
int i = 0; i < spx->nRows(); ++i)
4326 if ( ! spx->isRowBasic(i) )
4332 catch(
const SPxException&
x )
4334 std::string s = x.what();
4337 catch(
const SPxException& )
4364 assert( lpi !=
NULL );
4366 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4367 assert(coef !=
NULL);
4369 int nCols = lpi->
spx->nCols();
4370 int nRows = lpi->
spx->nRows();
4380 if ( spx->rep() == SPxSolver::COLUMN )
4383 spx->basis().coSolve(x, spx->unitVector(r));
4386 if( ninds !=
NULL && inds !=
NULL )
4392 for(
int i = 0; i < *ninds; ++i )
4403 Vector
y(nRows, coef);
4411 assert(spx->rep() == SPxSolver::ROW);
4428 Vector
x(nRows, coef);
4430 DSVector rhs(nCols);
4452 assert(idx < nRows);
4453 assert(!spx->isRowBasic(idx));
4456 rhs = spx->rowVector(idx);
4463 assert(idx < nCols);
4464 assert(!spx->isColBasic(idx));
4467 rhs = spx->unitVector(idx);
4471 spx->basis().solve(y, rhs);
4477 for(
int i = 0; i < nCols; ++i )
4479 SPxId
id = spx->basis().baseId(i);
4481 if(
id.isSPxRowId() )
4483 assert(spx->number(
id) >= 0);
4484 assert(spx->number(
id) < nRows);
4485 assert(bind[r] >= 0 || spx->number(
id) != idx);
4487 x[spx->number(
id)] = y[i];
4494 assert(x[idx] == 0.0);
4508 catch(
const SPxException& x )
4510 std::string s = x.what();
4513 catch(
const SPxException& )
4532 assert(lpi !=
NULL);
4534 assert(lpi->
spx->preStrongbranchingBasisFreed());
4535 assert(rhs !=
NULL);
4536 assert(coef !=
NULL);
4538 int nCols = lpi->
spx->nCols();
4539 int nRows = lpi->
spx->nRows();
4544 Vector v(nRows, rhs);
4545 Vector
x(nRows, coef);
4548 if( spx->rep() == SPxSolver::COLUMN )
4551 spx->basis().solve(x, v);
4555 assert(spx->rep() == SPxSolver::ROW);
4566 DSVector rowrhs(nCols);
4578 for(
int i = 0; i < nCols; ++i )
4580 SPxId
id = spx->basis().baseId(i);
4582 if(
id.isSPxRowId() )
4584 assert(spx->number(
id) >= 0);
4585 assert(spx->number(
id) < nRows);
4587 rowrhs.add(i, v[spx->number(
id)]);
4591 assert(rowrhs[i] == 0.0);
4596 spx->basis().coSolve(y, rowrhs);
4599 for(
int i = 0; i < nRows; ++i )
4611 assert(idx < nRows);
4612 assert(!spx->isRowBasic(idx));
4614 x[i] = v[idx] - (spx->rowVector(idx) * Vector(nCols, y.get_ptr()));
4620 assert(idx < nCols);
4621 assert(!spx->isColBasic(idx));
4633 catch(
const SPxException& x )
4635 std::string s = x.what();
4638 catch(
const SPxException& )
4668 assert( lpi !=
NULL );
4670 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4671 assert(coef !=
NULL);
4678 DVector e(lpi->
spx->nRows());
4683 assert(c < lpi->spx->nRows());
4716 assert(lpi !=
NULL);
4718 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4719 assert(coef !=
NULL);
4721 nrows = lpi->
spx->nRows();
4722 ncols = lpi->
spx->nCols();
4726 if( binvrow ==
NULL )
4735 assert(binv !=
NULL);
4742 soplex::Vector binvvec(nrows, binv);
4743 for( c = 0; c < ncols; ++c )
4744 coef[c] = binvvec * lpi->
spx->colVector(c);
4767 DVector col(lpi->
spx->nRows());
4771 assert( lpi !=
NULL );
4773 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4774 assert(coef !=
NULL);
4778 assert(c < lpi->spx->nCols());
4785 col = lpi->
spx->colVector(c);
4786 col.reDim(lpi->
spx->nRows());
4818 assert(blkmem !=
NULL);
4819 assert(lpi !=
NULL);
4821 assert(lpistate !=
NULL);
4823 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4825 ncols = lpi->
spx->nCols();
4826 nrows = lpi->
spx->nRows();
4841 (*lpistate)->ncols = ncols;
4842 (*lpistate)->nrows = nrows;
4863 assert(lpi !=
NULL);
4865 assert(lpistate !=
NULL);
4868 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4870 lpncols = lpi->
spx->nCols();
4871 lpnrows = lpi->
spx->nRows();
4872 assert(lpistate->
ncols <= lpncols);
4873 assert(lpistate->
nrows <= lpnrows);
4883 for( i = lpistate->
ncols; i < lpncols; ++i )
4889 bnd = lpi->
spx->lower(i);
4898 for( i = lpistate->
nrows; i < lpnrows; ++i )
4914 assert(lpi !=
NULL);
4922 catch(
const SPxException&
x )
4924 std::string s = x.what();
4927 catch(
const SPxException& )
4930 assert( lpi->
spx->getStatus() != SPxSolver::OPTIMAL );
4946 assert(lpi !=
NULL);
4947 assert(lpistate !=
NULL);
4948 assert(blkmem !=
NULL);
4950 if ( *lpistate !=
NULL )
4962 assert(lpi !=
NULL);
4973 assert(lpi !=
NULL);
4975 assert(fname !=
NULL);
4977 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4991 assert(lpi !=
NULL);
4993 assert(fname !=
NULL);
4996 assert( lpi->
spx->preStrongbranchingBasisFreed() );
5028 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 5032 assert(blkmem !=
NULL);
5033 assert(lpi !=
NULL);
5035 assert(lpinorms !=
NULL);
5037 lpi->
spx->getNdualNorms(nrows, ncols);
5039 if( nrows == 0 && ncols == 0)
5048 (*lpinorms)->nrows = 0;
5049 (*lpinorms)->ncols = 0;
5051 SCIPdebugMessage(
"storing SoPlex LPi pricing norms in %p (%d rows, %d cols)\n", (
void *) *lpinorms, nrows, ncols);
5053 if( !lpi->
spx->getDualNorms((*lpinorms)->nrows, (*lpinorms)->ncols, (*lpinorms)->norms) )
5058 assert(*lpinorms ==
NULL);
5063 assert(nrows == (*lpinorms)->nrows);
5064 assert(ncols == (*lpinorms)->ncols);
5083 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 5084 assert(blkmem !=
NULL);
5085 assert(lpi !=
NULL);
5089 if( lpinorms ==
NULL )
5092 assert(lpinorms->
nrows <= lpi->
spx->nRows());
5093 assert(lpinorms->
ncols <= lpi->
spx->nCols());
5095 if( lpinorms->
nrows == 0 )
5098 SCIPdebugMessage(
"loading LPi simplex norms %p (%d rows, %d cols) into SoPlex LP with %d rows and %d cols\n",
5099 (
const void *) lpinorms, lpinorms->
nrows, lpinorms->ncols, lpi->
spx->nRows(), lpi->
spx->nCols());
5101 if( !lpi->
spx->setDualNorms(lpinorms->nrows, lpinorms->ncols, lpinorms->norms) )
5115 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 5116 assert(lpi !=
NULL);
5117 assert(lpinorms !=
NULL);
5123 assert(*lpinorms ==
NULL);
5150 assert(lpi !=
NULL);
5152 assert(ival !=
NULL);
5157 *ival = lpi->
spx->getFromScratch();
5160 *ival = lpi->
spx->getLpInfo();
5163 *ival = lpi->
spx->getIterationLimit();
5168 *ival = lpi->
spx->getPresolving();
5174 *ival = lpi->
spx->getScaling();
5176 #if SOPLEX_VERSION >= 201 5178 *ival = (int) lpi->
spx->getTiming();
5181 #if SOPLEX_VERSION >= 230 || (SOPLEX_VERSION == 220 && SOPLEX_SUBVERSION >= 3) 5183 *ival = (int) lpi->
spx->random.getSeed();
5202 assert(lpi !=
NULL);
5209 lpi->
spx->setFromScratch(
bool(ival));
5213 lpi->
spx->setLpInfo(
bool(ival));
5216 assert( ival >= 0 );
5218 if( ival >= INT_MAX )
5220 lpi->
spx->setIterationLimit(ival);
5224 lpi->
spx->setPresolving(
bool(ival));
5232 lpi->
spx->setAutoPricer();
5235 lpi->
spx->setFullPricer();
5238 lpi->
spx->setParmultPricer();
5241 lpi->
spx->setSteepPricer();
5244 lpi->
spx->setSteepQStartPricer();
5247 lpi->
spx->setDevexPricer();
5255 lpi->
spx->setScaling(ival);
5257 #if SOPLEX_VERSION >= 201 5259 assert(ival >= 0 && ival < 3);
5260 lpi->
spx->setTiming((Timer::TYPE) ival);
5263 #if SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 220 && SOPLEX_SUBVERSION >= 2) 5265 lpi->
spx->random.setSeed((
unsigned int) ival);
5268 #if SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 221 && SOPLEX_SUBVERSION >= 3) 5270 assert(ival >= 0 && ival < 3);
5271 lpi->
spx->setSolutionPolishing((SPxSolver::SolutionPolish) ival);
5291 assert(lpi !=
NULL);
5293 assert(dval !=
NULL);
5298 *dval = lpi->
spx->feastol();
5300 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 5302 *dval = lpi->
spx->opttol();
5306 if ( lpi->
spx->getSense() == SPxLP::MINIMIZE )
5307 *dval = lpi->
spx->getObjUpLimit();
5309 *dval = lpi->
spx->getObjLoLimit();
5312 *dval = lpi->
spx->terminationTime();
5336 assert(lpi !=
NULL);
5343 assert( dval > 0.0 );
5344 lpi->
spx->setFeastol(dval);
5346 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 5349 assert( dval > 0.0 );
5350 lpi->
spx->setOpttol(dval);
5354 if ( lpi->
spx->getSense() == SPxLP::MINIMIZE )
5355 lpi->
spx->setObjUpLimit(dval);
5357 lpi->
spx->setObjLoLimit(dval);
5360 assert( dval > 0.0 );
5365 lpi->
spx->setTerminationTime(dval);
5368 assert( dval >= 0.0 || dval == -1.0 );
5389 assert(lpi !=
NULL);
5442 const char* filename
5447 f = fopen(filename,
"r");
5464 assert(lpi !=
NULL);
5466 assert(fname !=
NULL);
5468 assert( lpi->
spx->preStrongbranchingBasisFreed() );
5475 if( !lpi->
spx->readLP(fname) )
5479 catch(
const SPxException&
x )
5481 std::string s =
x.what();
5484 catch(
const SPxException& )
5501 assert(lpi !=
NULL);
5503 assert(fname !=
NULL);
5507 lpi->
spx->writeFile(fname);
5510 catch(
const SPxException&
x )
5512 std::string s =
x.what();
5515 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)
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)