34 #define AUTOPRICING_ITERSWITCH 10000 35 #define STRONGBRANCH_RESTOREBASIS 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 ) \ 76 #include "spxsolver.h" 79 #ifndef SOPLEX_SUBVERSION 80 #define SOPLEX_SUBVERSION 0 84 #if (SOPLEX_VERSION < 133) 85 #error "This interface is not compatible with SoPlex versions prior to 1.4" 89 #if (SOPLEX_VERSION >= 160) 90 #include "spxgithash.h" 94 #include "slufactor.h" 95 #include "spxsteeppr.h" 96 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 6) || SOPLEX_VERSION > 160) 97 #include "spxsteepexpr.h" 99 #include "spxparmultpr.h" 100 #include "spxdevexpr.h" 101 #include "spxfastrt.h" 102 #include "spxmainsm.h" 103 #include "spxequilisc.h" 105 #define WITH_BOUNDFLIPPING 106 #ifdef WITH_BOUNDFLIPPING 107 #include "spxboundflippingrt.h" 118 #if defined(_MSC_VER) && _MSC_VER < 1900 120 #define snprintf _snprintf 124 #define SOPLEX_VERBLEVEL 5 145 #define SOPLEX_TRY(messagehdlr, x) do \ 151 catch( const SPxMemoryException& E ) \ 153 std::string s = E.what(); \ 154 SCIPerrorMessage("SoPlex threw a memory exception: %s\n", s.c_str()); \ 157 catch( const SPxException& E ) \ 159 std::string s = E.what(); \ 160 SCIPmessagePrintWarning((messagehdlr), "SoPlex threw an exception: %s\n", s.c_str()); \ 161 return SCIP_LPERROR; \ 167 #define SOPLEX_TRY(messagehdlr, x) do \ 173 catch( const SPxMemoryException& E ) \ 175 std::string s = E.what(); \ 176 SCIPerrorMessage("SoPlex threw a memory exception: %s\n", s.c_str()); \ 179 catch( const SPxException& ) \ 181 return SCIP_LPERROR; \ 190 #define SOPLEX_TRY_ABORT(x) do \ 196 catch( const SPxException& E ) \ 198 std::string s = E.what(); \ 199 SCIPerrorMessage("SoPlex threw an exception: %s\n", s.c_str()); \ 210 SPxLP::SPxSense m_sense;
212 SPxSteepPR m_price_steep;
213 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 6) || SOPLEX_VERSION > 160) 214 SPxSteepExPR m_price_steep_ex;
216 SPxSteepPR m_price_steep_ex;
218 SPxParMultPR m_price_parmult;
219 SPxDevexPR m_price_devex;
220 #ifdef WITH_BOUNDFLIPPING 221 SPxBoundFlippingRT m_ratio;
238 DataArray<SPxSolver::VarStatus> m_rowstat;
239 DataArray<SPxSolver::VarStatus> m_colstat;
243 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 258 const char* probname =
NULL 262 m_fromscratch(
false),
276 m_messagehdlr(messagehdlr)
278 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 279 setOutstream(m_spxout);
282 setSense(SPxLP::MINIMIZE);
283 #if SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 221 && SOPLEX_SUBVERSION == 4) 284 setBasisSolver(&m_slu);
289 setPricer(&m_price_steep);
292 if ( probname !=
NULL )
295 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 296 m_lpifeastol = SPxSolver::feastol();
297 m_lpiopttol = SPxSolver::opttol();
299 m_lpifeastol = SPxSolver::delta();
300 m_lpiopttol = SPxSolver::delta();
305 m_cpxenv = CPXopenCPLEX(&cpxstat);
306 assert(m_cpxenv !=
NULL);
307 m_cpxlp = CPXcreateprob(m_cpxenv, &cpxstat, probname !=
NULL ? probname :
"spxcheck");
308 (void) CPXsetintparam(m_cpxenv, CPX_PARAM_SCRIND, 0);
310 m_doublecheck =
false;
316 if( m_probname !=
NULL )
317 spx_free(m_probname);
319 freePreStrongbranchingBasis();
321 if( m_rownames !=
NULL )
323 m_rownames->~NameSet();
324 spx_free(m_rownames);
326 if( m_colnames !=
NULL )
328 m_colnames->~NameSet();
329 spx_free(m_colnames);
333 (void) CPXfreeprob(m_cpxenv, &m_cpxlp);
334 (void) CPXcloseCPLEX(&m_cpxenv);
351 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 354 SPxSolver::setDelta(d);
371 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 372 SPxSolver::setOpttol(d);
374 SPxSolver::setDelta(d);
378 bool isPerturbed()
const 381 return (shift() >= 10.0 * epsilon());
385 void setIterationLimit(
394 setPricer(&m_price_devex);
395 m_autopricing =
true;
400 setPricer(&m_price_steep);
401 m_autopricing =
false;
404 void setSteepPricer()
406 setPricer(&m_price_steep_ex);
407 m_autopricing =
false;
410 void setSteepQStartPricer()
412 setPricer(&m_price_steep);
413 m_autopricing =
false;
416 void setParmultPricer()
418 setPricer(&m_price_parmult);
419 m_autopricing =
false;
422 void setDevexPricer()
424 setPricer(&m_price_devex);
425 m_autopricing =
false;
429 int getIterationLimit()
const 434 bool getFromScratch()
const 436 return m_fromscratch;
439 void setFromScratch(
bool fs)
444 int getScaling()
const 449 void setScaling(
int s)
454 bool getPresolving()
const 459 void setPresolving(
bool p)
464 bool getLpInfo()
const 469 void setLpInfo(
bool li)
474 SPxLP::SPxSense getSense()
const 476 assert(m_sense == sense());
481 void setSense(
const SPxLP::SPxSense sen)
483 assert(m_sense == sense());
494 SPxSolver::setTerminationValue(getObjUpLimit());
496 else if( m_sense == SPxLP::MAXIMIZE && getObjLoLimit() > -
soplex::infinity )
499 SPxSolver::setTerminationValue(getObjLoLimit());
504 void setProbname(
const char* probname)
508 assert(probname !=
NULL);
509 if( m_probname !=
NULL )
510 spx_free(m_probname);
511 len = (int) strlen(probname);
512 spx_alloc(m_probname, len + 1);
513 strncpy(m_probname, probname, len);
514 m_probname[len] =
'\0';
517 Real getObjLoLimit()
const 522 void setObjLoLimit(Real limit)
524 if( getSense() == SPxLP::MAXIMIZE )
526 SCIPdebugMessage(
"setting termination value from <%g> to <%g>\n", m_objLoLimit, limit);
527 SPxSolver::setTerminationValue(limit);
529 m_objLoLimit = limit;
532 Real getObjUpLimit()
const 537 void setObjUpLimit(Real limit)
539 if( getSense() == SPxLP::MINIMIZE )
541 SCIPdebugMessage(
"setting termination value from <%g> to <%g>\n", m_objUpLimit, limit);
542 SPxSolver::setTerminationValue(limit);
544 m_objUpLimit = limit;
547 void setRep(SPxSolver::Representation p_rep)
551 SCIPdebugMessage(
"switching to %s representation of the basis\n", p_rep == SPxSolver::ROW ?
"row" :
"column");
552 SPxSolver::setRep(p_rep);
557 bool getDoubleCheck()
560 return m_doublecheck && m_checknum + 1 >= CHECK_START;
563 void setDoubleCheck(
bool dc)
568 const char* spxStatusString(
const SPxSolver::Status stat)
572 case SPxSolver::ABORT_TIME:
574 case SPxSolver::ABORT_ITER:
576 case SPxSolver::ABORT_VALUE:
577 return "ABORT_VALUE";
578 case SPxSolver::SINGULAR:
580 case SPxSolver::REGULAR:
584 case SPxSolver::OPTIMAL:
586 case SPxSolver::UNBOUNDED:
588 case SPxSolver::INFEASIBLE:
597 const char* cpxStatusString(
const int stat)
601 case CPX_STAT_ABORT_TIME_LIM:
603 case CPX_STAT_ABORT_IT_LIM:
605 case CPX_STAT_ABORT_OBJ_LIM:
606 return "ABORT_VALUE";
607 case CPX_STAT_OPTIMAL:
609 case CPX_STAT_OPTIMAL_INFEAS:
610 return "CPX_STAT_OPTIMAL_INFEAS: OPT SOL INFEASIBLE AFTER UNSCALING";
611 case CPX_STAT_UNBOUNDED:
613 case CPX_STAT_INFEASIBLE:
615 case CPX_STAT_INForUNBD:
616 return "INFEASIBLE or UNBOUNDED";
617 case CPX_STAT_NUM_BEST:
618 return "CPX_STAT_NUM_BEST: SOL AVAILABLE BUT NOT PROVEN OPTIMAL DUE TO NUM TROUBLE";
628 bool checkConsistentBounds()
const 630 for(
int i = 0; i < nCols(); ++i )
632 if( lower(i) > upper(i) + Param::epsilon() )
634 SCIPerrorMessage(
"inconsistent bounds on column %d: lower=%.17g, upper=%.17g\n",
635 i, lower(i), upper(i));
643 bool checkConsistentSides()
const 645 for(
int i = 0; i < nRows(); ++i )
647 if( lhs(i) > rhs(i) + Param::epsilon() )
659 void trySolve(
bool printwarning =
true)
665 m_stat = SPxSolver::solve();
667 catch(
const SPxException& x )
669 std::string s = x.what();
674 m_stat = SPxSolver::status();
680 assert( m_stat != SPxSolver::OPTIMAL );
684 m_itused += SPxSolver::iterations();
685 assert(m_itlim < 0 || m_itused <= m_itlim);
688 timespent = SPxSolver::time();
692 timelimit = SPxSolver::terminationTime();
693 if( timelimit > timespent )
694 timelimit -= timespent;
698 assert(timelimit >= 0);
699 SPxSolver::setTerminationTime(timelimit);
703 void doSolve(
bool printwarning =
true)
706 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 707 SPxOut::Verbosity verbosity;
708 verbosity = m_spxout.getVerbosity();
709 m_spxout.setVerbosity(getLpInfo() ? (SPxOut::Verbosity)
SOPLEX_VERBLEVEL : (SPxOut::Verbosity) 0);
712 verbosity = Param::verbose();
716 assert(checkConsistentBounds());
717 assert(checkConsistentSides());
721 if( getDoubleCheck() )
726 setTerminationIter(m_autopricing && (m_itlim < 0 || m_itlim - m_itused >
AUTOPRICING_ITERSWITCH) ? AUTOPRICING_ITERSWITCH : m_itlim - m_itused);
728 trySolve(printwarning);
730 if( m_autopricing && m_stat == SPxSolver::ABORT_ITER && (m_itlim < 0 || m_itlim - m_itused > 0) )
732 setTerminationIter(m_itlim - m_itused);
733 setPricer(&m_price_steep_ex);
735 trySolve(printwarning);
737 setPricer(&m_price_devex);
741 setTerminationIter(m_itlim);
743 if( m_stat == OPTIMAL )
745 Real objval = value();
747 if( (objval > m_objUpLimit) || (objval < m_objLoLimit) )
748 m_stat = ABORT_VALUE;
753 if( getDoubleCheck() && (m_stat == SPxSolver::OPTIMAL || m_stat == SPxSolver::UNBOUNDED || m_stat == SPxSolver::INFEASIBLE || m_stat == SPxSolver::ABORT_VALUE) )
759 CPX_CALL( CPXreadcopyprob(m_cpxenv, m_cpxlp,
"spxcheck.mps",
NULL) );
760 CPX_CALL( CPXreadcopybase(m_cpxenv, m_cpxlp,
"spxcheck.bas") );
763 CPX_CALL( CPXsetdblparam(m_cpxenv, CPX_PARAM_EPOPT,
MAX(opttol(), 1e-9)) );
764 CPX_CALL( CPXsetdblparam(m_cpxenv, CPX_PARAM_EPRHS,
MAX(feastol(), 1e-9)) );
767 CPX_CALL( CPXlpopt(m_cpxenv, m_cpxlp) );
770 CPX_CALL( CPXsolution(m_cpxenv, m_cpxlp, &cpxstat, &cpxobj,
NULL,
NULL,
NULL,
NULL) );
771 if( getSense() == SPxLP::MAXIMIZE )
775 if( cpxstat == CPX_STAT_OPTIMAL_INFEAS )
777 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s)\n",
778 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat));
779 if( EXIT_AT_CPXERROR )
782 else if( (m_stat == SPxSolver::OPTIMAL && cpxstat != CPX_STAT_OPTIMAL)
783 || (m_stat == SPxSolver::UNBOUNDED && cpxstat != CPX_STAT_UNBOUNDED)
784 || (m_stat == SPxSolver::INFEASIBLE && cpxstat != CPX_STAT_INFEASIBLE) )
786 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
787 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat), m_checknum);
788 if( EXIT_AT_WRONG_RESULT )
791 else if( m_stat == SPxSolver::ABORT_VALUE )
795 case CPX_STAT_OPTIMAL:
796 if( (getSense() == SPxSolver::MINIMIZE && LTrel(cpxobj, getObjUpLimit(), 2*opttol()))
797 || (getSense() == SPxSolver::MAXIMIZE && GTrel(cpxobj, getObjLoLimit(), 2*opttol())) )
799 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
800 m_probname, m_stat, spxStatusString(m_stat), cpxobj, getSense() == SPxSolver::MINIMIZE ?
"<" :
">",
801 getSense() == SPxSolver::MINIMIZE ? getObjUpLimit() : getObjLoLimit(), cpxStatusString(cpxstat), m_checknum);
802 if( EXIT_AT_WRONG_RESULT )
805 else if( (getSense() == SPxSolver::MINIMIZE && cpxobj < getObjUpLimit())
806 || (getSense() == SPxSolver::MAXIMIZE && cpxobj > getObjLoLimit()) )
808 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
809 m_probname, m_stat, spxStatusString(m_stat), cpxobj, getSense() == SPxSolver::MINIMIZE ?
"<" :
">",
810 getSense() == SPxSolver::MINIMIZE ? getObjUpLimit() : getObjLoLimit(), cpxStatusString(cpxstat), m_checknum);
813 case CPX_STAT_OPTIMAL_INFEAS:
814 case CPX_STAT_NUM_BEST:
815 if( (getSense() == SPxSolver::MINIMIZE && cpxobj < getObjUpLimit())
816 || (getSense() == SPxSolver::MAXIMIZE && cpxobj > getObjLoLimit()) )
818 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
819 m_probname, m_stat, spxStatusString(m_stat), cpxobj, getSense() == SPxSolver::MINIMIZE ?
"<" :
">",
820 getSense() == SPxSolver::MINIMIZE ? getObjUpLimit() : getObjLoLimit(), cpxStatusString(cpxstat), m_checknum);
823 case CPX_STAT_INFEASIBLE:
825 case CPX_STAT_UNBOUNDED:
826 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
827 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat), m_checknum);
828 if( EXIT_AT_WRONG_RESULT )
831 case CPX_STAT_INForUNBD:
833 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
834 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat), m_checknum);
839 else if( m_stat == SPxSolver::OPTIMAL )
841 if( (getSense() == SPxSolver::MINIMIZE && LTrel(value(), cpxobj, 2*opttol()))
842 || (getSense() == SPxSolver::MAXIMIZE && GTrel(value(), cpxobj, 2*opttol())) )
847 else if( (getSense() == SPxSolver::MINIMIZE && GTrel(value(), cpxobj, 2*opttol()))
848 || (getSense() == SPxSolver::MAXIMIZE && LTrel(value(), cpxobj, 2*opttol())) )
850 SCIPerrorMessage(
"In %s: LP optimal; SoPlex value=%.10f %s CPLEX value=%.10f suboptimal (checknum=%d)\n", value(),
851 m_probname, getSense() == SPxSolver::MINIMIZE ?
">" :
"<", cpxobj, m_checknum);
852 if( EXIT_AT_WRONG_RESULT )
862 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 863 m_spxout.setVerbosity(verbosity);
865 Param::setVerbose(verbosity);
870 virtual Status solve()
872 assert(m_sense == sense());
873 SPxEquiliSC* scaler =
NULL;
874 SPxMainSM* simplifier =
NULL;
876 SPxSimplifier::Result result = SPxSimplifier::OKAY;
879 if ( getFromScratch() )
885 catch(
const SPxException& x )
887 std::string s = x.what();
889 m_stat = SPxSolver::status();
890 assert( m_stat != SPxSolver::OPTIMAL );
894 assert(!getFromScratch() || getBasisStatus() == SPxBasis::NO_PROBLEM);
897 if( SPxSolver::getBasisStatus() == SPxBasis::NO_PROBLEM && (getScaling() > 0) && nCols() > 0 && nRows() > 0 )
899 spx_alloc(scaler, 1);
900 scaler =
new (scaler) SPxEquiliSC();
901 assert(scaler !=
NULL);
902 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 903 scaler->setOutstream(m_spxout);
907 if( SPxSolver::getBasisStatus() == SPxBasis::NO_PROBLEM && getPresolving() && nCols() > 0 && nRows() > 0 )
909 spx_alloc(simplifier, 1);
910 simplifier =
new (simplifier) SPxMainSM();
911 assert(simplifier !=
NULL);
915 if( scaler !=
NULL || simplifier !=
NULL )
916 origlp = SPxLP(*
this);
925 scaler->scale(*
this);
928 if( simplifier !=
NULL )
931 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 932 SPxOut::Verbosity verbosity;
933 verbosity = m_spxout.getVerbosity();
934 m_spxout.setVerbosity(getLpInfo() ? (SPxOut::Verbosity)
SOPLEX_VERBLEVEL : (SPxOut::Verbosity) 0);
937 verbosity = Param::verbose();
941 #ifdef WITH_BOUNDFLIPPING 942 result = simplifier->simplify(*
this, epsilon(), feastol(), opttol(),
true);
944 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 945 result = simplifier->simplify(*
this, epsilon(), feastol(), opttol());
947 result = simplifier->simplify(*
this, epsilon(), delta());
950 SCIPdebugMessage(
"simplifier ended with status %u (0: OKAY, 1: INFEASIBLE, 2: DUAL_INFEASIBLE, 3: UNBOUNDED, 4: VANISHED)\n", result);
953 if( result == SPxSimplifier::INFEASIBLE || result == SPxSimplifier::DUAL_INFEASIBLE )
955 SCIPdebugMessage(
"simplifier detected primal or dual infeasibility - reloading and solving unsimplified LP\n");
957 simplifier->~SPxMainSM();
958 spx_free(simplifier);
960 SPxSolver::loadLP(origlp);
966 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 201) 967 m_spxout.setVerbosity(verbosity);
969 Param::setVerbose(verbosity);
974 if( result != SPxSimplifier::VANISHED )
977 Real objlolimit = getObjLoLimit();
978 Real objuplimit = getObjUpLimit();
980 if( simplifier !=
NULL || scaler !=
NULL )
992 if( simplifier !=
NULL || scaler !=
NULL )
994 setObjLoLimit(objlolimit);
995 setObjUpLimit(objuplimit);
1000 if( m_stat != SPxSolver::OPTIMAL && simplifier !=
NULL )
1002 SCIPdebugMessage(
"presolved LP not optimal - reloading and solving original LP\n");
1004 simplifier->~SPxMainSM();
1005 spx_free(simplifier);
1007 SPxSolver::loadLP(origlp);
1014 if( scaler !=
NULL || simplifier !=
NULL )
1016 SPxSolver::VarStatus* cstat =
NULL;
1017 SPxSolver::VarStatus* rstat =
NULL;
1020 if( (simplifier ==
NULL || result != SPxSimplifier::VANISHED) && SPxSolver::getBasisStatus() >= SPxBasis::REGULAR )
1023 spx_alloc(rstat, nRows());
1024 spx_alloc(cstat, nCols());
1025 (void) SPxSolver::getBasis(rstat, cstat);
1029 if( simplifier !=
NULL && SPxSolver::getBasisStatus() >= SPxBasis::REGULAR )
1031 assert((result == SPxSimplifier::VANISHED) == (cstat ==
NULL));
1032 assert((result == SPxSimplifier::VANISHED) == (rstat ==
NULL));
1035 int ncols = result == SPxSimplifier::VANISHED ? 0 : nCols();
1036 int nrows = result == SPxSimplifier::VANISHED ? 0 : nRows();
1039 DVector primals(ncols);
1040 DVector duals(nrows);
1041 DVector slacks(nrows);
1042 DVector redcosts(ncols);
1043 if( result != SPxSimplifier::VANISHED )
1045 (void) SPxSolver::getPrimal(primals);
1046 (void) SPxSolver::getDual(duals);
1047 (void) SPxSolver::getSlacks(slacks);
1048 (void) SPxSolver::getRedCost(redcosts);
1055 simplifier->unsimplify(primals, duals, slacks, redcosts, rstat, cstat);
1057 catch(
const SPxException& x )
1059 std::string s = x.what();
1060 SCIPmessagePrintWarning(m_messagehdlr,
"SoPlex unsimplification unsuccessful; solving again without LP presolving (SoPlex says %s)\n",
1069 if( simplifier->isUnsimplified() )
1074 spx_alloc(rstat, origlp.nRows());
1075 spx_alloc(cstat, origlp.nCols());
1076 simplifier->getBasis(rstat, cstat);
1082 SPxSolver::loadLP(origlp);
1086 if( rstat !=
NULL && cstat !=
NULL )
1089 SPxSolver::setBasis(rstat, cstat);
1104 if( scaler !=
NULL )
1106 scaler->~SPxEquiliSC();
1109 if( simplifier !=
NULL )
1111 simplifier->~SPxMainSM();
1112 spx_free(simplifier);
1116 if( m_stat == OPTIMAL )
1118 Real objval = value();
1120 if( (objval > m_objUpLimit) || (objval < m_objLoLimit) )
1121 m_stat = ABORT_VALUE;
1128 void savePreStrongbranchingBasis()
1130 m_rowstat.reSize(nRows());
1131 m_colstat.reSize(nCols());
1135 m_stat = getBasis(m_rowstat.get_ptr(), m_colstat.get_ptr());
1138 catch(
const SPxException& x )
1140 std::string s = x.what();
1147 assert(m_stat != SPxSolver::OPTIMAL);
1150 catch(
const SPxException& )
1157 void restorePreStrongbranchingBasis()
1159 assert(m_rowstat.size() == nRows());
1160 assert(m_colstat.size() == nCols());
1164 setBasis(m_rowstat.get_const_ptr(), m_colstat.get_const_ptr());
1167 catch(
const SPxException& x )
1169 std::string s = x.what();
1172 catch(
const SPxException& )
1175 m_stat = SPxSolver::status();
1181 assert(m_stat != SPxSolver::OPTIMAL);
1186 void freePreStrongbranchingBasis()
1193 bool preStrongbranchingBasisFreed()
const 1195 return ((m_rowstat.size() == 0 ) && (m_colstat.size() == 0));
1199 DataArray<SPxSolver::VarStatus>& rowStat()
1205 DataArray<SPxSolver::VarStatus>& colStat()
1210 Status getStatus()
const 1215 Status updateStatus()
1217 m_stat = SPxSolver::status();
1221 bool isInitialized()
const 1223 return SPxSolver::isInitialized();
1226 int iterations()
const 1231 virtual void clear()
1234 freePreStrongbranchingBasis();
1235 m_stat = NO_PROBLEM;
1239 bool readLP(
const char* fname)
1243 if ( m_rownames != 0 )
1244 m_rownames->~NameSet();
1246 spx_alloc(m_colnames, 1);
1248 if ( m_colnames != 0 )
1249 m_colnames->~NameSet();
1251 spx_alloc(m_rownames, 1);
1253 m_rownames =
new (m_rownames) NameSet();
1254 m_colnames =
new (m_colnames) NameSet();
1256 if( SPxSolver::readFile(fname, m_rownames, m_colnames) )
1258 m_stat = NO_PROBLEM;
1272 int namestoragesize,
1276 assert( m_colnames !=
NULL );
1279 if ( namestoragesize == 0 )
1282 *storageleft = -m_colnames->memSize();
1286 NameSet* names = m_colnames;
1287 assert( names != 0 );
1288 int sizeleft = namestoragesize;
1289 char* s = namestorage;
1290 for (
int j = firstcol; j <= lastcol; ++j)
1292 const char* t = (*names)[j];
1293 colnames[j-firstcol] = s;
1294 while( *t !=
'\0' && sizeleft >= 0 )
1301 if ( sizeleft == 0 )
1303 *storageleft = namestoragesize - m_colnames->memSize();
1304 assert( *storageleft <= 0 );
1307 *storageleft = sizeleft;
1317 int namestoragesize,
1321 assert( m_rownames !=
NULL );
1324 if ( namestoragesize == 0 )
1327 *storageleft = -m_rownames->memSize();
1331 NameSet* names = m_rownames;
1332 assert( names != 0 );
1333 int sizeleft = namestoragesize;
1334 char* s = namestorage;
1335 for (
int i = firstrow; i <= lastrow; ++i)
1337 const char* t = (*names)[i];
1338 rownames[i-firstrow] = s;
1339 while( *t !=
'\0' && sizeleft >= 0 )
1346 if ( sizeleft == 0 )
1348 *storageleft = m_rownames->memSize() - namestoragesize;
1349 assert( *storageleft <= 0 );
1352 *storageleft = sizeleft;
1368 #define COLS_PER_PACKET SCIP_DUALPACKETSIZE 1370 #define ROWS_PER_PACKET SCIP_DUALPACKETSIZE 1384 SLUFactor* factorization;
1396 COLPACKET* packcstat;
1397 ROWPACKET* packrstat;
1420 assert(lpi !=
NULL);
1430 assert(num <= lpi->cstatsize);
1442 assert(lpi !=
NULL);
1452 assert(num <= lpi->rstatsize);
1490 assert(lpistate !=
NULL);
1506 assert(lpistate !=
NULL);
1523 assert(lpistate !=
NULL);
1524 assert(blkmem !=
NULL);
1545 assert(blkmem !=
NULL);
1546 assert(lpistate !=
NULL);
1547 assert(*lpistate !=
NULL);
1573 return SPxLP::MAXIMIZE;
1575 return SPxLP::MINIMIZE;
1579 return SPxLP::MINIMIZE;
1587 assert(lpi !=
NULL);
1620 #if (SOPLEX_SUBVERSION > 0) 1621 snprintf(spxname, 100,
"SoPlex1 %d.%d.%d.%d", SOPLEX_VERSION/100, (SOPLEX_VERSION % 100)/10, SOPLEX_VERSION % 10,
SOPLEX_SUBVERSION);
1623 snprintf(spxname, 100,
"SoPlex1 %d.%d.%d", SOPLEX_VERSION/100, (SOPLEX_VERSION % 100)/10, SOPLEX_VERSION % 10);
1633 #if (SOPLEX_VERSION >= 160) 1634 snprintf(spxdesc, 200,
"Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de) [GitHash: %s]" 1635 #ifdef WITH_LPSCHECK
1636 " - including CPLEX double check" 1640 snprintf(spxdesc, 200,
"Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de)" 1641 #ifdef WITH_LPSCHECK
1642 " - including CPLEX double check" 1654 return (
void*) lpi->
spx;
1664 #if (SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 221 && SOPLEX_SUBVERSION >= 3)) 1665 assert(ncols == lpi->
spx->nCols() || (ncols == 0 && intInfo ==
NULL));
1666 lpi->
spx->setIntegralityInformation(ncols, intInfo);
1669 SCIPerrorMessage(
"SCIPlpiSetIntegralityInformation() has not been implemented yet.\n");
1694 assert(lpi !=
NULL);
1701 SOPLEX_TRY( messagehdlr, (*lpi)->spx = new ((*lpi)->spx) SPxSCIP(messagehdlr, name) );
1702 (*lpi)->cstat =
NULL;
1703 (*lpi)->rstat =
NULL;
1704 (*lpi)->cstatsize = 0;
1705 (*lpi)->rstatsize = 0;
1707 (*lpi)->factorization = 0;
1709 (*lpi)->conditionlimit = -1.0;
1710 (*lpi)->checkcondition =
FALSE;
1711 (*lpi)->messagehdlr = messagehdlr;
1729 assert(lpi !=
NULL);
1730 assert(*lpi !=
NULL);
1731 assert((*lpi)->spx !=
NULL);
1734 (*lpi)->spx->~SPxSCIP();
1778 assert(lpi !=
NULL);
1780 assert(lhs !=
NULL);
1781 assert(rhs !=
NULL);
1784 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1788 SPxSCIP* spx = lpi->
spx;
1789 LPRowSet rows(nrows);
1790 DSVector emptyVector(0);
1799 for( i = 0; i < nrows; ++i )
1800 rows.add(lhs[i], emptyVector, rhs[i]);
1807 catch(
const SPxException& x )
1809 std::string s = x.what();
1812 catch(
const SPxException& )
1837 assert(lpi !=
NULL);
1839 assert(obj !=
NULL);
1842 assert(nnonz == 0 || beg !=
NULL);
1843 assert(nnonz == 0 || ind !=
NULL);
1844 assert(nnonz == 0 || val !=
NULL);
1850 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1856 int nrows = lpi->
spx->nRows();
1857 for (
int j = 0; j < nnonz; ++j)
1858 assert( 0 <= ind[j] && ind[j] < nrows );
1862 SPxSCIP* spx = lpi->
spx;
1865 LPColSet cols(ncols);
1866 DSVector colVector(ncols);
1872 for( i = 0; i < ncols; ++i )
1878 last = (i == ncols-1 ? nnonz : beg[i+1]);
1879 colVector.add( last-start, &ind[start], &val[start] );
1881 cols.add(obj[i], lb[i], colVector, ub[i]);
1886 catch(
const SPxException& x )
1888 std::string s = x.what();
1891 catch(
const SPxException& )
1909 assert(lpi !=
NULL);
1911 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
1915 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1935 assert(lpi !=
NULL);
1940 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1942 ncols = lpi->
spx->nCols();
1945 for( i = 0; i < ncols; ++i )
1968 assert(lpi !=
NULL);
1970 assert(lhs !=
NULL);
1971 assert(rhs !=
NULL);
1972 assert(nnonz == 0 || beg !=
NULL);
1973 assert(nnonz == 0 || ind !=
NULL);
1974 assert(nnonz == 0 || val !=
NULL);
1978 assert( lpi->
spx->preStrongbranchingBasisFreed() );
1984 int ncols = lpi->
spx->nCols();
1985 for (
int j = 0; j < nnonz; ++j)
1986 assert( 0 <= ind[j] && ind[j] < ncols );
1992 SPxSCIP* spx = lpi->
spx;
1993 LPRowSet rows(nrows);
2000 for( i = 0; i < nrows; ++i )
2006 last = (i == nrows-1 ? nnonz : beg[i+1]);
2007 rowVector.add( last-start, &ind[start], &val[start] );
2009 rows.add(lhs[i], rowVector, rhs[i]);
2014 catch(
const SPxException& x )
2016 std::string s = x.what();
2019 catch(
const SPxException& )
2037 assert(lpi !=
NULL);
2039 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
2043 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2063 assert(lpi !=
NULL);
2068 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2070 nrows = lpi->
spx->nRows();
2073 for( i = 0; i < nrows; ++i )
2088 assert(lpi !=
NULL);
2093 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2112 assert(lpi !=
NULL);
2114 assert(ind !=
NULL);
2120 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2124 for( i = 0; i < ncols; ++i )
2126 assert(0 <= ind[i] && ind[i] < lpi->
spx->nCols());
2130 SCIPerrorMessage(
"LP Error: fixing lower bound for variable %d to infinity.\n", ind[i]);
2135 SCIPerrorMessage(
"LP Error: fixing upper bound for variable %d to -infinity.\n", ind[i]);
2139 lpi->
spx->changeBounds(ind[i], lb[i], ub[i]);
2140 assert(lpi->
spx->lower(ind[i]) <= lpi->
spx->upper(ind[i]) + Param::epsilon());
2144 catch(
const SPxException& x )
2146 std::string s = x.what();
2149 catch(
const SPxException& )
2171 assert(lpi !=
NULL);
2173 assert(ind !=
NULL);
2174 assert(lhs !=
NULL);
2175 assert(rhs !=
NULL);
2179 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2183 for( i = 0; i < nrows; ++i )
2185 assert(0 <= ind[i] && ind[i] < lpi->
spx->nRows());
2186 lpi->
spx->changeRange(ind[i], lhs[i], rhs[i]);
2187 assert(lpi->
spx->lhs(ind[i]) <= lpi->
spx->rhs(ind[i]) + Param::epsilon());
2191 catch(
const SPxException& x )
2193 std::string s = x.what();
2196 catch(
const SPxException& )
2215 assert(lpi !=
NULL);
2217 assert(0 <= row && row < lpi->spx->nRows());
2218 assert(0 <= col && col < lpi->spx->nCols());
2222 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2237 assert(lpi !=
NULL);
2242 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2261 assert(lpi !=
NULL);
2263 assert(ind !=
NULL);
2264 assert(obj !=
NULL);
2268 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2272 for( i = 0; i < ncols; ++i )
2274 assert(0 <= ind[i] && ind[i] < lpi->
spx->nCols());
2275 lpi->
spx->changeObj(ind[i], obj[i]);
2279 catch(
const SPxException& x )
2281 std::string s = x.what();
2284 catch(
const SPxException& )
2305 assert(lpi !=
NULL);
2307 assert(scaleval != 0.0);
2313 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2316 SVector rowvec = lpi->
spx->rowVector(row);
2317 lhs = lpi->
spx->lhs(row);
2318 rhs = lpi->
spx->rhs(row);
2326 else if( scaleval < 0.0 )
2330 else if( scaleval < 0.0 )
2332 if( scaleval < 0.0 )
2340 LPRow lprow(lhs, rowvec, rhs);
2343 lpi->
spx->changeRow(row, lprow);
2344 assert(lpi->
spx->lhs(row) <= lpi->
spx->rhs(row));
2347 catch(
const SPxException& x )
2349 std::string s = x.what();
2352 catch(
const SPxException& )
2376 assert(lpi !=
NULL);
2378 assert(scaleval != 0.0);
2384 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2387 SVector colvec = lpi->
spx->colVector(col);
2388 obj = lpi->
spx->obj(col);
2389 lb = lpi->
spx->lower(col);
2390 ub = lpi->
spx->upper(col);
2401 else if( scaleval < 0.0 )
2405 else if( scaleval < 0.0 )
2407 if( scaleval < 0.0 )
2415 LPCol lpcol(obj, colvec, ub, lb);
2418 lpi->
spx->changeCol(col, lpcol);
2419 assert(lpi->
spx->lower(col) <= lpi->
spx->upper(col));
2422 catch(
const SPxException& x )
2424 std::string s = x.what();
2427 catch(
const SPxException& )
2456 assert(lpi !=
NULL);
2458 assert(nrows !=
NULL);
2460 *nrows = lpi->
spx->nRows();
2473 assert(lpi !=
NULL);
2475 assert(ncols !=
NULL);
2477 *ncols = lpi->
spx->nCols();
2492 assert(lpi !=
NULL);
2494 assert(nnonz !=
NULL);
2498 if( lpi->
spx->nRows() < lpi->
spx->nCols() )
2500 for( i = 0; i < lpi->
spx->nRows(); ++i )
2501 (*nnonz) += lpi->
spx->rowVector(i).size();
2505 for( i = 0; i < lpi->
spx->nCols(); ++i )
2506 (*nnonz) += lpi->
spx->colVector(i).size();
2533 assert(lpi !=
NULL);
2535 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2541 const Vector& lbvec = lpi->
spx->lower();
2542 const Vector& ubvec = lpi->
spx->upper();
2543 for( i = firstcol; i <= lastcol; ++i )
2545 lb[i-firstcol] = lbvec[i];
2546 ub[i-firstcol] = ubvec[i];
2555 for( i = firstcol; i <= lastcol; ++i )
2557 beg[i-firstcol] = *nnonz;
2558 const SVector& cvec = lpi->
spx->colVector(i);
2559 for( j = 0; j < cvec.size(); ++j )
2561 ind[*nnonz] = cvec.index(j);
2562 val[*nnonz] = cvec.value(j);
2569 assert(beg ==
NULL);
2570 assert(ind ==
NULL);
2571 assert(val ==
NULL);
2598 assert(lpi !=
NULL);
2600 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
2604 assert(rhs !=
NULL);
2606 const Vector& lhsvec = lpi->
spx->lhs();
2607 const Vector& rhsvec = lpi->
spx->rhs();
2608 for( i = firstrow; i <= lastrow; ++i )
2610 lhs[i-firstrow] = lhsvec[i];
2611 rhs[i-firstrow] = rhsvec[i];
2615 assert(rhs ==
NULL);
2620 for( i = firstrow; i <= lastrow; ++i )
2622 beg[i-firstrow] = *nnonz;
2623 const SVector& rvec = lpi->
spx->rowVector(i);
2624 for( j = 0; j < rvec.size(); ++j )
2626 ind[*nnonz] = rvec.index(j);
2627 val[*nnonz] = rvec.value(j);
2634 assert(beg ==
NULL);
2635 assert(ind ==
NULL);
2636 assert(val ==
NULL);
2649 int namestoragesize,
2653 assert( lpi !=
NULL );
2655 assert( colnames !=
NULL || namestoragesize == 0 );
2656 assert( namestorage !=
NULL || namestoragesize == 0 );
2657 assert( namestoragesize >= 0 );
2658 assert( storageleft !=
NULL );
2659 assert( 0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols() );
2663 lpi->
spx->getColNames(firstcol, lastcol, colnames, namestorage, namestoragesize, storageleft);
2675 int namestoragesize,
2679 assert( lpi !=
NULL );
2681 assert( rownames !=
NULL || namestoragesize == 0 );
2682 assert( namestorage !=
NULL || namestoragesize == 0 );
2683 assert( namestoragesize >= 0 );
2684 assert( storageleft !=
NULL );
2685 assert( 0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows() );
2689 lpi->
spx->getRowNames(firstrow, lastrow, rownames, namestorage, namestoragesize, storageleft);
2702 assert(lpi !=
NULL);
2704 assert(objsen !=
NULL);
2723 assert(lpi !=
NULL);
2725 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2726 assert(vals !=
NULL);
2728 for( i = firstcol; i <= lastcol; ++i )
2729 vals[i-firstcol] = lpi->
spx->obj(i);
2747 assert(lpi !=
NULL);
2749 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2751 for( i = firstcol; i <= lastcol; ++i )
2754 lbs[i-firstcol] = lpi->
spx->lower(i);
2756 ubs[i-firstcol] = lpi->
spx->upper(i);
2775 assert(lpi !=
NULL);
2777 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
2779 for( i = firstrow; i <= lastrow; ++i )
2782 lhss[i-firstrow] = lpi->
spx->lhs(i);
2784 rhss[i-firstrow] = lpi->
spx->rhs(i);
2800 assert(lpi !=
NULL);
2802 assert(0 <= col && col < lpi->spx->nCols());
2803 assert(0 <= row && row < lpi->spx->nRows());
2804 assert(val !=
NULL);
2806 *val = lpi->
spx->colVector(col)[row];
2827 SPxSolver::Representation rep,
2831 assert( lpi !=
NULL );
2833 assert( rep == SPxSolver::ROW || rep == SPxSolver::COLUMN );
2834 assert( type == SPxSolver::ENTER || type == SPxSolver::LEAVE );
2836 SCIPdebugMessage(
"calling SoPlex solve(): %d cols, %d rows, rep=%s\n", lpi->
spx->nCols(), lpi->
spx->nRows(),
2837 rep == SPxSolver::COLUMN ?
"column" :
"row");
2841 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2844 lpi->
spx->setRep(rep);
2845 lpi->
spx->setType(type);
2847 #ifdef WITH_LPSCHECK 2848 lpi->
spx->setDoubleCheck(CHECK_SPXSOLVE);
2851 SPxSolver::Status status = lpi->
spx->solve();
2852 SCIPdebugMessage(
" -> SoPlex status: %d, basis status: %d\n", lpi->
spx->getStatus(), lpi->
spx->basis().status());
2857 case SPxSolver::ABORT_TIME:
2858 case SPxSolver::ABORT_ITER:
2859 case SPxSolver::ABORT_VALUE:
2860 case SPxSolver::SINGULAR:
2861 case SPxSolver::REGULAR:
2863 case SPxSolver::OPTIMAL:
2864 case SPxSolver::UNBOUNDED:
2865 case SPxSolver::INFEASIBLE:
2882 assert(lpi !=
NULL);
2889 rowrep = lpi->
spx->rep() == SPxSolver::ROW;
2909 retcode = rowrep ?
spxSolve(lpi, SPxSolver::ROW, SPxSolver::LEAVE) :
spxSolve(lpi, SPxSolver::COLUMN, SPxSolver::ENTER);
2910 assert(!rowrep || lpi->
spx->rep() == SPxSolver::ROW);
2911 assert(rowrep || lpi->
spx->rep() == SPxSolver::COLUMN);
2926 assert(lpi !=
NULL);
2933 rowrep = lpi->
spx->rep() == SPxSolver::ROW;
2953 retcode = rowrep ?
spxSolve(lpi, SPxSolver::ROW, SPxSolver::ENTER) :
spxSolve(lpi, SPxSolver::COLUMN, SPxSolver::LEAVE);
2954 assert(!rowrep || lpi->
spx->rep() == SPxSolver::ROW);
2955 assert(rowrep || lpi->
spx->rep() == SPxSolver::COLUMN);
2978 assert( lpi->
spx->preStrongbranchingBasisFreed() );
2979 lpi->
spx->savePreStrongbranchingBasis();
2989 assert( ! lpi->
spx->preStrongbranchingBasisFreed() );
2990 lpi->
spx->restorePreStrongbranchingBasis();
2991 lpi->
spx->freePreStrongbranchingBasis();
3013 SPxSolver::Status status;
3018 bool fromparentbasis;
3022 SCIPdebugMessage(
"calling SCIPlpiStrongbranch() on variable %d (%d iterations)\n", col, itlim);
3024 assert(lpi !=
NULL);
3028 assert(downvalid !=
NULL);
3029 assert(upvalid !=
NULL);
3033 fromparentbasis =
false;
3035 oldItlim = spx->getIterationLimit();
3038 oldlb = spx->lower(col);
3039 oldub = spx->upper(col);
3048 lpi->
spx->setType( lpi->
spx->rep() == SPxSolver::ROW ? SPxSolver::ENTER : SPxSolver::LEAVE);
3051 newub =
EPSCEIL(psol-1.0, lpi->
spx->feastol());
3052 if( newub >= oldlb - 0.5 && down !=
NULL )
3054 SCIPdebugMessage(
"strong branching down on x%d (%g) with %d iterations\n", col, psol, itlim);
3056 spx->changeUpper(col, newub);
3057 assert(spx->lower(col) <= spx->upper(col));
3059 spx->setIterationLimit(itlim);
3062 #ifdef WITH_LPSCHECK 3063 spx->setDoubleCheck(CHECK_SPXSTRONGBRANCH);
3065 status = spx->solve();
3069 case SPxSolver::OPTIMAL:
3070 *down = spx->value();
3074 case SPxSolver::ABORT_TIME:
3075 case SPxSolver::ABORT_ITER:
3076 case SPxSolver::ABORT_CYCLING:
3077 *down = spx->value();
3079 case SPxSolver::ABORT_VALUE:
3080 case SPxSolver::INFEASIBLE:
3081 *down = spx->terminationValue();
3089 (*iter) += spx->iterations();
3091 #ifdef STRONGBRANCH_RESTOREBASIS 3093 assert( ! spx->preStrongbranchingBasisFreed() );
3094 spx->restorePreStrongbranchingBasis();
3095 fromparentbasis =
false;
3099 if( (status == SPxSolver::ABORT_CYCLING || status == SPxSolver::SINGULAR) && !fromparentbasis && spx->iterations() < itlim )
3101 SCIPdebugMessage(
" --> Repeat strong branching down with %d iterations after restoring basis\n", itlim - spx->iterations());
3102 spx->setIterationLimit(itlim - spx->iterations());
3103 assert( ! spx->hasPreStrongbranchingBasis() );
3104 spx->restorePreStrongbranchingBasis();
3105 fromparentbasis =
true;
3110 fromparentbasis =
false;
3113 while( fromparentbasis );
3115 spx->changeUpper(col, oldub);
3116 assert(spx->lower(col) <= spx->upper(col));
3118 else if( down !=
NULL )
3120 *down = spx->terminationValue();
3130 if( newlb <= oldub + 0.5 && up !=
NULL )
3132 SCIPdebugMessage(
"strong branching up on x%d (%g) with %d iterations\n", col, psol, itlim);
3134 spx->changeLower(col, newlb);
3135 assert(spx->lower(col) <= spx->upper(col));
3137 spx->setIterationLimit(itlim);
3140 #ifdef WITH_LPSCHECK 3141 spx->setDoubleCheck(CHECK_SPXSTRONGBRANCH);
3143 status = spx->solve();
3147 case SPxSolver::OPTIMAL:
3152 case SPxSolver::ABORT_TIME:
3153 case SPxSolver::ABORT_ITER:
3154 case SPxSolver::ABORT_CYCLING:
3157 case SPxSolver::ABORT_VALUE:
3158 case SPxSolver::INFEASIBLE:
3159 *up = spx->terminationValue();
3167 (*iter) += spx->iterations();
3169 #ifdef STRONGBRANCH_RESTOREBASIS 3171 assert( ! spx->preStrongbranchingBasisFreed() );
3172 spx->restorePreStrongbranchingBasis();
3173 fromparentbasis =
false;
3177 else if( (status == SPxSolver::ABORT_CYCLING || status == SPxSolver::SINGULAR) && !fromparentbasis && spx->iterations() < itlim )
3179 SCIPdebugMessage(
" --> Repeat strong branching up with %d iterations after restoring basis\n", itlim - spx->iterations());
3180 assert( ! spx->hasPreStrongbranchingBasis() );
3181 spx->restorePreStrongbranchingBasis();
3182 spx->setIterationLimit(itlim - spx->iterations());
3184 fromparentbasis =
true;
3188 fromparentbasis =
false;
3191 while( fromparentbasis );
3193 spx->changeLower(col, oldlb);
3194 assert(spx->lower(col) <= spx->upper(col));
3196 else if( up !=
NULL )
3198 *up = spx->terminationValue();
3206 spx->setIterationLimit(oldItlim);
3210 SCIPdebugMessage(
"SCIPlpiStrongbranch() returned SoPlex status %d\n",
int(status));
3235 retcode =
lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter);
3265 assert( cols !=
NULL );
3266 assert( psols !=
NULL );
3267 assert( down !=
NULL );
3268 assert( up !=
NULL );
3269 assert( downvalid !=
NULL );
3270 assert( upvalid !=
NULL );
3271 assert( down !=
NULL );
3276 for (
int j = 0; j < ncols; ++j)
3279 retcode =
lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter);
3309 retcode =
lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter);
3339 assert( cols !=
NULL );
3340 assert( psols !=
NULL );
3341 assert( down !=
NULL );
3342 assert( up !=
NULL );
3343 assert( downvalid !=
NULL );
3344 assert( upvalid !=
NULL );
3345 assert( down !=
NULL );
3350 for (
int j = 0; j < ncols; ++j)
3353 retcode =
lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter);
3382 assert(lpi !=
NULL);
3396 assert(lpi !=
NULL);
3397 assert(primalfeasible !=
NULL);
3398 assert(dualfeasible !=
NULL);
3415 assert(lpi !=
NULL);
3418 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED);
3430 assert(lpi !=
NULL);
3433 #if ((SOPLEX_VERSION == 150 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 150) 3434 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED);
3447 assert(lpi !=
NULL);
3450 assert(lpi->
spx->getStatus() != SPxSolver::UNBOUNDED || lpi->
spx->basis().status() == SPxBasis::UNBOUNDED);
3455 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED && !lpi->
spx->isPerturbed());
3465 assert(lpi !=
NULL);
3468 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE);
3476 SPxBasis::SPxStatus basestatus;
3480 assert(lpi !=
NULL);
3483 basestatus = lpi->
spx->basis().status();
3488 assert(basestatus == SPxBasis::OPTIMAL || lpi->
spx->getStatus() != SPxSolver::OPTIMAL);
3490 return basestatus == SPxBasis::OPTIMAL ||
3491 ((basestatus == SPxBasis::PRIMAL || basestatus == SPxBasis::UNBOUNDED) && !lpi->
spx->isPerturbed());
3503 assert(lpi !=
NULL);
3506 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE);
3518 assert(lpi !=
NULL);
3521 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE);
3531 assert(lpi !=
NULL);
3534 return (lpi->
spx->getStatus() == SPxSolver::INFEASIBLE && lpi->
spx->basis().status() == SPxBasis::DUAL
3535 && !lpi->
spx->isPerturbed());
3545 assert(lpi !=
NULL);
3548 return (lpi->
spx->getStatus() == SPxSolver::UNBOUNDED);
3558 assert(lpi !=
NULL);
3564 assert(lpi->
spx->basis().status() == SPxBasis::OPTIMAL || lpi->
spx->getStatus() != SPxSolver::OPTIMAL);
3566 return (lpi->
spx->basis().status() == SPxBasis::OPTIMAL) ||
3567 (lpi->
spx->basis().status() == SPxBasis::DUAL && !lpi->
spx->isPerturbed());
3577 assert(lpi !=
NULL);
3578 assert((lpi->
spx->basis().status() == SPxBasis::OPTIMAL)
3584 return (lpi->
spx->basis().status() == SPxBasis::OPTIMAL);
3594 assert(lpi !=
NULL);
3597 #if ((SOPLEX_VERSION == 172 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 172) 3620 return (lpi->
spx->getStatus() != SPxSolver::ERROR && lpi->
spx->getStatus() != SPxSolver::SINGULAR);
3630 assert(lpi !=
NULL);
3633 return (lpi->
spx->getStatus() == SPxSolver::ABORT_VALUE);
3643 assert(lpi !=
NULL);
3646 return (lpi->
spx->getStatus() == SPxSolver::ABORT_ITER);
3656 assert(lpi !=
NULL);
3659 return (lpi->
spx->getStatus() == SPxSolver::ABORT_TIME);
3669 assert(lpi !=
NULL);
3672 return static_cast<int>(lpi->
spx->getStatus());
3683 assert(lpi !=
NULL);
3700 assert(lpi !=
NULL);
3702 assert(objval !=
NULL);
3704 *objval = lpi->
spx->value();
3721 assert(lpi !=
NULL);
3724 if( objval !=
NULL )
3725 *objval = lpi->
spx->value();
3729 if( primsol !=
NULL )
3731 Vector tmp(lpi->
spx->nCols(), primsol);
3732 (void)lpi->
spx->getPrimal(tmp);
3734 if( dualsol !=
NULL )
3736 Vector tmp(lpi->
spx->nRows(), dualsol);
3737 (void)lpi->
spx->getDual(tmp);
3739 if( activity !=
NULL )
3741 Vector tmp(lpi->
spx->nRows(), activity);
3742 (void)lpi->
spx->getSlacks(tmp);
3744 if( redcost !=
NULL )
3746 Vector tmp(lpi->
spx->nCols(), redcost);
3747 (void)lpi->
spx->getRedCost(tmp);
3751 catch(
const SPxException& x )
3753 std::string s = x.what();
3756 catch(
const SPxException& )
3773 assert(lpi !=
NULL);
3776 #if ((SOPLEX_VERSION == 150 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 150) 3779 Vector tmp(lpi->
spx->nCols(), ray);
3780 (void)lpi->
spx->getPrimalray(tmp);
3783 catch(
const SPxException& x )
3785 std::string s = x.what();
3788 catch(
const SPxException& )
3796 SCIPerrorMessage(
"SCIPlpiGetPrimalRay() not supported by SoPlex versions <= 1.5.0\n");
3809 assert(lpi !=
NULL);
3814 Vector tmp(lpi->
spx->nRows(), dualfarkas);
3815 (void)lpi->
spx->getDualfarkas(tmp);
3818 catch(
const SPxException& x )
3820 std::string s = x.what();
3823 catch(
const SPxException& )
3840 assert(lpi !=
NULL);
3843 *iterations = lpi->
spx->iterations();
3861 assert(lpi !=
NULL);
3862 assert(quality !=
NULL);
3864 #if ((SOPLEX_VERSION == 172 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 172) 3868 assert(lpi !=
NULL);
3869 assert(quality !=
NULL);
3871 SCIPdebugMessage(
"requesting solution quality from SoPlex: quality %d\n", qualityindicator);
3873 switch( qualityindicator )
3890 *quality = lpi->
spx->basis().condition(maxiter, tolerance);
3913 assert( spx !=
NULL );
3920 if (! spx->isInitialized() )
3923 assert( 0 <= col && col < spx->nCols() );
3925 if( spx->rep() == SPxSolver::COLUMN )
3928 if (spx->getSense() == SPxLP::MINIMIZE)
3929 *val = spx->pVec()[col] - spx->maxObj()[col];
3931 *val = spx->maxObj()[col] - spx->pVec()[col];
3935 assert( spx->rep() == SPxSolver::ROW );
3938 #ifdef SCIP_DISABLED_CODE 3941 if ( spx->getSense() == SPxLP::MINIMIZE )
3944 if ( spx->isColBasic(col) )
3947 for (
int i = spx->dim() - 1; i >= 0; --i)
3949 SPxId
id = spx->basis().baseId(i);
3950 if (
id.isSPxColId() && col == spx->number(SPxColId(
id)) )
3952 *val = sign * spx->fVec()[i];
3976 assert(lpi !=
NULL);
3979 assert( lpi->
spx->preStrongbranchingBasisFreed() );
3983 for( i = 0; i < lpi->
spx->nRows(); ++i )
3985 switch( lpi->
spx->getBasisRowStatus(i) )
3987 case SPxSolver::BASIC:
3990 case SPxSolver::FIXED:
3991 case SPxSolver::ON_LOWER:
3994 case SPxSolver::ON_UPPER:
3997 case SPxSolver::ZERO:
3998 SCIPerrorMessage(
"slack variable has basis status ZERO (should not occur)\n");
4000 case SPxSolver::UNDEFINED:
4011 for( i = 0; i < lpi->
spx->nCols(); ++i )
4014 switch( lpi->
spx->getBasisColStatus(i) )
4016 case SPxSolver::BASIC:
4019 case SPxSolver::FIXED:
4031 case SPxSolver::ON_LOWER:
4034 case SPxSolver::ON_UPPER:
4037 case SPxSolver::ZERO:
4040 case SPxSolver::UNDEFINED:
4060 int nCols = lpi->
spx->nCols();
4061 int nRows = lpi->
spx->nRows();
4065 assert(lpi !=
NULL);
4067 assert(cstat !=
NULL || nCols == 0);
4068 assert(rstat !=
NULL || nRows == 0);
4070 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4073 DataArray<SPxSolver::VarStatus>& m_colstat = lpi->
spx->colStat();
4074 DataArray<SPxSolver::VarStatus>& m_rowstat = lpi->
spx->rowStat();
4076 m_colstat.reSize(nCols);
4077 m_rowstat.reSize(nRows);
4079 for( i = 0; i < nRows; ++i )
4081 assert( rstat != 0 );
4085 m_rowstat[i] = SPxSolver::ON_LOWER;
4088 m_rowstat[i] = SPxSolver::BASIC;
4091 m_rowstat[i] = SPxSolver::ON_UPPER;
4094 SCIPerrorMessage(
"slack variable has basis status ZERO (should not occur)\n");
4103 for( i = 0; i < nCols; ++i )
4105 assert( cstat != 0 );
4109 m_colstat[i] = SPxSolver::ON_LOWER;
4112 m_colstat[i] = SPxSolver::BASIC;
4115 m_colstat[i] = SPxSolver::ON_UPPER;
4118 m_colstat[i] = SPxSolver::ZERO;
4128 (void) lpi->
spx->updateStatus();
4130 lpi->
spx->freePreStrongbranchingBasis();
4145 assert(lpi !=
NULL);
4148 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4156 if( spx->rep() == SPxSolver::COLUMN )
4158 for(
int i = 0; i < spx->nRows(); ++i )
4160 SPxId
id = spx->basis().baseId(i);
4162 bind[i] = (
id.isSPxColId() ? spx->number(
id) : - 1 - spx->number(
id));
4169 int nrows = spx->nRows();
4170 int ncols = spx->nCols();
4172 assert( spx->rep() == SPxSolver::ROW );
4174 for(
int i = 0; i < nrows; ++i )
4176 if( !spx->isRowBasic(i) )
4184 for(
int j = 0; j < ncols && k < nrows; ++j )
4186 if( !spx->isColBasic(j) )
4203 SCIPdebugMessage(
"Preparing factorization for computation of basis inverse.\n");
4213 DataArray <const SVector*> matrix(spx->nRows());
4216 for (
int i = 0; i < spx->nRows(); ++i)
4218 if ( ! spx->isRowBasic(i) )
4219 matrix[k++] =
new UnitVector(i);
4221 for (
int j = 0; j < spx->nCols(); ++j)
4223 if ( ! spx->isColBasic(j) )
4224 matrix[k++] = &spx->colVector(j);
4226 assert( k == spx->nRows() );
4227 assert( k == matrix.size() );
4232 SLinSolver::Status status = lpi->
factorization->load(matrix.get_ptr(), k);
4236 assert( status == SLinSolver::OK );
4241 for (
int i = 0; i < spx->nRows(); ++i)
4243 if ( ! spx->isRowBasic(i) )
4249 catch(
const SPxException& x )
4251 std::string s = x.what();
4254 catch(
const SPxException& )
4281 assert( lpi !=
NULL );
4283 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4285 int nCols = lpi->
spx->nCols();
4286 int nRows = lpi->
spx->nRows();
4296 if ( spx->rep() == SPxSolver::COLUMN )
4299 spx->basis().coSolve(x, spx->unitVector(r));
4302 if( ninds !=
NULL && inds !=
NULL )
4308 for(
int i = 0; i < *ninds; ++i )
4319 Vector y(nRows, coef);
4327 assert(spx->rep() == SPxSolver::ROW);
4344 Vector x(nRows, coef);
4346 DSVector rhs(nCols);
4368 assert(idx < nRows);
4369 assert(!spx->isRowBasic(idx));
4372 rhs = spx->rowVector(idx);
4379 assert(idx < nCols);
4380 assert(!spx->isColBasic(idx));
4383 rhs = spx->unitVector(idx);
4387 spx->basis().solve(y, rhs);
4393 for(
int i = 0; i < nCols; ++i )
4395 SPxId
id = spx->basis().baseId(i);
4397 if(
id.isSPxRowId() )
4399 assert(spx->number(
id) >= 0);
4400 assert(spx->number(
id) < nRows);
4401 assert(bind[r] >= 0 || spx->number(
id) != idx);
4403 x[spx->number(
id)] = y[i];
4410 assert(x[idx] == 0.0);
4424 catch(
const SPxException& x )
4426 std::string s = x.what();
4429 catch(
const SPxException& )
4448 assert(lpi !=
NULL);
4450 assert(lpi->
spx->preStrongbranchingBasisFreed());
4451 assert(rhs !=
NULL);
4452 assert(coef !=
NULL);
4454 int nCols = lpi->
spx->nCols();
4455 int nRows = lpi->
spx->nRows();
4460 Vector v(nRows, rhs);
4461 Vector x(nRows, coef);
4464 if( spx->rep() == SPxSolver::COLUMN )
4467 spx->basis().solve(x, v);
4471 assert(spx->rep() == SPxSolver::ROW);
4482 DSVector rowrhs(nCols);
4494 for(
int i = 0; i < nCols; ++i )
4496 SPxId
id = spx->basis().baseId(i);
4498 if(
id.isSPxRowId() )
4500 assert(spx->number(
id) >= 0);
4501 assert(spx->number(
id) < nRows);
4503 rowrhs.add(i, v[spx->number(
id)]);
4507 assert(rowrhs[i] == 0.0);
4512 spx->basis().coSolve(y, rowrhs);
4515 for(
int i = 0; i < nRows; ++i )
4527 assert(idx < nRows);
4528 assert(!spx->isRowBasic(idx));
4530 x[i] = v[idx] - (spx->rowVector(idx) * Vector(nCols, y.get_ptr()));
4536 assert(idx < nCols);
4537 assert(!spx->isColBasic(idx));
4549 catch(
const SPxException& x )
4551 std::string s = x.what();
4554 catch(
const SPxException& )
4584 assert( lpi !=
NULL );
4586 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4593 DVector e(lpi->
spx->nRows());
4598 assert(c < lpi->spx->nRows());
4631 assert(lpi !=
NULL);
4633 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4635 nrows = lpi->
spx->nRows();
4636 ncols = lpi->
spx->nCols();
4640 if( binvrow ==
NULL )
4649 assert(binv !=
NULL);
4656 soplex::Vector binvvec(nrows, binv);
4657 for( c = 0; c < ncols; ++c )
4658 coef[c] = binvvec * lpi->
spx->colVector(c);
4681 DVector col(lpi->
spx->nRows());
4685 assert( lpi !=
NULL );
4687 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4691 assert(c < lpi->spx->nCols());
4698 col = lpi->
spx->colVector(c);
4699 col.reDim(lpi->
spx->nRows());
4731 assert(blkmem !=
NULL);
4732 assert(lpi !=
NULL);
4734 assert(lpistate !=
NULL);
4736 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4738 ncols = lpi->
spx->nCols();
4739 nrows = lpi->
spx->nRows();
4754 (*lpistate)->ncols = ncols;
4755 (*lpistate)->nrows = nrows;
4776 assert(lpi !=
NULL);
4778 assert(lpistate !=
NULL);
4780 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4782 lpncols = lpi->
spx->nCols();
4783 lpnrows = lpi->
spx->nRows();
4784 assert(lpistate->
ncols <= lpncols);
4785 assert(lpistate->
nrows <= lpnrows);
4795 for( i = lpistate->
ncols; i < lpncols; ++i )
4801 bnd = lpi->
spx->lower(i);
4810 for( i = lpistate->
nrows; i < lpnrows; ++i )
4826 assert(lpi !=
NULL);
4834 catch(
const SPxException& x )
4836 std::string s = x.what();
4839 catch(
const SPxException& )
4842 assert( lpi->
spx->getStatus() != SPxSolver::OPTIMAL );
4858 assert(lpi !=
NULL);
4859 assert(lpistate !=
NULL);
4861 if ( *lpistate !=
NULL )
4884 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4900 assert( lpi->
spx->preStrongbranchingBasisFreed() );
4932 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 4936 assert(blkmem !=
NULL);
4937 assert(lpi !=
NULL);
4939 assert(lpinorms !=
NULL);
4941 lpi->
spx->getNdualNorms(nrows, ncols);
4943 if( nrows == 0 && ncols == 0)
4952 (*lpinorms)->nrows = 0;
4953 (*lpinorms)->ncols = 0;
4955 SCIPdebugMessage(
"storing SoPlex LPi pricing norms in %p (%d rows, %d cols)\n", (
void *) *lpinorms, nrows, ncols);
4957 if( !lpi->
spx->getDualNorms((*lpinorms)->nrows, (*lpinorms)->ncols, (*lpinorms)->norms) )
4962 assert(*lpinorms ==
NULL);
4967 assert(nrows == (*lpinorms)->nrows);
4968 assert(ncols == (*lpinorms)->ncols);
4987 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 4988 assert(blkmem !=
NULL);
4989 assert(lpi !=
NULL);
4993 if( lpinorms ==
NULL )
4996 assert(lpinorms->
nrows <= lpi->
spx->nRows());
4997 assert(lpinorms->
ncols <= lpi->
spx->nCols());
4999 if( lpinorms->
nrows == 0 )
5002 SCIPdebugMessage(
"loading LPi simplex norms %p (%d rows, %d cols) into SoPlex LP with %d rows and %d cols\n",
5003 (
const void *) lpinorms, lpinorms->
nrows, lpinorms->ncols, lpi->
spx->nRows(), lpi->
spx->nCols());
5005 if( !lpi->
spx->setDualNorms(lpinorms->nrows, lpinorms->ncols, lpinorms->norms) )
5019 #if ((SOPLEX_VERSION == 201 && SOPLEX_SUBVERSION >= 3) || SOPLEX_VERSION > 201) 5020 assert(lpi !=
NULL);
5021 assert(lpinorms !=
NULL);
5027 assert(*lpinorms ==
NULL);
5054 assert(lpi !=
NULL);
5056 assert(ival !=
NULL);
5061 *ival = lpi->
spx->getFromScratch();
5064 *ival = lpi->
spx->getLpInfo();
5067 *ival = lpi->
spx->getIterationLimit();
5070 *ival = lpi->
spx->getPresolving();
5076 *ival = lpi->
spx->getScaling();
5078 #if SOPLEX_VERSION >= 201 5080 *ival = (int) lpi->
spx->getTiming();
5083 #if SOPLEX_VERSION >= 230 || (SOPLEX_VERSION == 220 && SOPLEX_SUBVERSION >= 3) 5085 *ival = (int) lpi->
spx->random.getSeed();
5104 assert(lpi !=
NULL);
5111 lpi->
spx->setFromScratch(
bool(ival));
5115 lpi->
spx->setLpInfo(
bool(ival));
5119 lpi->
spx->setIterationLimit(ival);
5123 lpi->
spx->setPresolving(
bool(ival));
5131 lpi->
spx->setAutoPricer();
5134 lpi->
spx->setFullPricer();
5137 lpi->
spx->setParmultPricer();
5140 lpi->
spx->setSteepPricer();
5143 lpi->
spx->setSteepQStartPricer();
5146 lpi->
spx->setDevexPricer();
5154 lpi->
spx->setScaling(ival);
5156 #if SOPLEX_VERSION >= 201 5158 assert(ival >= 0 && ival < 3);
5159 lpi->
spx->setTiming((Timer::TYPE) ival);
5162 #if SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 220 && SOPLEX_SUBVERSION >= 2) 5164 lpi->
spx->random.setSeed((
unsigned int) ival);
5167 #if SOPLEX_VERSION > 221 || (SOPLEX_VERSION == 221 && SOPLEX_SUBVERSION >= 3) 5169 assert(ival >= 0 && ival < 3);
5170 lpi->
spx->setSolutionPolishing((SPxSolver::SolutionPolish) ival);
5190 assert(lpi !=
NULL);
5192 assert(dval !=
NULL);
5197 *dval = lpi->
spx->feastol();
5199 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 5201 *dval = lpi->
spx->opttol();
5205 *dval = lpi->
spx->getObjLoLimit();
5208 *dval = lpi->
spx->getObjUpLimit();
5211 *dval = lpi->
spx->terminationTime();
5235 assert(lpi !=
NULL);
5241 lpi->
spx->setFeastol(dval);
5243 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160) 5245 lpi->
spx->setOpttol(dval);
5249 lpi->
spx->setObjLoLimit(dval);
5252 lpi->
spx->setObjUpLimit(dval);
5255 lpi->
spx->setTerminationTime(dval);
5258 assert(dval >= -1.5);
5320 const char* filename
5325 f = fopen(filename,
"r");
5342 assert(lpi !=
NULL);
5345 assert( lpi->
spx->preStrongbranchingBasisFreed() );
5352 if( !lpi->
spx->readLP(fname) )
5356 catch(
const SPxException& x )
5358 std::string s = x.what();
5361 catch(
const SPxException& )
5378 assert(lpi !=
NULL);
5383 lpi->
spx->writeFile(fname);
5386 catch(
const SPxException& x )
5388 std::string s = x.what();
5391 catch(
const SPxException& )
SCIP_Bool SCIPlpiIsDualFeasible(SCIP_LPI *lpi)
static SCIP_RETCODE lpiGetBInvVec(SCIP_LPI *lpi, SCIP_Real *rhs, SCIP_Real *coef)
SCIP_RETCODE SCIPlpiDelColset(SCIP_LPI *lpi, int *dstat)
SCIP_RETCODE SCIPlpiGetBInvRow(SCIP_LPI *lpi, int r, SCIP_Real *coef, int *inds, int *ninds)
SCIP_Bool SCIPlpiExistsPrimalRay(SCIP_LPI *lpi)
enum SCIP_LPSolQuality SCIP_LPSOLQUALITY
SCIP_RETCODE SCIPlpiReadLP(SCIP_LPI *lpi, const char *fname)
SCIP_RETCODE SCIPlpiStrongbranchFrac(SCIP_LPI *lpi, int col, SCIP_Real psol, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
#define BMSfreeMemoryArrayNull(ptr)
SCIP_RETCODE SCIPlpiGetNCols(SCIP_LPI *lpi, int *ncols)
SCIP_RETCODE SCIPlpiSetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int ival)
enum SCIP_ObjSen SCIP_OBJSEN
SCIP_RETCODE SCIPlpiSolvePrimal(SCIP_LPI *lpi)
void SCIPdecodeDualBit(const SCIP_DUALPACKET *inp, int *out, int count)
interface methods for specific LP solvers
SCIP_RETCODE SCIPlpiDelRows(SCIP_LPI *lpi, int firstrow, int lastrow)
static SCIP_RETCODE lpistateCreate(SCIP_LPISTATE **lpistate, BMS_BLKMEM *blkmem, int ncols, int nrows)
int SCIPlpiGetInternalStatus(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiIsPrimalInfeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiDelRowset(SCIP_LPI *lpi, int *dstat)
#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 SCIPlpiSolveDual(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiIsPrimalFeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiSetState(SCIP_LPI *lpi, BMS_BLKMEM *, const SCIP_LPISTATE *lpistate)
SCIP_RETCODE SCIPlpiEndStrongbranch(SCIP_LPI *lpi)
static SCIP_RETCODE spxSolve(SCIP_LPI *lpi, SPxSolver::Representation rep, SPxSolver::Type type)
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)
enum SCIP_LPParam SCIP_LPPARAM
SCIP_RETCODE SCIPlpiGetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int *ival)
#define BMSallocMemoryArray(ptr, num)
const char * SCIPlpiGetSolverName(void)
SCIP_RETCODE SCIPlpiFreeNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
SCIP_RETCODE SCIPlpiGetNRows(SCIP_LPI *lpi, int *nrows)
SCIP_RETCODE SCIPlpiSetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, const SCIP_LPINORMS *lpinorms)
#define BMSfreeMemory(ptr)
enum SCIP_Pricing SCIP_PRICING
static void lpistateFree(SCIP_LPISTATE **lpistate, BMS_BLKMEM *blkmem)
SCIP_RETCODE SCIPlpiGetObjsen(SCIP_LPI *lpi, SCIP_OBJSEN *objsen)
static SCIP_RETCODE ensureRstatMem(SCIP_LPI *lpi, int num)
SCIP_RETCODE SCIPlpiGetPrimalRay(SCIP_LPI *lpi, SCIP_Real *ray)
SCIP_RETCODE SCIPlpiIgnoreInstability(SCIP_LPI *lpi, SCIP_Bool *success)
SCIP_RETCODE SCIPlpiGetCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real *val)
SCIP_RETCODE SCIPlpiReadState(SCIP_LPI *lpi, const char *fname)
#define SOPLEX_TRY(messagehdlr, x)
SCIP_RETCODE SCIPlpiGetBInvARow(SCIP_LPI *lpi, int r, const SCIP_Real *binvrow, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiGetObjval(SCIP_LPI *lpi, SCIP_Real *objval)
void * SCIPlpiGetSolverPointer(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiHasPrimalRay(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiChgObj(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *obj)
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)
static SCIP_RETCODE ensureCstatMem(SCIP_LPI *lpi, int num)
packing single and dual bit values
#define BMSfreeMemoryArray(ptr)
SCIP_RETCODE SCIPlpiGetNNonz(SCIP_LPI *lpi, int *nnonz)
static int colpacketNum(int ncols)
SCIP_RETCODE SCIPlpiScaleRow(SCIP_LPI *lpi, int row, SCIP_Real scaleval)
SCIP_Bool SCIPlpiIsInfinity(SCIP_LPI *, SCIP_Real val)
SCIP_RETCODE SCIPlpiFree(SCIP_LPI **lpi)
static SPxLP::SPxSense spxObjsen(SCIP_OBJSEN objsen)
SCIPInterval sign(const SCIPInterval &x)
void SCIPmessagePrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
SCIP_Bool SCIPlpiIsTimelimExc(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiClear(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiScaleCol(SCIP_LPI *lpi, int col, SCIP_Real scaleval)
SCIP_Bool SCIPlpiExistsDualRay(SCIP_LPI *lpi)
static 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 SCIPlpiSetIntegralityInformation(SCIP_LPI *lpi, int ncols, int *intInfo)
SCIP_RETCODE SCIPlpiSetBase(SCIP_LPI *lpi, const int *cstat, const int *rstat)
SCIP_Bool SCIPlpiIsPrimalUnbounded(SCIP_LPI *lpi)
static SCIP_Bool fileExists(const char *filename)
SCIP_RETCODE SCIPlpiStrongbranchInt(SCIP_LPI *lpi, int col, SCIP_Real psol, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
void SCIPencodeDualBit(const int *inp, SCIP_DUALPACKET *out, int count)
const char * SCIPlpiGetSolverDesc(void)
#define SOPLEX_SUBVERSION
SCIP_RETCODE SCIPlpiCreate(SCIP_LPI **lpi, SCIP_MESSAGEHDLR *messagehdlr, const char *name, SCIP_OBJSEN objsen)
#define BMSfreeBlockMemory(mem, ptr)
SCIP_RETCODE SCIPlpiGetDualfarkas(SCIP_LPI *lpi, SCIP_Real *dualfarkas)
unsigned int SCIP_DUALPACKET
SCIP_RETCODE SCIPlpiWriteLP(SCIP_LPI *lpi, const char *fname)
SCIP_Bool SCIPlpiWasSolved(SCIP_LPI *lpi)
#define BMSallocBlockMemoryArray(mem, ptr, num)
SCIP_Real SCIPlpiInfinity(SCIP_LPI *)
static void setFeastol(SCIP_NLPIPROBLEM *nlpiproblem, SCIP_Real feastol)
SCIP_RETCODE SCIPlpiGetBounds(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *lbs, SCIP_Real *ubs)
SCIP_RETCODE SCIPlpiChgCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real newval)
SCIP_Bool SCIPlpiIsObjlimExc(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetSides(SCIP_LPI *lpi, int firstrow, int lastrow, SCIP_Real *lhss, SCIP_Real *rhss)
#define BMSallocMemoryCPP(size)
#define BMSfreeBlockMemoryArray(mem, ptr, num)
SCIP_RETCODE SCIPlpiGetSolFeasibility(SCIP_LPI *lpi, SCIP_Bool *primalfeasible, SCIP_Bool *dualfeasible)
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)
SCIP_RETCODE SCIPlpiGetIterations(SCIP_LPI *lpi, int *iterations)
static void lpistatePack(SCIP_LPISTATE *lpistate, const int *cstat, const int *rstat)
SCIP_RETCODE SCIPlpiGetSol(SCIP_LPI *lpi, SCIP_Real *objval, SCIP_Real *primsol, SCIP_Real *dualsol, SCIP_Real *activity, SCIP_Real *redcost)
SCIP_RETCODE SCIPlpiStrongbranchesInt(SCIP_LPI *lpi, int *cols, int ncols, SCIP_Real *psols, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
SCIP_RETCODE SCIPlpiGetRealSolQuality(SCIP_LPI *lpi, SCIP_LPSOLQUALITY qualityindicator, SCIP_Real *quality)
SCIP_RETCODE SCIPlpiDelCols(SCIP_LPI *lpi, int firstcol, int lastcol)
SCIP_RETCODE SCIPlpiGetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
SCIP_RETCODE SCIPlpiGetRowNames(SCIP_LPI *lpi, int firstrow, int lastrow, char **rownames, char *namestorage, int namestoragesize, int *storageleft)
SCIP_RETCODE SCIPlpiChgObjsen(SCIP_LPI *lpi, SCIP_OBJSEN objsen)
SCIP_Bool SCIPlpiIsDualInfeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiAddRows(SCIP_LPI *lpi, int nrows, const SCIP_Real *lhs, const SCIP_Real *rhs, char **, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
SCIP_RETCODE SCIPlpiGetState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
SCIP_RETCODE SCIPlpiChgBounds(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *lb, const SCIP_Real *ub)
SCIP_Bool SCIPlpiHasStateBasis(SCIP_LPI *lpi, SCIP_LPISTATE *lpistate)
SCIP_Bool SCIPlpiIsOptimal(SCIP_LPI *lpi)
SLUFactor * factorization
SCIP_RETCODE SCIPlpiGetCols(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *lb, SCIP_Real *ub, int *nnonz, int *beg, int *ind, SCIP_Real *val)
static void lpistateUnpack(const SCIP_LPISTATE *lpistate, int *cstat, int *rstat)
SCIP_RETCODE SCIPlpiGetBase(SCIP_LPI *lpi, int *cstat, int *rstat)
public methods for message output
SCIP_DUALPACKET COLPACKET
SCIP_Bool SCIPlpiHasDualRay(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetColNames(SCIP_LPI *lpi, int firstcol, int lastcol, char **colnames, char *namestorage, int namestoragesize, int *storageleft)
SCIP_RETCODE SCIPlpiFreeState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
SCIP_RETCODE SCIPlpiGetBasisInd(SCIP_LPI *lpi, int *bind)
#define BMSallocMemory(ptr)
#define BMSreallocMemoryArray(ptr, num)
SCIP_Bool SCIPlpiIsDualUnbounded(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiIsStable(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetObj(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *vals)
SCIP_DUALPACKET ROWPACKET
SCIP_RETCODE SCIPlpiSolveBarrier(SCIP_LPI *lpi, SCIP_Bool crossover)
#define SOPLEX_TRY_ABORT(x)
SCIP_MESSAGEHDLR * messagehdlr
SCIP_RETCODE SCIPlpiGetRows(SCIP_LPI *lpi, int firstrow, int lastrow, SCIP_Real *lhs, SCIP_Real *rhs, int *nnonz, int *beg, int *ind, SCIP_Real *val)
#define BMSallocBlockMemory(mem, ptr)
#define BMSclearMemoryArray(ptr, num)
SCIP_RETCODE SCIPlpiStartStrongbranch(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiSetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real dval)
struct BMS_BlkMem BMS_BLKMEM
SCIP_RETCODE SCIPlpiWriteState(SCIP_LPI *lpi, const char *fname)
SCIP_Bool SCIPlpiIsIterlimExc(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiClearState(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiChgSides(SCIP_LPI *lpi, int nrows, const int *ind, const SCIP_Real *lhs, const SCIP_Real *rhs)
SCIP_RETCODE SCIPlpiGetBInvCol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiGetBInvACol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiGetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real *dval)