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 #ifdef WITH_BOUNDFLIPPING
106 #include "spxboundflippingrt.h"
116 #define SOPLEX_VERBLEVEL 5
129 using namespace soplex;
137 #define SOPLEX_TRY(messagehdlr, x) do \
143 catch( const SPxException& E ) \
145 std::string s = E.what(); \
146 SCIPmessagePrintWarning((messagehdlr), "SoPlex threw an exception: %s\n", s.c_str()); \
147 return SCIP_LPERROR; \
153 #define SOPLEX_TRY(messagehdlr, x) do \
159 catch( const SPxException& E ) \
161 return SCIP_LPERROR; \
170 #define SOPLEX_TRY_ABORT(x) do \
176 catch( const SPxException& E ) \
178 std::string s = E.what(); \
179 SCIPerrorMessage("SoPlex threw an exception: %s\n", s.c_str()); \
188 class SPxSCIP :
public SPxSolver
190 SPxLP::SPxSense m_sense;
192 SPxSteepPR m_price_steep;
193 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 6) || SOPLEX_VERSION > 160)
194 SPxSteepExPR m_price_steep_ex;
196 SPxSteepPR m_price_steep_ex;
198 SPxParMultPR m_price_parmult;
199 SPxDevexPR m_price_devex;
200 #ifdef WITH_BOUNDFLIPPING
201 SPxBoundFlippingRT m_ratio;
218 SPxSolver::VarStatus* m_rowstat;
219 SPxSolver::VarStatus* m_colstat;
234 const char* probname =
NULL
236 : SPxSolver(LEAVE, COLUMN),
238 m_fromscratch(
false),
241 m_objLoLimit(-soplex::infinity),
242 m_objUpLimit(soplex::infinity),
252 m_messagehdlr(messagehdlr)
255 setSense(SPxLP::MINIMIZE);
258 setPricer(&m_price_steep);
261 if ( probname !=
NULL )
264 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160)
265 m_lpifeastol = SPxSolver::feastol();
266 m_lpiopttol = SPxSolver::opttol();
268 m_lpifeastol = SPxSolver::delta();
269 m_lpiopttol = SPxSolver::delta();
274 m_cpxenv = CPXopenCPLEX(&cpxstat);
275 assert(m_cpxenv !=
NULL);
276 m_cpxlp = CPXcreateprob(m_cpxenv, &cpxstat, probname !=
NULL ? probname :
"spxcheck");
277 (void) CPXsetintparam(m_cpxenv, CPX_PARAM_SCRIND, 0);
279 m_doublecheck =
false;
285 if( m_probname !=
NULL )
286 spx_free(m_probname);
288 freePreStrongbranchingBasis();
290 if( m_rownames !=
NULL )
292 m_rownames->~NameSet();
293 spx_free(m_rownames);
295 if( m_colnames !=
NULL )
297 m_colnames->~NameSet();
298 spx_free(m_colnames);
300 if( m_colstat !=
NULL )
302 if( m_rowstat !=
NULL )
306 (void) CPXfreeprob(m_cpxenv, &m_cpxlp);
307 (void) CPXcloseCPLEX(&m_cpxenv);
324 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160)
325 SPxSolver::setFeastol(d);
327 SPxSolver::setDelta(d);
344 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160)
345 SPxSolver::setOpttol(d);
347 SPxSolver::setDelta(d);
351 bool isPerturbed()
const
354 return (shift() >= 10.0 * epsilon());
358 void setIterationLimit(
367 setPricer(&m_price_devex);
368 m_autopricing =
true;
373 setPricer(&m_price_steep);
374 m_autopricing =
false;
377 void setSteepPricer()
379 setPricer(&m_price_steep_ex);
380 m_autopricing =
false;
383 void setSteepQStartPricer()
385 setPricer(&m_price_steep);
386 m_autopricing =
false;
389 void setParmultPricer()
391 setPricer(&m_price_parmult);
392 m_autopricing =
false;
395 void setDevexPricer()
397 setPricer(&m_price_devex);
398 m_autopricing =
false;
402 int getIterationLimit()
const
407 bool getFromScratch()
const
409 return m_fromscratch;
412 void setFromScratch(
bool fs)
417 bool getScaling()
const
422 void setScaling(
bool s)
427 bool getPresolving()
const
432 void setPresolving(
bool p)
437 bool getLpInfo()
const
442 void setLpInfo(
bool li)
447 SPxLP::SPxSense getSense()
const
449 assert(m_sense == sense());
454 void setSense(
const SPxLP::SPxSense sen)
456 assert(m_sense == sense());
464 if( m_sense == SPxLP::MINIMIZE && getObjUpLimit() < soplex::infinity )
467 SPxSolver::setTerminationValue(getObjUpLimit());
469 else if( m_sense == SPxLP::MAXIMIZE && getObjLoLimit() > -soplex::infinity )
472 SPxSolver::setTerminationValue(getObjLoLimit());
477 void setProbname(
const char* probname)
481 assert(probname !=
NULL);
482 if( m_probname !=
NULL )
483 spx_free(m_probname);
484 len = (int) strlen(probname);
485 spx_alloc(m_probname, len + 1);
486 strncpy(m_probname, probname, len);
487 m_probname[len] =
'\0';
490 Real getObjLoLimit()
const
495 void setObjLoLimit(Real limit)
497 if( getSense() == SPxLP::MAXIMIZE )
499 SCIPdebugMessage(
"setting termination value from <%g> to <%g>\n", m_objLoLimit, limit);
500 SPxSolver::setTerminationValue(limit);
502 m_objLoLimit = limit;
505 Real getObjUpLimit()
const
510 void setObjUpLimit(Real limit)
512 if( getSense() == SPxLP::MINIMIZE )
514 SCIPdebugMessage(
"setting termination value from <%g> to <%g>\n", m_objUpLimit, limit);
515 SPxSolver::setTerminationValue(limit);
517 m_objUpLimit = limit;
520 void setRep(SPxSolver::Representation p_rep)
524 SCIPdebugMessage(
"switching to %s representation of the basis\n", p_rep == SPxSolver::ROW ?
"row" :
"column");
525 SPxSolver::setRep(p_rep);
530 bool getDoubleCheck()
533 return m_doublecheck && m_checknum + 1 >= CHECK_START;
536 void setDoubleCheck(
bool dc)
541 const char* spxStatusString(
const SPxSolver::Status stat)
545 case SPxSolver::ABORT_TIME:
547 case SPxSolver::ABORT_ITER:
549 case SPxSolver::ABORT_VALUE:
550 return "ABORT_VALUE";
551 case SPxSolver::SINGULAR:
553 case SPxSolver::REGULAR:
555 case SPxSolver::UNKNOWN:
557 case SPxSolver::OPTIMAL:
559 case SPxSolver::UNBOUNDED:
561 case SPxSolver::INFEASIBLE:
570 const char* cpxStatusString(
const int stat)
574 case CPX_STAT_ABORT_TIME_LIM:
576 case CPX_STAT_ABORT_IT_LIM:
578 case CPX_STAT_ABORT_OBJ_LIM:
579 return "ABORT_VALUE";
580 case CPX_STAT_OPTIMAL:
582 case CPX_STAT_OPTIMAL_INFEAS:
583 return "CPX_STAT_OPTIMAL_INFEAS: OPT SOL INFEASIBLE AFTER UNSCALING";
584 case CPX_STAT_UNBOUNDED:
586 case CPX_STAT_INFEASIBLE:
588 case CPX_STAT_INForUNBD:
589 return "INFEASIBLE or UNBOUNDED";
590 case CPX_STAT_NUM_BEST:
591 return "CPX_STAT_NUM_BEST: SOL AVAILABLE BUT NOT PROVEN OPTIMAL DUE TO NUM TROUBLE";
601 bool checkConsistentBounds()
const
603 for(
int i = 0; i < nCols(); ++i )
605 if( lower(i) > upper(i) )
607 SCIPerrorMessage(
"inconsistent bounds on column %d: lower=%.17g, upper=%.17g\n",
608 i, lower(i), upper(i));
616 bool checkConsistentSides()
const
618 for(
int i = 0; i < nRows(); ++i )
620 if( lhs(i) > rhs(i) )
632 void trySolve(
bool printwarning =
true)
638 m_stat = SPxSolver::solve();
640 catch(
const SPxException& x )
642 std::string s = x.what();
647 m_stat = SPxSolver::status();
653 assert( m_stat != SPxSolver::OPTIMAL );
657 m_itused += SPxSolver::iterations();
658 assert(m_itlim < 0 || m_itused <= m_itlim);
661 timespent = SPxSolver::time();
665 timelimit = SPxSolver::terminationTime();
666 if( timelimit > timespent )
667 timelimit -= timespent;
671 assert(timelimit >= 0);
672 SPxSolver::setTerminationTime(timelimit);
676 void doSolve(
bool printwarning =
true)
681 verbosity = Param::verbose();
684 assert(checkConsistentBounds());
685 assert(checkConsistentSides());
689 if( getDoubleCheck() )
694 setTerminationIter(m_autopricing && (m_itlim < 0 || m_itlim - m_itused >
AUTOPRICING_ITERSWITCH) ? AUTOPRICING_ITERSWITCH : m_itlim - m_itused);
696 trySolve(printwarning);
698 if( m_autopricing && m_stat == SPxSolver::ABORT_ITER && (m_itlim < 0 || m_itlim - m_itused > 0) )
700 setTerminationIter(m_itlim - m_itused);
701 setPricer(&m_price_steep_ex);
703 trySolve(printwarning);
705 setPricer(&m_price_devex);
709 setTerminationIter(m_itlim);
711 if( m_stat == OPTIMAL )
713 Real objval = value();
715 if( (objval > m_objUpLimit) || (objval < m_objLoLimit) )
716 m_stat = ABORT_VALUE;
721 if( getDoubleCheck() && (m_stat == SPxSolver::OPTIMAL || m_stat == SPxSolver::UNBOUNDED || m_stat == SPxSolver::INFEASIBLE || m_stat == SPxSolver::ABORT_VALUE) )
727 CPX_CALL( CPXreadcopyprob(m_cpxenv, m_cpxlp,
"spxcheck.mps",
NULL) );
728 CPX_CALL( CPXreadcopybase(m_cpxenv, m_cpxlp,
"spxcheck.bas") );
731 CPX_CALL( CPXsetdblparam(m_cpxenv, CPX_PARAM_EPOPT,
MAX(opttol(), 1e-9)) );
732 CPX_CALL( CPXsetdblparam(m_cpxenv, CPX_PARAM_EPRHS,
MAX(feastol(), 1e-9)) );
735 CPX_CALL( CPXlpopt(m_cpxenv, m_cpxlp) );
738 CPX_CALL( CPXsolution(m_cpxenv, m_cpxlp, &cpxstat, &cpxobj,
NULL,
NULL,
NULL,
NULL) );
739 if( getSense() == SPxLP::MAXIMIZE )
743 if( cpxstat == CPX_STAT_OPTIMAL_INFEAS )
745 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s)\n",
746 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat));
747 if( EXIT_AT_CPXERROR )
750 else if( (m_stat == SPxSolver::OPTIMAL && cpxstat != CPX_STAT_OPTIMAL)
751 || (m_stat == SPxSolver::UNBOUNDED && cpxstat != CPX_STAT_UNBOUNDED)
752 || (m_stat == SPxSolver::INFEASIBLE && cpxstat != CPX_STAT_INFEASIBLE) )
754 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
755 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat), m_checknum);
756 if( EXIT_AT_WRONG_RESULT )
759 else if( m_stat == SPxSolver::ABORT_VALUE )
763 case CPX_STAT_OPTIMAL:
764 if( (getSense() == SPxSolver::MINIMIZE && LTrel(cpxobj, getObjUpLimit(), 2*opttol()))
765 || (getSense() == SPxSolver::MAXIMIZE && GTrel(cpxobj, getObjLoLimit(), 2*opttol())) )
767 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
768 m_probname, m_stat, spxStatusString(m_stat), cpxobj, getSense() == SPxSolver::MINIMIZE ?
"<" :
">",
769 getSense() == SPxSolver::MINIMIZE ? getObjUpLimit() : getObjLoLimit(), cpxStatusString(cpxstat), m_checknum);
770 if( EXIT_AT_WRONG_RESULT )
773 else if( (getSense() == SPxSolver::MINIMIZE && cpxobj < getObjUpLimit())
774 || (getSense() == SPxSolver::MAXIMIZE && cpxobj > getObjLoLimit()) )
776 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
777 m_probname, m_stat, spxStatusString(m_stat), cpxobj, getSense() == SPxSolver::MINIMIZE ?
"<" :
">",
778 getSense() == SPxSolver::MINIMIZE ? getObjUpLimit() : getObjLoLimit(), cpxStatusString(cpxstat), m_checknum);
781 case CPX_STAT_OPTIMAL_INFEAS:
782 case CPX_STAT_NUM_BEST:
783 if( (getSense() == SPxSolver::MINIMIZE && cpxobj < getObjUpLimit())
784 || (getSense() == SPxSolver::MAXIMIZE && cpxobj > getObjLoLimit()) )
786 SCIPerrorMessage(
"In %s: SoPlex returned status=%d (%s) while CPLEX claims obj=%.10f %s %.10f=obj.limit (%s) (checknum=%d)\n",
787 m_probname, m_stat, spxStatusString(m_stat), cpxobj, getSense() == SPxSolver::MINIMIZE ?
"<" :
">",
788 getSense() == SPxSolver::MINIMIZE ? getObjUpLimit() : getObjLoLimit(), cpxStatusString(cpxstat), m_checknum);
791 case CPX_STAT_INFEASIBLE:
793 case CPX_STAT_UNBOUNDED:
794 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
795 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat), m_checknum);
796 if( EXIT_AT_WRONG_RESULT )
799 case CPX_STAT_INForUNBD:
801 SCIPerrorMessage(
"In %s: SoPlex status=%d (%s) while CPLEX status=%d (%s) (checknum=%d)\n",
802 m_probname, m_stat, spxStatusString(m_stat), cpxstat, cpxStatusString(cpxstat), m_checknum);
807 else if( m_stat == SPxSolver::OPTIMAL )
809 if( (getSense() == SPxSolver::MINIMIZE && LTrel(value(), cpxobj, 2*opttol()))
810 || (getSense() == SPxSolver::MAXIMIZE && GTrel(value(), cpxobj, 2*opttol())) )
815 else if( (getSense() == SPxSolver::MINIMIZE && GTrel(value(), cpxobj, 2*opttol()))
816 || (getSense() == SPxSolver::MAXIMIZE && LTrel(value(), cpxobj, 2*opttol())) )
818 SCIPerrorMessage(
"In %s: LP optimal; SoPlex value=%.10f %s CPLEX value=%.10f suboptimal (checknum=%d)\n", value(),
819 m_probname, getSense() == SPxSolver::MINIMIZE ?
">" :
"<", cpxobj, m_checknum);
820 if( EXIT_AT_WRONG_RESULT )
830 Param::setVerbose(verbosity);
833 virtual Status solve()
835 assert(m_sense == sense());
837 SPxEquiliSC* scaler =
NULL;
838 SPxMainSM* simplifier =
NULL;
840 SPxSimplifier::Result result = SPxSimplifier::OKAY;
843 if ( getFromScratch() )
849 catch(
const SPxException& x )
851 std::string s = x.what();
853 m_stat = SPxSolver::status();
854 assert( m_stat != SPxSolver::OPTIMAL );
858 assert(!getFromScratch() || getBasisStatus() == SPxBasis::NO_PROBLEM);
861 if( SPxSolver::getBasisStatus() == SPxBasis::NO_PROBLEM && getScaling() && nCols() > 0 && nRows() > 0 )
863 spx_alloc(scaler, 1);
864 scaler =
new (scaler) SPxEquiliSC();
865 assert(scaler !=
NULL);
868 if( SPxSolver::getBasisStatus() == SPxBasis::NO_PROBLEM && getPresolving() && nCols() > 0 && nRows() > 0 )
870 spx_alloc(simplifier, 1);
871 simplifier =
new (simplifier) SPxMainSM();
872 assert(simplifier !=
NULL);
876 if( scaler !=
NULL || simplifier !=
NULL )
877 origlp = SPxLP(*
this);
884 scaler->scale(*
this);
887 if( simplifier !=
NULL )
892 verbosity = Param::verbose();
895 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160)
896 result = simplifier->simplify(*
this, epsilon(), feastol(), opttol());
898 result = simplifier->simplify(*
this, epsilon(), delta());
900 SCIPdebugMessage(
"simplifier ended with status %u (0: OKAY, 1: INFEASIBLE, 2: DUAL_INFEASIBLE, 3: UNBOUNDED, 4: VANISHED)\n", result);
903 if( result == SPxSimplifier::INFEASIBLE || result == SPxSimplifier::DUAL_INFEASIBLE )
905 SCIPdebugMessage(
"simplifier detected primal or dual infeasibility - reloading and solving unsimplified LP\n");
907 simplifier->~SPxMainSM();
908 spx_free(simplifier);
910 SPxSolver::loadLP(origlp);
916 Param::setVerbose(verbosity);
921 if( result != SPxSimplifier::VANISHED )
924 Real objlolimit = getObjLoLimit();
925 Real objuplimit = getObjUpLimit();
927 if( simplifier !=
NULL || scaler !=
NULL )
929 setObjLoLimit(-soplex::infinity);
930 setObjUpLimit(soplex::infinity);
939 if( simplifier !=
NULL || scaler !=
NULL )
941 setObjLoLimit(objlolimit);
942 setObjUpLimit(objuplimit);
947 if( m_stat != SPxSolver::OPTIMAL && simplifier !=
NULL )
949 SCIPdebugMessage(
"presolved LP not optimal - reloading and solving original LP\n");
951 simplifier->~SPxMainSM();
952 spx_free(simplifier);
954 SPxSolver::loadLP(origlp);
961 if( scaler !=
NULL || simplifier !=
NULL )
963 SPxSolver::VarStatus* cstat =
NULL;
964 SPxSolver::VarStatus* rstat =
NULL;
967 if( (simplifier ==
NULL || result != SPxSimplifier::VANISHED) && SPxSolver::getBasisStatus() >= SPxBasis::REGULAR )
970 spx_alloc(rstat, nRows());
971 spx_alloc(cstat, nCols());
972 (void) SPxSolver::getBasis(rstat, cstat);
976 if( simplifier !=
NULL && SPxSolver::getBasisStatus() >= SPxBasis::REGULAR )
978 assert((result == SPxSimplifier::VANISHED) == (cstat ==
NULL));
979 assert((result == SPxSimplifier::VANISHED) == (rstat ==
NULL));
982 int ncols = result == SPxSimplifier::VANISHED ? 0 : nCols();
983 int nrows = result == SPxSimplifier::VANISHED ? 0 : nRows();
986 DVector primals(ncols);
987 DVector duals(nrows);
988 DVector slacks(nrows);
989 DVector redcosts(ncols);
990 if( result != SPxSimplifier::VANISHED )
992 (void) SPxSolver::getPrimal(primals);
993 (void) SPxSolver::getDual(duals);
994 (void) SPxSolver::getSlacks(slacks);
995 (void) SPxSolver::getRedCost(redcosts);
1002 simplifier->unsimplify(primals, duals, slacks, redcosts, rstat, cstat);
1004 catch(
const SPxException& x )
1006 std::string s = x.what();
1007 SCIPmessagePrintWarning(m_messagehdlr,
"SoPlex unsimplification unsuccessful; solving again without LP presolving (SoPlex says %s)\n",
1016 if( simplifier->isUnsimplified() )
1021 spx_alloc(rstat, origlp.nRows());
1022 spx_alloc(cstat, origlp.nCols());
1023 simplifier->getBasis(rstat, cstat);
1029 SPxSolver::loadLP(origlp);
1033 if( rstat !=
NULL && cstat !=
NULL )
1036 SPxSolver::setBasis(rstat, cstat);
1051 if( scaler !=
NULL )
1053 scaler->~SPxEquiliSC();
1056 if( simplifier !=
NULL )
1058 simplifier->~SPxMainSM();
1059 spx_free(simplifier);
1063 if( m_stat == OPTIMAL )
1065 Real objval = value();
1067 if( (objval > m_objUpLimit) || (objval < m_objLoLimit) )
1068 m_stat = ABORT_VALUE;
1075 void savePreStrongbranchingBasis()
1077 assert(m_rowstat ==
NULL);
1078 assert(m_colstat ==
NULL);
1080 spx_alloc(m_rowstat, nRows());
1081 spx_alloc(m_colstat, nCols());
1085 m_stat = getBasis(m_rowstat, m_colstat);
1087 catch(
const SPxException& x )
1090 std::string s = x.what();
1097 assert(m_stat != SPxSolver::OPTIMAL);
1103 void restorePreStrongbranchingBasis()
1105 assert(m_rowstat !=
NULL);
1106 assert(m_colstat !=
NULL);
1110 setBasis(m_rowstat, m_colstat);
1112 catch(
const SPxException& x )
1115 std::string s = x.what();
1118 m_stat = SPxSolver::status();
1124 assert(m_stat != SPxSolver::OPTIMAL);
1129 void freePreStrongbranchingBasis()
1131 if( m_rowstat !=
NULL )
1132 spx_free(m_rowstat);
1133 if( m_colstat !=
NULL )
1134 spx_free(m_colstat);
1138 bool preStrongbranchingBasisFreed()
const
1140 return ((m_rowstat ==
NULL ) && (m_colstat ==
NULL));
1143 Status getStatus()
const
1148 Status updateStatus()
1150 m_stat = SPxSolver::status();
1154 bool isInitialized()
const
1156 return SPxSolver::isInitialized();
1159 int iterations()
const
1164 virtual void clear()
1167 freePreStrongbranchingBasis();
1168 m_stat = NO_PROBLEM;
1172 bool readLP(
const char* fname)
1176 if ( m_rownames != 0 )
1177 m_rownames->~NameSet();
1179 spx_alloc(m_colnames, 1);
1181 if ( m_colnames != 0 )
1182 m_colnames->~NameSet();
1184 spx_alloc(m_rownames, 1);
1186 m_rownames =
new (m_rownames) NameSet();
1187 m_colnames =
new (m_colnames) NameSet();
1189 if( SPxSolver::readFile(fname, m_rownames, m_colnames) )
1191 m_stat = NO_PROBLEM;
1205 int namestoragesize,
1209 assert( m_colnames !=
NULL );
1212 if ( namestoragesize == 0 )
1215 *storageleft = -m_colnames->memSize();
1219 NameSet* names = m_colnames;
1220 assert( names != 0 );
1221 int sizeleft = namestoragesize;
1222 char* s = namestorage;
1223 for (
int j = firstcol; j <= lastcol; ++j)
1225 const char* t = (*names)[j];
1226 colnames[j-firstcol] = s;
1227 while( *t !=
'\0' && sizeleft >= 0 )
1234 if ( sizeleft == 0 )
1236 *storageleft = namestoragesize - m_colnames->memSize();
1237 assert( *storageleft <= 0 );
1240 *storageleft = sizeleft;
1250 int namestoragesize,
1254 assert( m_rownames !=
NULL );
1257 if ( namestoragesize == 0 )
1260 *storageleft = -m_rownames->memSize();
1264 NameSet* names = m_rownames;
1265 assert( names != 0 );
1266 int sizeleft = namestoragesize;
1267 char* s = namestorage;
1268 for (
int i = firstrow; i <= lastrow; ++i)
1270 const char* t = (*names)[i];
1271 rownames[i-firstrow] = s;
1272 while( *t !=
'\0' && sizeleft >= 0 )
1279 if ( sizeleft == 0 )
1281 *storageleft = m_rownames->memSize() - namestoragesize;
1282 assert( *storageleft <= 0 );
1285 *storageleft = sizeleft;
1298 #include "scip/bitencode.h"
1301 #define COLS_PER_PACKET SCIP_DUALPACKETSIZE
1303 #define ROWS_PER_PACKET SCIP_DUALPACKETSIZE
1317 SLUFactor* factorization;
1325 struct SCIP_LPiState
1347 assert(lpi !=
NULL);
1349 if( num > lpi->cstatsize )
1353 newsize =
MAX(2*lpi->cstatsize, num);
1354 SCIP_ALLOC( BMSreallocMemoryArray(&lpi->cstat, newsize) );
1355 lpi->cstatsize = newsize;
1357 assert(num <= lpi->cstatsize);
1369 assert(lpi !=
NULL);
1371 if( num > lpi->rstatsize )
1375 newsize =
MAX(2*lpi->rstatsize, num);
1376 SCIP_ALLOC( BMSreallocMemoryArray(&lpi->rstat, newsize) );
1377 lpi->rstatsize = newsize;
1379 assert(num <= lpi->rstatsize);
1417 assert(lpistate !=
NULL);
1418 assert(lpistate->packcstat !=
NULL);
1419 assert(lpistate->packrstat !=
NULL);
1421 SCIPencodeDualBit(cstat, lpistate->packcstat, lpistate->ncols);
1422 SCIPencodeDualBit(rstat, lpistate->packrstat, lpistate->nrows);
1427 void lpistateUnpack(
1433 assert(lpistate !=
NULL);
1434 assert(lpistate->packcstat !=
NULL);
1435 assert(lpistate->packrstat !=
NULL);
1437 SCIPdecodeDualBit(lpistate->packcstat, cstat, lpistate->ncols);
1438 SCIPdecodeDualBit(lpistate->packrstat, rstat, lpistate->nrows);
1450 assert(lpistate !=
NULL);
1451 assert(blkmem !=
NULL);
1455 int nColPackets = colpacketNum(ncols);
1456 int nRowPackets = rowpacketNum(nrows);
1458 SCIP_ALLOC( BMSallocBlockMemory(blkmem, lpistate) );
1459 SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*lpistate)->packcstat, nColPackets) );
1460 SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*lpistate)->packrstat, nRowPackets) );
1472 assert(blkmem !=
NULL);
1473 assert(lpistate !=
NULL);
1474 assert(*lpistate !=
NULL);
1476 int nColPackets = colpacketNum((*lpistate)->ncols);
1477 int nRowPackets = rowpacketNum((*lpistate)->nrows);
1479 BMSfreeBlockMemoryArray(blkmem, &(*lpistate)->packcstat, nColPackets);
1480 BMSfreeBlockMemoryArray(blkmem, &(*lpistate)->packrstat, nRowPackets);
1481 BMSfreeBlockMemory(blkmem, lpistate);
1493 SPxLP::SPxSense spxObjsen(
1500 return SPxLP::MAXIMIZE;
1502 return SPxLP::MINIMIZE;
1506 return SPxLP::MINIMIZE;
1512 void invalidateSolution(
SCIP_LPI* lpi)
1514 assert(lpi !=
NULL);
1515 lpi->solved =
FALSE;
1516 if ( lpi->factorization != 0 )
1518 delete lpi->factorization;
1519 lpi->factorization = 0;
1534 static char spxname[100];
1535 static char spxdesc[200];
1547 #if (SOPLEX_SUBVERSION > 0)
1548 sprintf(spxname,
"SoPlex %d.%d.%d.%d", SOPLEX_VERSION/100, (SOPLEX_VERSION % 100)/10, SOPLEX_VERSION % 10,
SOPLEX_SUBVERSION);
1550 sprintf(spxname,
"SoPlex %d.%d.%d", SOPLEX_VERSION/100, (SOPLEX_VERSION % 100)/10, SOPLEX_VERSION % 10);
1560 sprintf(spxdesc,
"%s",
"Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de)");
1561 #if (SOPLEX_VERSION >= 160)
1562 sprintf(spxdesc,
"%s [GitHash: %s]", spxdesc, getGitHash());
1564 #ifdef WITH_LPSCHECK
1565 sprintf(spxdesc,
"%s %s", spxdesc,
"- including CPLEX double check");
1575 return (
void*) lpi->spx;
1597 assert(lpi !=
NULL);
1603 (*lpi)->spx =
static_cast<SPxSCIP*
>(BMSallocMemoryCPP(
sizeof(SPxSCIP)));
1604 SOPLEX_TRY( messagehdlr, (*lpi)->spx = new ((*lpi)->spx) SPxSCIP(messagehdlr, name) );
1605 (*lpi)->cstat =
NULL;
1606 (*lpi)->rstat =
NULL;
1607 (*lpi)->cstatsize = 0;
1608 (*lpi)->rstatsize = 0;
1610 (*lpi)->factorization = 0;
1612 (*lpi)->conditionlimit = -1.0;
1613 (*lpi)->checkcondition =
FALSE;
1614 (*lpi)->messagehdlr = messagehdlr;
1616 invalidateSolution(*lpi);
1632 assert(lpi !=
NULL);
1633 assert(*lpi !=
NULL);
1634 assert((*lpi)->spx !=
NULL);
1637 (*lpi)->spx->~SPxSCIP();
1638 BMSfreeMemory(&((*lpi)->spx));
1641 BMSfreeMemoryArrayNull(&(*lpi)->cstat);
1642 BMSfreeMemoryArrayNull(&(*lpi)->rstat);
1681 assert(lpi !=
NULL);
1682 assert(lpi->spx !=
NULL);
1683 assert(lhs !=
NULL);
1684 assert(rhs !=
NULL);
1686 invalidateSolution(lpi);
1687 assert( lpi->spx->preStrongbranchingBasisFreed() );
1691 SPxSCIP* spx = lpi->spx;
1692 LPRowSet rows(nrows);
1693 DSVector emptyVector(0);
1699 spx->setSense(spxObjsen(objsen));
1702 for( i = 0; i < nrows; ++i )
1703 rows.add(lhs[i], emptyVector, rhs[i]);
1709 catch(
const SPxException& x )
1712 std::string s = x.what();
1737 assert(lpi !=
NULL);
1738 assert(lpi->spx !=
NULL);
1739 assert(obj !=
NULL);
1742 assert(nnonz == 0 || beg !=
NULL);
1743 assert(nnonz == 0 || ind !=
NULL);
1744 assert(nnonz == 0 || val !=
NULL);
1746 invalidateSolution(lpi);
1748 assert( lpi->spx->preStrongbranchingBasisFreed() );
1750 SPxSCIP* spx = lpi->spx;
1753 LPColSet cols(ncols);
1754 DSVector colVector(ncols);
1760 for( i = 0; i < ncols; ++i )
1766 last = (i == ncols-1 ? nnonz : beg[i+1]);
1767 colVector.add( last-start, &ind[start], &val[start] );
1769 cols.add(obj[i], lb[i], colVector, ub[i]);
1773 catch(
const SPxException& x )
1776 std::string s = x.what();
1794 assert(lpi !=
NULL);
1795 assert(lpi->spx !=
NULL);
1796 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
1798 invalidateSolution(lpi);
1800 assert( lpi->spx->preStrongbranchingBasisFreed() );
1802 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->removeColRange(firstcol, lastcol) );
1820 assert(lpi !=
NULL);
1821 assert(lpi->spx !=
NULL);
1823 invalidateSolution(lpi);
1825 assert( lpi->spx->preStrongbranchingBasisFreed() );
1827 ncols = lpi->spx->nCols();
1830 for( i = 0; i < ncols; ++i )
1833 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->removeCols(dstat) );
1853 assert(lpi !=
NULL);
1854 assert(lpi->spx !=
NULL);
1855 assert(lhs !=
NULL);
1856 assert(rhs !=
NULL);
1857 assert(nnonz == 0 || beg !=
NULL);
1858 assert(nnonz == 0 || ind !=
NULL);
1859 assert(nnonz == 0 || val !=
NULL);
1861 invalidateSolution(lpi);
1863 assert( lpi->spx->preStrongbranchingBasisFreed() );
1867 SPxSCIP* spx = lpi->spx;
1868 LPRowSet rows(nrows);
1875 for( i = 0; i < nrows; ++i )
1881 last = (i == nrows-1 ? nnonz : beg[i+1]);
1882 rowVector.add( last-start, &ind[start], &val[start] );
1884 rows.add(lhs[i], rowVector, rhs[i]);
1888 catch(
const SPxException& x )
1891 std::string s = x.what();
1909 assert(lpi !=
NULL);
1910 assert(lpi->spx !=
NULL);
1911 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
1913 invalidateSolution(lpi);
1915 assert( lpi->spx->preStrongbranchingBasisFreed() );
1917 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->removeRowRange(firstrow, lastrow) );
1935 assert(lpi !=
NULL);
1936 assert(lpi->spx !=
NULL);
1938 invalidateSolution(lpi);
1940 assert( lpi->spx->preStrongbranchingBasisFreed() );
1942 nrows = lpi->spx->nRows();
1945 for( i = 0; i < nrows; ++i )
1948 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->removeRows(dstat) );
1960 assert(lpi !=
NULL);
1961 assert(lpi->spx !=
NULL);
1963 invalidateSolution(lpi);
1965 assert( lpi->spx->preStrongbranchingBasisFreed() );
1966 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->clear() );
1984 assert(lpi !=
NULL);
1985 assert(lpi->spx !=
NULL);
1986 assert(ind !=
NULL);
1990 invalidateSolution(lpi);
1992 assert( lpi->spx->preStrongbranchingBasisFreed() );
1996 for( i = 0; i < ncols; ++i )
1998 assert(0 <= ind[i] && ind[i] < lpi->spx->nCols());
1999 lpi->spx->changeBounds(ind[i], lb[i], ub[i]);
2000 assert(lpi->spx->lower(ind[i]) <= lpi->spx->upper(ind[i]));
2003 catch(
const SPxException& x )
2006 std::string s = x.what();
2028 assert(lpi !=
NULL);
2029 assert(lpi->spx !=
NULL);
2030 assert(ind !=
NULL);
2031 assert(lhs !=
NULL);
2032 assert(rhs !=
NULL);
2034 invalidateSolution(lpi);
2036 assert( lpi->spx->preStrongbranchingBasisFreed() );
2040 for( i = 0; i < nrows; ++i )
2042 assert(0 <= ind[i] && ind[i] < lpi->spx->nRows());
2043 lpi->spx->changeRange(ind[i], lhs[i], rhs[i]);
2044 assert(lpi->spx->lhs(ind[i]) <= lpi->spx->rhs(ind[i]));
2047 catch(
const SPxException& x )
2050 std::string s = x.what();
2069 assert(lpi !=
NULL);
2070 assert(lpi->spx !=
NULL);
2071 assert(0 <= row && row < lpi->spx->nRows());
2072 assert(0 <= col && col < lpi->spx->nCols());
2074 invalidateSolution(lpi);
2076 assert( lpi->spx->preStrongbranchingBasisFreed() );
2078 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->changeElement(row, col, newval) );
2091 assert(lpi !=
NULL);
2092 assert(lpi->spx !=
NULL);
2094 invalidateSolution(lpi);
2096 assert( lpi->spx->preStrongbranchingBasisFreed() );
2098 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->setSense(spxObjsen(objsen)) );
2115 assert(lpi !=
NULL);
2116 assert(lpi->spx !=
NULL);
2117 assert(ind !=
NULL);
2118 assert(obj !=
NULL);
2120 invalidateSolution(lpi);
2122 assert( lpi->spx->preStrongbranchingBasisFreed() );
2126 for( i = 0; i < ncols; ++i )
2128 assert(0 <= ind[i] && ind[i] < lpi->spx->nCols());
2129 lpi->spx->changeObj(ind[i], obj[i]);
2132 catch(
const SPxException& x )
2135 std::string s = x.what();
2156 assert(lpi !=
NULL);
2157 assert(lpi->spx !=
NULL);
2158 assert(scaleval != 0.0);
2162 invalidateSolution(lpi);
2164 assert( lpi->spx->preStrongbranchingBasisFreed() );
2167 SVector rowvec = lpi->spx->rowVector(row);
2168 lhs = lpi->spx->lhs(row);
2169 rhs = lpi->spx->rhs(row);
2175 if( lhs > -soplex::infinity )
2177 else if( scaleval < 0.0 )
2178 lhs = soplex::infinity;
2179 if( rhs < soplex::infinity )
2181 else if( scaleval < 0.0 )
2182 rhs = -soplex::infinity;
2183 if( scaleval < 0.0 )
2191 LPRow lprow(lhs, rowvec, rhs);
2194 lpi->spx->changeRow(row, lprow);
2195 assert(lpi->spx->lhs(row) <= lpi->spx->rhs(row));
2197 catch(
const SPxException& x )
2200 std::string s = x.what();
2224 assert(lpi !=
NULL);
2225 assert(lpi->spx !=
NULL);
2226 assert(scaleval != 0.0);
2230 invalidateSolution(lpi);
2232 assert( lpi->spx->preStrongbranchingBasisFreed() );
2235 SVector colvec = lpi->spx->colVector(col);
2236 obj = lpi->spx->obj(col);
2237 lb = lpi->spx->lower(col);
2238 ub = lpi->spx->upper(col);
2247 if( lb > -soplex::infinity )
2249 else if( scaleval < 0.0 )
2250 lb = soplex::infinity;
2251 if( ub < soplex::infinity )
2253 else if( scaleval < 0.0 )
2254 ub = -soplex::infinity;
2255 if( scaleval < 0.0 )
2263 LPCol lpcol(obj, colvec, ub, lb);
2266 lpi->spx->changeCol(col, lpcol);
2267 assert(lpi->spx->lower(col) <= lpi->spx->upper(col));
2269 catch(
const SPxException& x )
2272 std::string s = x.what();
2301 assert(lpi !=
NULL);
2302 assert(lpi->spx !=
NULL);
2303 assert(nrows !=
NULL);
2305 *nrows = lpi->spx->nRows();
2318 assert(lpi !=
NULL);
2319 assert(lpi->spx !=
NULL);
2320 assert(ncols !=
NULL);
2322 *ncols = lpi->spx->nCols();
2337 assert(lpi !=
NULL);
2338 assert(lpi->spx !=
NULL);
2339 assert(nnonz !=
NULL);
2343 if( lpi->spx->nRows() < lpi->spx->nCols() )
2345 for( i = 0; i < lpi->spx->nRows(); ++i )
2346 (*nnonz) += lpi->spx->rowVector(i).size();
2350 for( i = 0; i < lpi->spx->nCols(); ++i )
2351 (*nnonz) += lpi->spx->colVector(i).size();
2378 assert(lpi !=
NULL);
2379 assert(lpi->spx !=
NULL);
2380 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2386 const Vector& lbvec = lpi->spx->lower();
2387 const Vector& ubvec = lpi->spx->upper();
2388 for( i = firstcol; i <= lastcol; ++i )
2390 lb[i-firstcol] = lbvec[i];
2391 ub[i-firstcol] = ubvec[i];
2400 for( i = firstcol; i <= lastcol; ++i )
2402 beg[i-firstcol] = *nnonz;
2403 const SVector& cvec = lpi->spx->colVector(i);
2404 for( j = 0; j < cvec.size(); ++j )
2406 ind[*nnonz] = cvec.index(j);
2407 val[*nnonz] = cvec.value(j);
2414 assert(beg ==
NULL);
2415 assert(ind ==
NULL);
2416 assert(val ==
NULL);
2443 assert(lpi !=
NULL);
2444 assert(lpi->spx !=
NULL);
2445 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
2449 assert(rhs !=
NULL);
2451 const Vector& lhsvec = lpi->spx->lhs();
2452 const Vector& rhsvec = lpi->spx->rhs();
2453 for( i = firstrow; i <= lastrow; ++i )
2455 lhs[i-firstrow] = lhsvec[i];
2456 rhs[i-firstrow] = rhsvec[i];
2460 assert(rhs ==
NULL);
2465 for( i = firstrow; i <= lastrow; ++i )
2467 beg[i-firstrow] = *nnonz;
2468 const SVector& rvec = lpi->spx->rowVector(i);
2469 for( j = 0; j < rvec.size(); ++j )
2471 ind[*nnonz] = rvec.index(j);
2472 val[*nnonz] = rvec.value(j);
2479 assert(beg ==
NULL);
2480 assert(ind ==
NULL);
2481 assert(val ==
NULL);
2494 int namestoragesize,
2498 assert( lpi !=
NULL );
2499 assert( lpi->spx !=
NULL );
2500 assert( colnames !=
NULL || namestoragesize == 0 );
2501 assert( namestorage !=
NULL || namestoragesize == 0 );
2502 assert( namestoragesize >= 0 );
2503 assert( storageleft !=
NULL );
2504 assert( 0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols() );
2508 lpi->spx->getColNames(firstcol, lastcol, colnames, namestorage, namestoragesize, storageleft);
2520 int namestoragesize,
2524 assert( lpi !=
NULL );
2525 assert( lpi->spx !=
NULL );
2526 assert( rownames !=
NULL || namestoragesize == 0 );
2527 assert( namestorage !=
NULL || namestoragesize == 0 );
2528 assert( namestoragesize >= 0 );
2529 assert( storageleft !=
NULL );
2530 assert( 0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows() );
2534 lpi->spx->getRowNames(firstrow, lastrow, rownames, namestorage, namestoragesize, storageleft);
2547 assert(lpi !=
NULL);
2548 assert(lpi->spx !=
NULL);
2549 assert(objsen !=
NULL);
2568 assert(lpi !=
NULL);
2569 assert(lpi->spx !=
NULL);
2570 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2571 assert(vals !=
NULL);
2573 for( i = firstcol; i <= lastcol; ++i )
2574 vals[i-firstcol] = lpi->spx->obj(i);
2592 assert(lpi !=
NULL);
2593 assert(lpi->spx !=
NULL);
2594 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->spx->nCols());
2596 for( i = firstcol; i <= lastcol; ++i )
2599 lbs[i-firstcol] = lpi->spx->lower(i);
2601 ubs[i-firstcol] = lpi->spx->upper(i);
2620 assert(lpi !=
NULL);
2621 assert(lpi->spx !=
NULL);
2622 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->nRows());
2624 for( i = firstrow; i <= lastrow; ++i )
2627 lhss[i-firstrow] = lpi->spx->lhs(i);
2629 rhss[i-firstrow] = lpi->spx->rhs(i);
2645 assert(lpi !=
NULL);
2646 assert(lpi->spx !=
NULL);
2647 assert(0 <= col && col < lpi->spx->nCols());
2648 assert(0 <= row && row < lpi->spx->nRows());
2649 assert(val !=
NULL);
2651 *val = lpi->spx->colVector(col)[row];
2672 SPxSolver::Representation rep,
2673 SPxSolver::Type type
2676 assert( lpi !=
NULL );
2677 assert( lpi->spx !=
NULL );
2678 assert( rep == SPxSolver::ROW || rep == SPxSolver::COLUMN );
2679 assert( type == SPxSolver::ENTER || type == SPxSolver::LEAVE );
2681 SCIPdebugMessage(
"calling SoPlex solve(): %d cols, %d rows\n", lpi->spx->nCols(), lpi->spx->nRows());
2683 invalidateSolution(lpi);
2685 assert( lpi->spx->preStrongbranchingBasisFreed() );
2688 lpi->spx->setRep(rep);
2689 lpi->spx->setType(type);
2691 #ifdef WITH_LPSCHECK
2692 lpi->spx->setDoubleCheck(CHECK_SPXSOLVE);
2695 SPxSolver::Status status = lpi->spx->solve();
2696 SCIPdebugMessage(
" -> SoPlex status: %d, basis status: %d\n", lpi->spx->getStatus(), lpi->spx->basis().status());
2701 case SPxSolver::ABORT_TIME:
2702 case SPxSolver::ABORT_ITER:
2703 case SPxSolver::ABORT_VALUE:
2704 case SPxSolver::SINGULAR:
2705 case SPxSolver::REGULAR:
2706 case SPxSolver::UNKNOWN:
2707 case SPxSolver::OPTIMAL:
2708 case SPxSolver::UNBOUNDED:
2709 case SPxSolver::INFEASIBLE:
2726 assert(lpi !=
NULL);
2727 assert(lpi->spx !=
NULL);
2731 if( lpi->rowrepswitch >= 0 )
2733 rowrep = lpi->spx->rep() == SPxSolver::ROW;
2736 rowrep = lpi->spx->nRows() > lpi->spx->nCols() * (lpi->rowrepswitch);
2738 rowrep = lpi->spx->nRows() * 1.1 > lpi->spx->nCols() * (lpi->rowrepswitch);
2753 retcode = rowrep ? spxSolve(lpi, SPxSolver::ROW, SPxSolver::LEAVE) : spxSolve(lpi, SPxSolver::COLUMN, SPxSolver::ENTER);
2754 assert(!rowrep || lpi->spx->rep() == SPxSolver::ROW);
2755 assert(rowrep || lpi->spx->rep() == SPxSolver::COLUMN);
2770 assert(lpi !=
NULL);
2771 assert(lpi->spx !=
NULL);
2775 if( lpi->rowrepswitch >= 0 )
2777 rowrep = lpi->spx->rep() == SPxSolver::ROW;
2780 rowrep = lpi->spx->nRows() > lpi->spx->nCols() * (lpi->rowrepswitch);
2782 rowrep = lpi->spx->nRows() * 1.1 > lpi->spx->nCols() * (lpi->rowrepswitch);
2797 retcode = rowrep ? spxSolve(lpi, SPxSolver::ROW, SPxSolver::ENTER) : spxSolve(lpi, SPxSolver::COLUMN, SPxSolver::LEAVE);
2798 assert(!rowrep || lpi->spx->rep() == SPxSolver::ROW);
2799 assert(rowrep || lpi->spx->rep() == SPxSolver::COLUMN);
2822 assert( lpi->spx->preStrongbranchingBasisFreed() );
2823 lpi->spx->savePreStrongbranchingBasis();
2833 assert( ! lpi->spx->preStrongbranchingBasisFreed() );
2834 lpi->spx->restorePreStrongbranchingBasis();
2835 lpi->spx->freePreStrongbranchingBasis();
2857 SPxSolver::Status status;
2862 bool fromparentbasis;
2866 SCIPdebugMessage(
"calling SCIPlpiStrongbranch() on variable %d (%d iterations)\n", col, itlim);
2868 assert(lpi !=
NULL);
2869 assert(lpi->spx !=
NULL);
2872 assert(downvalid !=
NULL);
2873 assert(upvalid !=
NULL);
2876 status = SPxSolver::UNKNOWN;
2877 fromparentbasis =
false;
2879 oldItlim = spx->getIterationLimit();
2882 oldlb = spx->lower(col);
2883 oldub = spx->upper(col);
2892 lpi->spx->setType( lpi->spx->rep() == SPxSolver::ROW ? SPxSolver::ENTER : SPxSolver::LEAVE);
2895 newub =
EPSCEIL(psol-1.0, lpi->spx->feastol());
2896 if( newub >= oldlb - 0.5 && down !=
NULL )
2898 SCIPdebugMessage(
"strong branching down on x%d (%g) with %d iterations\n", col, psol, itlim);
2900 spx->changeUpper(col, newub);
2901 assert(spx->lower(col) <= spx->upper(col));
2903 spx->setIterationLimit(itlim);
2906 #ifdef WITH_LPSCHECK
2907 spx->setDoubleCheck(CHECK_SPXSTRONGBRANCH);
2909 status = spx->solve();
2913 case SPxSolver::OPTIMAL:
2914 *down = spx->value();
2918 case SPxSolver::ABORT_TIME:
2919 case SPxSolver::ABORT_ITER:
2920 case SPxSolver::ABORT_CYCLING:
2921 *down = spx->value();
2923 case SPxSolver::ABORT_VALUE:
2924 case SPxSolver::INFEASIBLE:
2925 *down = spx->terminationValue();
2933 (*iter) += spx->iterations();
2935 #ifdef STRONGBRANCH_RESTOREBASIS
2937 assert( ! spx->preStrongbranchingBasisFreed() );
2938 spx->restorePreStrongbranchingBasis();
2939 fromparentbasis =
false;
2943 if( (status == SPxSolver::ABORT_CYCLING || status == SPxSolver::SINGULAR) && !fromparentbasis && spx->iterations() < itlim )
2945 SCIPdebugMessage(
" --> Repeat strong branching down with %d iterations after restoring basis\n", itlim - spx->iterations());
2946 spx->setIterationLimit(itlim - spx->iterations());
2947 assert( ! spx->hasPreStrongbranchingBasis() );
2948 spx->restorePreStrongbranchingBasis();
2949 fromparentbasis =
true;
2954 fromparentbasis =
false;
2957 while( fromparentbasis );
2959 spx->changeUpper(col, oldub);
2960 assert(spx->lower(col) <= spx->upper(col));
2962 else if( down !=
NULL )
2964 *down = spx->terminationValue();
2973 newlb =
EPSFLOOR(psol+1.0, lpi->spx->feastol());
2974 if( newlb <= oldub + 0.5 && up !=
NULL )
2976 SCIPdebugMessage(
"strong branching up on x%d (%g) with %d iterations\n", col, psol, itlim);
2978 spx->changeLower(col, newlb);
2979 assert(spx->lower(col) <= spx->upper(col));
2981 spx->setIterationLimit(itlim);
2984 #ifdef WITH_LPSCHECK
2985 spx->setDoubleCheck(CHECK_SPXSTRONGBRANCH);
2987 status = spx->solve();
2991 case SPxSolver::OPTIMAL:
2996 case SPxSolver::ABORT_TIME:
2997 case SPxSolver::ABORT_ITER:
2998 case SPxSolver::ABORT_CYCLING:
3001 case SPxSolver::ABORT_VALUE:
3002 case SPxSolver::INFEASIBLE:
3003 *up = spx->terminationValue();
3011 (*iter) += spx->iterations();
3013 #ifdef STRONGBRANCH_RESTOREBASIS
3015 assert( ! spx->preStrongbranchingBasisFreed() );
3016 spx->restorePreStrongbranchingBasis();
3017 fromparentbasis =
false;
3021 else if( (status == SPxSolver::ABORT_CYCLING || status == SPxSolver::SINGULAR) && !fromparentbasis && spx->iterations() < itlim )
3023 SCIPdebugMessage(
" --> Repeat strong branching up with %d iterations after restoring basis\n", itlim - spx->iterations());
3024 assert( ! spx->hasPreStrongbranchingBasis() );
3025 spx->restorePreStrongbranchingBasis();
3026 spx->setIterationLimit(itlim - spx->iterations());
3028 fromparentbasis =
true;
3032 fromparentbasis =
false;
3035 while( fromparentbasis );
3037 spx->changeLower(col, oldlb);
3038 assert(spx->lower(col) <= spx->upper(col));
3040 else if( up !=
NULL )
3042 *up = spx->terminationValue();
3050 spx->setIterationLimit(oldItlim);
3054 SCIPdebugMessage(
"SCIPlpiStrongbranch() returned SoPlex status %d\n",
int(status));
3079 retcode = lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter);
3109 assert( cols !=
NULL );
3110 assert( psols !=
NULL );
3111 assert( down !=
NULL );
3112 assert( up !=
NULL );
3113 assert( downvalid !=
NULL );
3114 assert( upvalid !=
NULL );
3115 assert( down !=
NULL );
3120 for (
int j = 0; j < ncols; ++j)
3123 retcode = lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter);
3153 retcode = lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter);
3183 assert( cols !=
NULL );
3184 assert( psols !=
NULL );
3185 assert( down !=
NULL );
3186 assert( up !=
NULL );
3187 assert( downvalid !=
NULL );
3188 assert( upvalid !=
NULL );
3189 assert( down !=
NULL );
3194 for (
int j = 0; j < ncols; ++j)
3197 retcode = lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter);
3226 assert(lpi !=
NULL);
3240 assert(lpi !=
NULL);
3241 assert(primalfeasible !=
NULL);
3242 assert(dualfeasible !=
NULL);
3259 assert(lpi !=
NULL);
3260 assert(lpi->spx !=
NULL);
3262 return (lpi->spx->getStatus() == SPxSolver::UNBOUNDED);
3274 assert(lpi !=
NULL);
3275 assert(lpi->spx !=
NULL);
3277 #if ((SOPLEX_VERSION == 150 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 150)
3278 return (lpi->spx->getStatus() == SPxSolver::UNBOUNDED);
3291 assert(lpi !=
NULL);
3292 assert(lpi->spx !=
NULL);
3294 assert(lpi->spx->getStatus() != SPxSolver::UNBOUNDED || lpi->spx->basis().status() == SPxBasis::UNBOUNDED);
3299 return (lpi->spx->getStatus() == SPxSolver::UNBOUNDED && !lpi->spx->isPerturbed());
3309 assert(lpi !=
NULL);
3310 assert(lpi->spx !=
NULL);
3312 return (lpi->spx->getStatus() == SPxSolver::INFEASIBLE);
3320 SPxBasis::SPxStatus basestatus;
3324 assert(lpi !=
NULL);
3325 assert(lpi->spx !=
NULL);
3327 basestatus = lpi->spx->basis().status();
3332 assert(basestatus == SPxBasis::OPTIMAL || lpi->spx->getStatus() != SPxSolver::OPTIMAL);
3334 return basestatus == SPxBasis::OPTIMAL ||
3335 ((basestatus == SPxBasis::PRIMAL || basestatus == SPxBasis::UNBOUNDED) && !lpi->spx->isPerturbed());
3347 assert(lpi !=
NULL);
3348 assert(lpi->spx !=
NULL);
3350 return (lpi->spx->getStatus() == SPxSolver::INFEASIBLE);
3362 assert(lpi !=
NULL);
3363 assert(lpi->spx !=
NULL);
3365 return (lpi->spx->getStatus() == SPxSolver::INFEASIBLE);
3375 assert(lpi !=
NULL);
3376 assert(lpi->spx !=
NULL);
3378 return (lpi->spx->getStatus() == SPxSolver::INFEASIBLE && lpi->spx->basis().status() == SPxBasis::DUAL
3379 && !lpi->spx->isPerturbed());
3389 assert(lpi !=
NULL);
3390 assert(lpi->spx !=
NULL);
3392 return (lpi->spx->getStatus() == SPxSolver::UNBOUNDED);
3402 assert(lpi !=
NULL);
3403 assert(lpi->spx !=
NULL);
3408 assert(lpi->spx->basis().status() == SPxBasis::OPTIMAL || lpi->spx->getStatus() != SPxSolver::OPTIMAL);
3410 return (lpi->spx->basis().status() == SPxBasis::OPTIMAL) ||
3411 (lpi->spx->basis().status() == SPxBasis::DUAL && !lpi->spx->isPerturbed());
3421 assert(lpi !=
NULL);
3422 assert((lpi->spx->basis().status() == SPxBasis::OPTIMAL)
3428 return (lpi->spx->basis().status() == SPxBasis::OPTIMAL);
3438 assert(lpi !=
NULL);
3439 assert(lpi->spx !=
NULL);
3441 #if ((SOPLEX_VERSION == 172 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 172)
3459 if( kappa > lpi->conditionlimit )
3464 return (lpi->spx->getStatus() != SPxSolver::ERROR && lpi->spx->getStatus() != SPxSolver::SINGULAR);
3474 assert(lpi !=
NULL);
3475 assert(lpi->spx !=
NULL);
3477 return (lpi->spx->getStatus() == SPxSolver::ABORT_VALUE);
3487 assert(lpi !=
NULL);
3488 assert(lpi->spx !=
NULL);
3490 return (lpi->spx->getStatus() == SPxSolver::ABORT_ITER);
3500 assert(lpi !=
NULL);
3501 assert(lpi->spx !=
NULL);
3503 return (lpi->spx->getStatus() == SPxSolver::ABORT_TIME);
3513 assert(lpi !=
NULL);
3514 assert(lpi->spx !=
NULL);
3516 return static_cast<int>(lpi->spx->getStatus());
3527 assert(lpi !=
NULL);
3528 assert(lpi->spx !=
NULL);
3544 assert(lpi !=
NULL);
3545 assert(lpi->spx !=
NULL);
3546 assert(objval !=
NULL);
3548 *objval = lpi->spx->value();
3565 assert(lpi !=
NULL);
3566 assert(lpi->spx !=
NULL);
3568 if( objval !=
NULL )
3569 *objval = lpi->spx->value();
3573 if( primsol !=
NULL )
3575 Vector tmp(lpi->spx->nCols(), primsol);
3576 (void)lpi->spx->getPrimal(tmp);
3578 if( dualsol !=
NULL )
3580 Vector tmp(lpi->spx->nRows(), dualsol);
3581 (void)lpi->spx->getDual(tmp);
3583 if( activity !=
NULL )
3585 Vector tmp(lpi->spx->nRows(), activity);
3586 (void)lpi->spx->getSlacks(tmp);
3588 if( redcost !=
NULL )
3590 Vector tmp(lpi->spx->nCols(), redcost);
3591 (void)lpi->spx->getRedCost(tmp);
3594 catch(
const SPxException& x )
3597 std::string s = x.what();
3614 assert(lpi !=
NULL);
3615 assert(lpi->spx !=
NULL);
3617 #if ((SOPLEX_VERSION == 150 && SOPLEX_SUBVERSION >= 2) || SOPLEX_VERSION > 150)
3620 Vector tmp(lpi->spx->nCols(), ray);
3621 (void)lpi->spx->getPrimalray(tmp);
3623 catch(
const SPxException& x )
3626 std::string s = x.what();
3634 SCIPerrorMessage(
"SCIPlpiGetPrimalRay() not supported by SoPlex versions <= 1.5.0\n");
3647 assert(lpi !=
NULL);
3648 assert(lpi->spx !=
NULL);
3652 Vector tmp(lpi->spx->nRows(), dualfarkas);
3653 (void)lpi->spx->getDualfarkas(tmp);
3655 catch(
const SPxException& x )
3658 std::string s = x.what();
3675 assert(lpi !=
NULL);
3676 assert(lpi->spx !=
NULL);
3678 *iterations = lpi->spx->iterations();
3696 assert(lpi !=
NULL);
3697 assert(quality !=
NULL);
3699 #if ((SOPLEX_VERSION == 172 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 172)
3703 assert(lpi !=
NULL);
3704 assert(quality !=
NULL);
3706 SCIPdebugMessage(
"requesting solution quality from SoPlex: quality %d\n", qualityindicator);
3708 switch( qualityindicator )
3725 *quality = lpi->spx->basis().condition(maxiter, tolerance);
3748 assert( spx !=
NULL );
3749 assert( val !=
NULL );
3755 if (! spx->isInitialized() )
3758 assert( 0 <= col && col < spx->nCols() );
3760 if( spx->rep() == SPxSolver::COLUMN )
3763 if (spx->getSense() == SPxLP::MINIMIZE)
3764 *val = spx->pVec()[col] - spx->maxObj()[col];
3766 *val = spx->maxObj()[col] - spx->pVec()[col];
3770 assert( spx->rep() == SPxSolver::ROW );
3773 #ifdef SCIP_DISABLED_CODE
3776 if ( spx->getSense() == SPxLP::MINIMIZE )
3779 if ( spx->isColBasic(col) )
3782 for (
int i = spx->dim() - 1; i >= 0; --i)
3784 SPxId
id = spx->basis().baseId(i);
3785 if (
id.isSPxColId() && col == spx->number(SPxColId(
id)) )
3787 *val = sign * spx->fVec()[i];
3811 assert(lpi !=
NULL);
3812 assert(lpi->spx !=
NULL);
3814 assert( lpi->spx->preStrongbranchingBasisFreed() );
3818 for( i = 0; i < lpi->spx->nRows(); ++i )
3820 switch( lpi->spx->getBasisRowStatus(i) )
3822 case SPxSolver::BASIC:
3825 case SPxSolver::FIXED:
3826 case SPxSolver::ON_LOWER:
3829 case SPxSolver::ON_UPPER:
3832 case SPxSolver::ZERO:
3833 SCIPerrorMessage(
"slack variable has basis status ZERO (should not occur)\n");
3835 case SPxSolver::UNDEFINED:
3846 for( i = 0; i < lpi->spx->nCols(); ++i )
3849 switch( lpi->spx->getBasisColStatus(i) )
3851 case SPxSolver::BASIC:
3854 case SPxSolver::FIXED:
3860 SCIP_CALL( getRedCostEst(lpi->spx, i, &val) );
3866 case SPxSolver::ON_LOWER:
3869 case SPxSolver::ON_UPPER:
3872 case SPxSolver::ZERO:
3875 case SPxSolver::UNDEFINED:
3895 int nCols = lpi->spx->nCols();
3896 int nRows = lpi->spx->nRows();
3900 assert(lpi !=
NULL);
3901 assert(lpi->spx !=
NULL);
3902 assert(cstat !=
NULL || nCols == 0);
3903 assert(rstat !=
NULL || nRows == 0);
3905 assert( lpi->spx->preStrongbranchingBasisFreed() );
3906 invalidateSolution(lpi);
3908 SPxSolver::VarStatus* spxcstat =
NULL;
3909 SPxSolver::VarStatus* spxrstat =
NULL;
3910 SCIP_ALLOC( BMSallocMemoryArray(&spxcstat, nCols) );
3911 SCIP_ALLOC( BMSallocMemoryArray(&spxrstat, nRows) );
3913 for( i = 0; i < nRows; ++i )
3915 assert( rstat != 0 );
3919 spxrstat[i] = SPxSolver::ON_LOWER;
3922 spxrstat[i] = SPxSolver::BASIC;
3925 spxrstat[i] = SPxSolver::ON_UPPER;
3928 SCIPerrorMessage(
"slack variable has basis status ZERO (should not occur)\n");
3929 BMSfreeMemoryArrayNull(&spxcstat);
3930 BMSfreeMemoryArrayNull(&spxrstat);
3939 for( i = 0; i < nCols; ++i )
3941 assert( cstat != 0 );
3945 spxcstat[i] = SPxSolver::ON_LOWER;
3948 spxcstat[i] = SPxSolver::BASIC;
3951 spxcstat[i] = SPxSolver::ON_UPPER;
3954 spxcstat[i] = SPxSolver::ZERO;
3963 SOPLEX_TRY( lpi->messagehdlr, lpi->spx->setBasis(spxrstat, spxcstat) );
3964 (void) lpi->spx->updateStatus();
3966 BMSfreeMemoryArrayNull(&spxcstat);
3967 BMSfreeMemoryArrayNull(&spxrstat);
3982 assert(lpi !=
NULL);
3983 assert(lpi->spx !=
NULL);
3985 assert( lpi->spx->preStrongbranchingBasisFreed() );
3993 if( spx->rep() == SPxSolver::COLUMN )
3995 for(
int i = 0; i < spx->nRows(); ++i )
3997 SPxId
id = spx->basis().baseId(i);
3999 bind[i] = (
id.isSPxColId() ? spx->number(
id) : - 1 - spx->number(
id));
4007 assert( spx->rep() == SPxSolver::ROW );
4009 for(
int i = 0; i < spx->nRows(); ++i )
4011 if( !spx->isRowBasic(i) )
4015 for(
int j = 0; j < spx->nCols(); ++j )
4017 if( !spx->isColBasic(j) )
4021 assert(k == spx->nRows());
4034 SCIPdebugMessage(
"Preparing factorization for computation of basis inverse.\n");
4039 if ( lpi->factorization == 0 )
4041 SPxSolver* spx = lpi->spx;
4044 DataArray <const SVector*> matrix(spx->nRows());
4047 for (
int i = 0; i < spx->nRows(); ++i)
4049 if ( ! spx->isRowBasic(i) )
4050 matrix[k++] =
new UnitVector(i);
4052 for (
int j = 0; j < spx->nCols(); ++j)
4054 if ( ! spx->isColBasic(j) )
4055 matrix[k++] = &spx->colVector(j);
4057 assert( k == spx->nRows() );
4058 assert( k == matrix.size() );
4061 lpi->factorization =
new SLUFactor;
4063 SLinSolver::Status status = lpi->factorization->load(matrix.get_ptr(), k);
4065 (void) lpi->factorization->load(matrix.get_ptr(), k);
4067 assert( status == SLinSolver::OK );
4068 assert( k == lpi->factorization->dim() );
4072 for (
int i = 0; i < spx->nRows(); ++i)
4074 if ( ! spx->isRowBasic(i) )
4079 catch(
const SPxException& x )
4082 std::string s = x.what();
4106 assert( lpi !=
NULL );
4107 assert( lpi->spx !=
NULL );
4108 assert( lpi->spx->preStrongbranchingBasisFreed() );
4110 int nCols = lpi->spx->nCols();
4111 int nRows = lpi->spx->nRows();
4118 SPxSolver* spx = lpi->spx;
4120 Vector x(nRows, coef);
4123 if ( spx->rep() == SPxSolver::COLUMN )
4132 spx->basis().coSolve(x, e);
4136 assert(spx->rep() == SPxSolver::ROW);
4139 DVector e(spx->nRows());
4147 assert( lpi->factorization != 0 );
4148 assert( lpi->factorization->dim() == spx->nRows() );
4151 lpi->factorization->solveLeft(x, e);
4154 DSVector rhs(nCols);
4161 SCIP_ALLOC( BMSallocMemoryArray(&bind, nRows) );
4174 assert(idx < nRows);
4175 assert(!spx->isRowBasic(idx));
4178 rhs = spx->rowVector(idx);
4185 assert(idx < nCols);
4186 assert(!spx->isColBasic(idx));
4189 rhs = spx->unitVector(idx);
4193 spx->basis().solve(y, rhs);
4196 BMSclearMemoryArray(coef, nRows);
4199 for(
int i = 0; i < nCols; ++i )
4201 SPxId
id = spx->basis().baseId(i);
4203 if(
id.isSPxRowId() )
4205 assert(spx->number(
id) >= 0);
4206 assert(spx->number(
id) < nRows);
4207 assert(bind[r] >= 0 || spx->number(
id) != idx);
4209 x[spx->number(
id)] = y[i];
4216 assert(x[idx] == 0.0);
4221 BMSfreeMemoryArray(&bind);
4225 catch(
const SPxException& x )
4228 std::string s = x.what();
4247 assert(lpi !=
NULL);
4248 assert(lpi->spx !=
NULL);
4249 assert(lpi->spx->preStrongbranchingBasisFreed());
4250 assert(rhs !=
NULL);
4251 assert(coef !=
NULL);
4253 int nCols = lpi->spx->nCols();
4254 int nRows = lpi->spx->nRows();
4258 SPxSolver* spx = lpi->spx;
4259 Vector v(nRows, rhs);
4260 Vector x(nRows, coef);
4263 if( spx->rep() == SPxSolver::COLUMN )
4266 spx->basis().solve(x, v);
4270 assert(spx->rep() == SPxSolver::ROW);
4275 assert(lpi->factorization != 0);
4276 assert(lpi->factorization->dim() == spx->nRows());
4279 lpi->factorization->solveRight(x, v);
4281 DSVector rowrhs(nCols);
4287 SCIP_ALLOC( BMSallocMemoryArray(&bind, nRows) );
4291 for(
int i = 0; i < nCols; ++i )
4293 SPxId
id = spx->basis().baseId(i);
4295 if(
id.isSPxRowId() )
4297 assert(spx->number(
id) >= 0);
4298 assert(spx->number(
id) < nRows);
4300 rowrhs.add(i, v[spx->number(
id)]);
4304 assert(rowrhs[i] == 0.0);
4309 spx->basis().coSolve(y, rowrhs);
4312 for(
int i = 0; i < nRows; ++i )
4324 assert(idx < nRows);
4325 assert(!spx->isRowBasic(idx));
4327 x[i] = v[idx] - (spx->rowVector(idx) * Vector(nCols, y.get_ptr()));
4333 assert(idx < nCols);
4334 assert(!spx->isColBasic(idx));
4341 BMSfreeMemoryArray(&bind);
4345 catch(
const SPxException& x )
4348 std::string s = x.what();
4375 assert( lpi !=
NULL );
4376 assert( lpi->spx !=
NULL );
4377 assert( lpi->spx->preStrongbranchingBasisFreed() );
4380 DVector e(lpi->spx->nRows());
4385 assert(c < lpi->spx->nRows());
4389 SCIP_CALL( lpiGetBInvVec(lpi, e.get_ptr(), coef) );
4415 assert(lpi !=
NULL);
4416 assert(lpi->spx !=
NULL);
4417 assert( lpi->spx->preStrongbranchingBasisFreed() );
4419 nrows = lpi->spx->nRows();
4420 ncols = lpi->spx->nCols();
4424 if( binvrow ==
NULL )
4426 SCIP_ALLOC( BMSallocMemoryArray(&buf, nrows) );
4433 assert(binv !=
NULL);
4436 soplex::Vector binvvec(nrows, binv);
4437 for( c = 0; c < ncols; ++c )
4438 coef[c] = binvvec * lpi->spx->colVector(c);
4441 BMSfreeMemoryArrayNull(&buf);
4458 DVector col(lpi->spx->nRows());
4462 assert( lpi !=
NULL );
4463 assert( lpi->spx !=
NULL );
4464 assert( lpi->spx->preStrongbranchingBasisFreed() );
4468 assert(c < lpi->spx->nCols());
4471 col = lpi->spx->colVector(c);
4472 col.reDim(lpi->spx->nRows());
4475 SCIP_CALL( lpiGetBInvVec(lpi, col.get_ptr(), coef) );
4504 assert(blkmem !=
NULL);
4505 assert(lpi !=
NULL);
4506 assert(lpi->spx !=
NULL);
4507 assert(lpistate !=
NULL);
4509 assert( lpi->spx->preStrongbranchingBasisFreed() );
4511 ncols = lpi->spx->nCols();
4512 nrows = lpi->spx->nRows();
4517 SCIP_CALL( lpistateCreate(lpistate, blkmem, ncols, nrows) );
4520 SCIP_CALL( ensureCstatMem(lpi, ncols) );
4521 SCIP_CALL( ensureRstatMem(lpi, nrows) );
4527 (*lpistate)->ncols = ncols;
4528 (*lpistate)->nrows = nrows;
4529 lpistatePack(*lpistate, lpi->cstat, lpi->rstat);
4549 assert(lpi !=
NULL);
4550 assert(lpi->spx !=
NULL);
4551 assert(lpistate !=
NULL);
4553 assert( lpi->spx->preStrongbranchingBasisFreed() );
4555 lpncols = lpi->spx->nCols();
4556 lpnrows = lpi->spx->nRows();
4557 assert(lpistate->ncols <= lpncols);
4558 assert(lpistate->nrows <= lpnrows);
4561 SCIP_CALL( ensureCstatMem(lpi, lpncols) );
4562 SCIP_CALL( ensureRstatMem(lpi, lpnrows) );
4565 lpistateUnpack(lpistate, lpi->cstat, lpi->rstat);
4568 for( i = lpistate->ncols; i < lpncols; ++i )
4574 bnd = lpi->spx->lower(i);
4583 for( i = lpistate->nrows; i < lpnrows; ++i )
4599 assert(lpi !=
NULL);
4600 assert(lpi->spx !=
NULL);
4606 catch(
const SPxException& x )
4609 std::string s = x.what();
4612 assert( lpi->spx->getStatus() != SPxSolver::OPTIMAL );
4628 assert(lpi !=
NULL);
4629 assert(lpistate !=
NULL);
4631 if ( *lpistate !=
NULL )
4632 lpistateFree(lpistate, blkmem);
4654 assert( lpi->spx->preStrongbranchingBasisFreed() );
4657 SOPLEX_TRY( lpi->messagehdlr, success = lpi->spx->readBasisFile(fname, 0, 0) );
4670 assert( lpi->spx->preStrongbranchingBasisFreed() );
4673 SOPLEX_TRY( lpi->messagehdlr, res = lpi->spx->writeBasisFile(fname, 0, 0) );
4702 assert(lpinorms !=
NULL);
4718 assert(lpinorms ==
NULL);
4731 assert(lpinorms ==
NULL);
4758 assert(lpi !=
NULL);
4759 assert(lpi->spx !=
NULL);
4760 assert(ival !=
NULL);
4765 *ival = lpi->spx->getFromScratch();
4768 *ival = lpi->spx->getLpInfo();
4771 *ival = lpi->spx->getIterationLimit();
4774 *ival = lpi->spx->getPresolving();
4777 *ival = (int)lpi->pricing;
4780 *ival = lpi->spx->getScaling();
4782 #if SOPLEX_VERSION >= 201
4784 *ival = (int) lpi->spx->getTiming();
4803 assert(lpi !=
NULL);
4804 assert(lpi->spx !=
NULL);
4810 lpi->spx->setFromScratch(
bool(ival));
4814 lpi->spx->setLpInfo(
bool(ival));
4818 lpi->spx->setIterationLimit(ival);
4822 lpi->spx->setPresolving(
bool(ival));
4826 switch( lpi->pricing )
4830 lpi->spx->setAutoPricer();
4833 lpi->spx->setFullPricer();
4836 lpi->spx->setParmultPricer();
4839 lpi->spx->setSteepPricer();
4842 lpi->spx->setSteepQStartPricer();
4845 lpi->spx->setDevexPricer();
4853 lpi->spx->setScaling(
bool(ival));
4855 #if SOPLEX_VERSION >= 201
4857 assert(ival >= 0 && ival < 3);
4858 lpi->spx->setTiming((Timer::TYPE) ival);
4877 assert(lpi !=
NULL);
4878 assert(lpi->spx !=
NULL);
4879 assert(dval !=
NULL);
4884 *dval = lpi->spx->feastol();
4886 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160)
4888 *dval = lpi->spx->opttol();
4892 *dval = lpi->spx->getObjLoLimit();
4895 *dval = lpi->spx->getObjUpLimit();
4898 *dval = lpi->spx->terminationTime();
4901 *dval = lpi->rowrepswitch;
4904 *dval = lpi->conditionlimit;
4922 assert(lpi !=
NULL);
4923 assert(lpi->spx !=
NULL);
4928 lpi->spx->setFeastol(dval);
4930 #if ((SOPLEX_VERSION == 160 && SOPLEX_SUBVERSION >= 5) || SOPLEX_VERSION > 160)
4932 lpi->spx->setOpttol(dval);
4936 lpi->spx->setObjLoLimit(dval);
4939 lpi->spx->setObjUpLimit(dval);
4942 lpi->spx->setTerminationTime(dval);
4945 assert(dval >= -1.5);
4946 lpi->rowrepswitch = dval;
4949 lpi->conditionlimit = dval;
4950 lpi->checkcondition = (dval >= 0);
4978 return soplex::infinity;
4989 return (val >= soplex::infinity);
5007 const char* filename
5012 f = fopen(filename,
"r");
5029 assert(lpi !=
NULL);
5030 assert(lpi->spx !=
NULL);
5032 assert( lpi->spx->preStrongbranchingBasisFreed() );
5034 if( !fileExists(fname) )
5039 if( !lpi->spx->readLP(fname) )
5042 catch(
const SPxException& x )
5045 std::string s = x.what();
5062 assert(lpi !=
NULL);
5063 assert(lpi->spx !=
NULL);
5067 lpi->spx->writeFile(fname);
5069 catch(
const SPxException& x )
5072 std::string s = x.what();
SCIP_RETCODE SCIPlpiScaleCol(SCIP_LPI *lpi, int col, SCIP_Real scaleval)
SCIP_Bool SCIPlpiIsPrimalUnbounded(SCIP_LPI *lpi)
enum SCIP_LPSolQuality SCIP_LPSOLQUALITY
SCIP_RETCODE SCIPlpiDelCols(SCIP_LPI *lpi, int firstcol, int lastcol)
SCIP_RETCODE SCIPlpiReadState(SCIP_LPI *lpi, const char *fname)
SCIP_RETCODE SCIPlpiGetSolFeasibility(SCIP_LPI *lpi, SCIP_Bool *primalfeasible, SCIP_Bool *dualfeasible)
SCIP_RETCODE SCIPlpiLoadColLP(SCIP_LPI *lpi, SCIP_OBJSEN objsen, int ncols, const SCIP_Real *obj, const SCIP_Real *lb, const SCIP_Real *ub, char **colnames, int nrows, const SCIP_Real *lhs, const SCIP_Real *rhs, char **, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
SCIP_Bool SCIPlpiIsIterlimExc(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetNNonz(SCIP_LPI *lpi, int *nnonz)
SCIP_RETCODE SCIPlpiSolveBarrier(SCIP_LPI *lpi, SCIP_Bool crossover)
SCIP_DUALPACKET ROWPACKET
unsigned int SCIP_DUALPACKET
SCIP_RETCODE SCIPlpiGetObjval(SCIP_LPI *lpi, SCIP_Real *objval)
#define AUTOPRICING_ITERSWITCH
enum SCIP_ObjSen SCIP_OBJSEN
SCIP_RETCODE SCIPlpiGetBInvRow(SCIP_LPI *lpi, int r, SCIP_Real *coef)
interface methods for specific LP solvers
SCIP_RETCODE SCIPlpiGetState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
SCIP_RETCODE SCIPlpiGetBase(SCIP_LPI *lpi, int *cstat, int *rstat)
struct SCIP_Messagehdlr SCIP_MESSAGEHDLR
SCIP_Bool SCIPlpiIsObjlimExc(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiIsDualUnbounded(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiFree(SCIP_LPI **lpi)
SCIP_RETCODE SCIPlpiWriteLP(SCIP_LPI *lpi, const char *fname)
SCIP_RETCODE SCIPlpiGetObj(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *vals)
enum SCIP_Retcode SCIP_RETCODE
const char * SCIPlpiGetSolverName(void)
SCIP_RETCODE SCIPlpiSolveDual(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiClearState(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiScaleRow(SCIP_LPI *lpi, int row, SCIP_Real scaleval)
enum SCIP_LPParam SCIP_LPPARAM
SCIP_Bool SCIPlpiHasPrimalRay(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetBInvACol(SCIP_LPI *lpi, int c, SCIP_Real *coef)
SCIP_Bool SCIPlpiIsDualInfeasible(SCIP_LPI *lpi)
enum SCIP_Pricing SCIP_PRICING
SCIP_RETCODE SCIPlpiGetPrimalRay(SCIP_LPI *lpi, SCIP_Real *ray)
SCIP_RETCODE SCIPlpiGetIterations(SCIP_LPI *lpi, int *iterations)
SCIP_Bool SCIPlpiWasSolved(SCIP_LPI *lpi)
#define SOPLEX_TRY(messagehdlr, x)
void SCIPmessagePrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
SCIP_DUALPACKET COLPACKET
SCIP_Bool SCIPlpiIsPrimalInfeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiStrongbranchFrac(SCIP_LPI *lpi, int col, SCIP_Real psol, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
SCIP_RETCODE SCIPlpiDelColset(SCIP_LPI *lpi, int *dstat)
SCIP_RETCODE SCIPlpiStartStrongbranch(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiClear(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetBasisInd(SCIP_LPI *lpi, int *bind)
SCIP_RETCODE SCIPlpiGetBInvCol(SCIP_LPI *lpi, int c, SCIP_Real *coef)
SCIP_Bool SCIPlpiExistsPrimalRay(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetSol(SCIP_LPI *lpi, SCIP_Real *objval, SCIP_Real *primsol, SCIP_Real *dualsol, SCIP_Real *activity, SCIP_Real *redcost)
int SCIPlpiGetInternalStatus(SCIP_LPI *lpi)
SCIP_Real SCIPlpiInfinity(SCIP_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_DUALPACKET ROWPACKET
SCIP_Bool SCIPlpiIsTimelimExc(SCIP_LPI *lpi)
SCIPInterval sign(const SCIPInterval &x)
SCIP_Bool SCIPlpiIsInfinity(SCIP_LPI *, SCIP_Real val)
SCIP_RETCODE SCIPlpiChgCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real newval)
struct SCIP_LPiState SCIP_LPISTATE
SCIP_RETCODE SCIPlpiSetState(SCIP_LPI *lpi, BMS_BLKMEM *, SCIP_LPISTATE *lpistate)
SCIP_RETCODE SCIPlpiFreeState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
SCIP_RETCODE SCIPlpiFreeNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
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 SCIPlpiChgSides(SCIP_LPI *lpi, int nrows, const int *ind, const SCIP_Real *lhs, const SCIP_Real *rhs)
SCIP_Bool SCIPlpiIsDualFeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real *val)
#define SOPLEX_SUBVERSION
#define SOPLEX_TRY_ABORT(x)
SCIP_RETCODE SCIPlpiSetBase(SCIP_LPI *lpi, int *cstat, int *rstat)
SCIP_RETCODE SCIPlpiGetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int *ival)
SCIP_RETCODE SCIPlpiChgObj(SCIP_LPI *lpi, int ncols, int *ind, SCIP_Real *obj)
SCIP_RETCODE SCIPlpiGetBInvARow(SCIP_LPI *lpi, int r, const SCIP_Real *binvrow, SCIP_Real *coef)
SCIP_RETCODE SCIPlpiGetRowNames(SCIP_LPI *lpi, int firstrow, int lastrow, char **rownames, char *namestorage, int namestoragesize, int *storageleft)
SCIP_Bool SCIPlpiIsStable(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetColNames(SCIP_LPI *lpi, int firstcol, int lastcol, char **colnames, char *namestorage, int namestoragesize, int *storageleft)
SCIP_RETCODE SCIPlpiDelRows(SCIP_LPI *lpi, int firstrow, int lastrow)
SCIP_RETCODE SCIPlpiSolvePrimal(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
const char * SCIPlpiGetSolverDesc(void)
SCIP_DUALPACKET COLPACKET
SCIP_RETCODE SCIPlpiSetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS *lpinorms)
SCIP_RETCODE SCIPlpiGetNRows(SCIP_LPI *lpi, int *nrows)
SCIP_RETCODE SCIPlpiSetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int ival)
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 SCIPlpiGetDualfarkas(SCIP_LPI *lpi, SCIP_Real *dualfarkas)
SCIP_RETCODE SCIPlpiEndStrongbranch(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetBounds(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *lbs, SCIP_Real *ubs)
SCIP_Bool SCIPlpiHasStateBasis(SCIP_LPI *lpi, SCIP_LPISTATE *lpistate)
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 SCIPlpiGetSides(SCIP_LPI *lpi, int firstrow, int lastrow, SCIP_Real *lhss, SCIP_Real *rhss)
SCIP_RETCODE SCIPlpiGetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real *dval)
public methods for message output
SCIP_RETCODE SCIPlpiGetRealSolQuality(SCIP_LPI *lpi, SCIP_LPSOLQUALITY qualityindicator, SCIP_Real *quality)
SCIP_Bool SCIPlpiExistsDualRay(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiAddCols(SCIP_LPI *lpi, int ncols, const SCIP_Real *obj, const SCIP_Real *lb, const SCIP_Real *ub, char **, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
SCIP_RETCODE SCIPlpiCreate(SCIP_LPI **lpi, SCIP_MESSAGEHDLR *messagehdlr, const char *name, SCIP_OBJSEN objsen)
SCIP_Bool SCIPlpiIsOptimal(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiChgBounds(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *lb, const SCIP_Real *ub)
SCIP_RETCODE SCIPlpiReadLP(SCIP_LPI *lpi, const char *fname)
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_Bool SCIPlpiHasDualRay(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiIgnoreInstability(SCIP_LPI *lpi, SCIP_Bool *success)
SCIP_RETCODE SCIPlpiChgObjsen(SCIP_LPI *lpi, SCIP_OBJSEN objsen)
SCIP_RETCODE SCIPlpiGetNCols(SCIP_LPI *lpi, int *ncols)
SCIP_RETCODE SCIPlpiGetObjsen(SCIP_LPI *lpi, SCIP_OBJSEN *objsen)
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 SCIPlpiSetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real dval)
SCIP_RETCODE SCIPlpiDelRowset(SCIP_LPI *lpi, int *dstat)
void * SCIPlpiGetSolverPointer(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiIsPrimalFeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiWriteState(SCIP_LPI *lpi, const char *fname)