Clp  1.15.10
OsiClpSolverInterface.hpp
Go to the documentation of this file.
1 // $Id$
2 // Copyright (C) 2000, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 
7 #ifndef OsiClpSolverInterface_H
8 #define OsiClpSolverInterface_H
9 
10 #include <string>
11 #include <cfloat>
12 #include <map>
13 
14 #include "ClpSimplex.hpp"
15 #include "ClpLinearObjective.hpp"
16 #include "CoinPackedMatrix.hpp"
17 #include "OsiSolverInterface.hpp"
18 #include "CoinWarmStartBasis.hpp"
19 #include "ClpEventHandler.hpp"
20 #include "ClpNode.hpp"
21 #include "CoinIndexedVector.hpp"
22 #include "CoinFinite.hpp"
23 
24 class OsiRowCut;
25 class OsiClpUserSolver;
27 class CoinSet;
28 static const double OsiClpInfinity = COIN_DBL_MAX;
29 
30 //#############################################################################
31 
39  virtual public OsiSolverInterface {
40  friend void OsiClpSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir);
41 
42 public:
43  //---------------------------------------------------------------------------
46  virtual void initialSolve();
48 
50  virtual void resolve();
51 
53  virtual void resolveGub(int needed);
54 
56  virtual void branchAndBound();
57 
65  void crossover(int options,int basis);
67 
83  virtual int canDoSimplexInterface() const;
84 
93  virtual void enableFactorization() const;
94 
96  virtual void disableFactorization() const;
97 
102  virtual bool basisIsAvailable() const;
103 
119  virtual void getBasisStatus(int* cstat, int* rstat) const;
120 
131  virtual int setBasisStatus(const int* cstat, const int* rstat);
132 
134  virtual void getReducedGradient(double* columnReducedCosts,
135  double * duals,
136  const double * c) const ;
137 
139  virtual void getBInvARow(int row, double* z, double * slack=NULL) const;
140 
145  virtual void getBInvARow(int row, CoinIndexedVector * z, CoinIndexedVector * slack=NULL,
146  bool keepScaled=false) const;
147 
149  virtual void getBInvRow(int row, double* z) const;
150 
152  virtual void getBInvACol(int col, double* vec) const ;
153 
155  virtual void getBInvACol(int col, CoinIndexedVector * vec) const ;
156 
161  virtual void getBInvACol(CoinIndexedVector * vec) const ;
162 
164  virtual void getBInvCol(int col, double* vec) const ;
165 
170  virtual void getBasics(int* index) const;
171 
178  virtual void enableSimplexInterface(bool doingPrimal);
181 
183  virtual void disableSimplexInterface();
185  void copyEnabledStuff(ClpSimplex & rhs);
186 
194  virtual int pivot(int colIn, int colOut, int outStatus);
195 
207  virtual int primalPivotResult(int colIn, int sign,
208  int& colOut, int& outStatus,
209  double& t, CoinPackedVector* dx);
210 
217  virtual int dualPivotResult(int& colIn, int& sign,
218  int colOut, int outStatus,
219  double& t, CoinPackedVector* dx);
220 
221 
223  //---------------------------------------------------------------------------
239  // Set an integer parameter
240  bool setIntParam(OsiIntParam key, int value);
241  // Set an double parameter
242  bool setDblParam(OsiDblParam key, double value);
243  // Set a string parameter
244  bool setStrParam(OsiStrParam key, const std::string & value);
245  // Get an integer parameter
246  bool getIntParam(OsiIntParam key, int& value) const;
247  // Get an double parameter
248  bool getDblParam(OsiDblParam key, double& value) const;
249  // Get a string parameter
250  bool getStrParam(OsiStrParam key, std::string& value) const;
251  // Set a hint parameter - overrides OsiSolverInterface
252  virtual bool setHintParam(OsiHintParam key, bool yesNo=true,
253  OsiHintStrength strength=OsiHintTry,
254  void * otherInformation=NULL);
256 
257  //---------------------------------------------------------------------------
259 
260  virtual bool isAbandoned() const;
263  virtual bool isProvenOptimal() const;
265  virtual bool isProvenPrimalInfeasible() const;
267  virtual bool isProvenDualInfeasible() const;
269  virtual bool isPrimalObjectiveLimitReached() const;
271  virtual bool isDualObjectiveLimitReached() const;
273  virtual bool isIterationLimitReached() const;
275 
276  //---------------------------------------------------------------------------
279 
287  virtual CoinWarmStart *getEmptyWarmStart () const;
288 
290  virtual CoinWarmStart* getWarmStart() const;
292  inline CoinWarmStartBasis* getPointerToWarmStart()
293  { return &basis_;}
295  inline const CoinWarmStartBasis* getConstPointerToWarmStart() const
296  { return &basis_;}
299  virtual bool setWarmStart(const CoinWarmStart* warmstart);
309  virtual CoinWarmStart* getPointerToWarmStart(bool & mustDelete) ;
310 
312 
313  //---------------------------------------------------------------------------
320  virtual void markHotStart();
323  virtual void solveFromHotStart();
325  virtual void unmarkHotStart();
334  int startFastDual(int options);
336  void stopFastDual();
338  void setStuff(double tolerance,double increment);
340 
341  //---------------------------------------------------------------------------
356  virtual int getNumCols() const {
358  return modelPtr_->numberColumns(); }
359 
361  virtual int getNumRows() const {
362  return modelPtr_->numberRows(); }
363 
365  virtual int getNumElements() const {
366  int retVal = 0;
367  const CoinPackedMatrix * matrix =modelPtr_->matrix();
368  if ( matrix != NULL ) retVal=matrix->getNumElements();
369  return retVal; }
370 
373  virtual std::string getRowName(int rowIndex,
374  unsigned maxLen = static_cast<unsigned>(std::string::npos)) const;
375 
378  virtual std::string getColName(int colIndex,
379  unsigned maxLen = static_cast<unsigned>(std::string::npos)) const;
380 
381 
383  virtual const double * getColLower() const { return modelPtr_->columnLower(); }
384 
386  virtual const double * getColUpper() const { return modelPtr_->columnUpper(); }
387 
397  virtual const char * getRowSense() const;
398 
407  virtual const double * getRightHandSide() const ;
408 
417  virtual const double * getRowRange() const ;
418 
420  virtual const double * getRowLower() const { return modelPtr_->rowLower(); }
421 
423  virtual const double * getRowUpper() const { return modelPtr_->rowUpper(); }
424 
426  virtual const double * getObjCoefficients() const
427  { if (fakeMinInSimplex_)
428  return linearObjective_ ;
429  else
430  return modelPtr_->objective(); }
431 
433  virtual double getObjSense() const
436 
438  virtual bool isContinuous(int colNumber) const;
440  virtual bool isBinary(int colIndex) const;
441 
446  virtual bool isInteger(int colIndex) const;
447 
449  virtual bool isIntegerNonBinary(int colIndex) const;
450 
452  virtual bool isFreeBinary(int colIndex) const;
458  virtual const char * getColType(bool refresh=false) const;
459 
465  bool isOptionalInteger(int colIndex) const;
467  void setOptionalInteger(int index);
468 
470  virtual const CoinPackedMatrix * getMatrixByRow() const;
471 
473  virtual const CoinPackedMatrix * getMatrixByCol() const;
474 
476  virtual CoinPackedMatrix * getMutableMatrixByCol() const;
477 
479  virtual double getInfinity() const { return OsiClpInfinity; }
481 
484  virtual const double * getColSolution() const;
486 
488  virtual const double * getRowPrice() const;
489 
491  virtual const double * getReducedCost() const;
492 
495  virtual const double * getRowActivity() const;
496 
498  virtual double getObjValue() const;
499 
502  virtual int getIterationCount() const
503  { return modelPtr_->numberIterations(); }
504 
522  virtual std::vector<double*> getDualRays(int maxNumRays,
523  bool fullRay = false) const;
535  virtual std::vector<double*> getPrimalRays(int maxNumRays) const;
536 
538 
539 
540  //---------------------------------------------------------------------------
541 
544  //-------------------------------------------------------------------------
548  virtual void setObjCoeff( int elementIndex, double elementValue );
549 
552  virtual void setColLower( int elementIndex, double elementValue );
553 
556  virtual void setColUpper( int elementIndex, double elementValue );
557 
559  virtual void setColBounds( int elementIndex,
560  double lower, double upper );
561 
570  virtual void setColSetBounds(const int* indexFirst,
571  const int* indexLast,
572  const double* boundList);
573 
576  virtual void setRowLower( int elementIndex, double elementValue );
577 
580  virtual void setRowUpper( int elementIndex, double elementValue ) ;
581 
583  virtual void setRowBounds( int elementIndex,
584  double lower, double upper ) ;
585 
587  virtual void setRowType(int index, char sense, double rightHandSide,
588  double range);
589 
598  virtual void setRowSetBounds(const int* indexFirst,
599  const int* indexLast,
600  const double* boundList);
601 
612  virtual void setRowSetTypes(const int* indexFirst,
613  const int* indexLast,
614  const char* senseList,
615  const double* rhsList,
616  const double* rangeList);
621  virtual void setObjective(const double * array);
622 
627  virtual void setColLower(const double * array);
628 
633  virtual void setColUpper(const double * array);
634 
635 // using OsiSolverInterface::setRowName ;
637 // virtual void setRowName(int rowIndex, std::string & name) ;
638  virtual void setRowName(int rowIndex, std::string name) ;
639 
640 // using OsiSolverInterface::setColName ;
642 // virtual void setColName(int colIndex, std::string & name) ;
643  virtual void setColName(int colIndex, std::string name) ;
644 
646 
647  //-------------------------------------------------------------------------
651  virtual void setContinuous(int index);
653  virtual void setInteger(int index);
656  virtual void setContinuous(const int* indices, int len);
659  virtual void setInteger(const int* indices, int len);
661  inline int numberSOS() const
662  { return numberSOS_;}
664  inline const CoinSet * setInfo() const
665  { return setInfo_;}
675  virtual int findIntegersAndSOS(bool justCount);
677 
678  //-------------------------------------------------------------------------
680  virtual void setObjSense(double s )
681  { modelPtr_->setOptimizationDirection( s < 0 ? -1 : 1); }
682 
693  virtual void setColSolution(const double * colsol);
694 
705  virtual void setRowPrice(const double * rowprice);
706 
707  //-------------------------------------------------------------------------
712 
713  //using OsiSolverInterface::addCol ;
715  virtual void addCol(const CoinPackedVectorBase& vec,
716  const double collb, const double colub,
717  const double obj);
720  virtual void addCol(const CoinPackedVectorBase& vec,
721  const double collb, const double colub,
722  const double obj, std::string name) ;
724  virtual void addCol(int numberElements, const int * rows, const double * elements,
725  const double collb, const double colub,
726  const double obj) ;
729  virtual void addCol(int numberElements,
730  const int* rows, const double* elements,
731  const double collb, const double colub,
732  const double obj, std::string name) ;
734  virtual void addCols(const int numcols,
735  const CoinPackedVectorBase * const * cols,
736  const double* collb, const double* colub,
737  const double* obj);
739  virtual void addCols(const int numcols,
740  const int * columnStarts, const int * rows, const double * elements,
741  const double* collb, const double* colub,
742  const double* obj);
744  virtual void deleteCols(const int num, const int * colIndices);
745 
747  virtual void addRow(const CoinPackedVectorBase& vec,
748  const double rowlb, const double rowub);
755  virtual void addRow(const CoinPackedVectorBase& vec,
756  const double rowlb, const double rowub,
757  std::string name) ;
758  virtual void addRow(const CoinPackedVectorBase& vec,
759  const char rowsen, const double rowrhs,
760  const double rowrng);
762  virtual void addRow(int numberElements, const int * columns, const double * element,
763  const double rowlb, const double rowub) ;
766  virtual void addRow(const CoinPackedVectorBase& vec,
767  const char rowsen, const double rowrhs,
768  const double rowrng, std::string name) ;
770  virtual void addRows(const int numrows,
771  const CoinPackedVectorBase * const * rows,
772  const double* rowlb, const double* rowub);
774  virtual void addRows(const int numrows,
775  const CoinPackedVectorBase * const * rows,
776  const char* rowsen, const double* rowrhs,
777  const double* rowrng);
778 
780  virtual void addRows(const int numrows,
781  const int * rowStarts, const int * columns, const double * element,
782  const double* rowlb, const double* rowub);
784  void modifyCoefficient(int row, int column, double newElement,
785  bool keepZero=false)
786  {modelPtr_->modifyCoefficient(row,column,newElement, keepZero);}
787 
789  virtual void deleteRows(const int num, const int * rowIndices);
792  virtual void saveBaseModel() ;
796  virtual void restoreBaseModel(int numberRows);
797 
798  //-----------------------------------------------------------------------
802  virtual void applyRowCuts(int numberCuts, const OsiRowCut * cuts);
807  virtual void applyRowCuts(int numberCuts, const OsiRowCut ** cuts);
830  virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs,
831  double effectivenessLb = 0.0);
832 
834 
835 
836  //---------------------------------------------------------------------------
837 
838 public:
839 
853  virtual void loadProblem(const CoinPackedMatrix& matrix,
854  const double* collb, const double* colub,
855  const double* obj,
856  const double* rowlb, const double* rowub);
857 
865  virtual void assignProblem(CoinPackedMatrix*& matrix,
866  double*& collb, double*& colub, double*& obj,
867  double*& rowlb, double*& rowub);
868 
881  virtual void loadProblem(const CoinPackedMatrix& matrix,
882  const double* collb, const double* colub,
883  const double* obj,
884  const char* rowsen, const double* rowrhs,
885  const double* rowrng);
886 
894  virtual void assignProblem(CoinPackedMatrix*& matrix,
895  double*& collb, double*& colub, double*& obj,
896  char*& rowsen, double*& rowrhs,
897  double*& rowrng);
898 
901  virtual void loadProblem(const ClpMatrixBase& matrix,
902  const double* collb, const double* colub,
903  const double* obj,
904  const double* rowlb, const double* rowub) ;
905 
908  virtual void loadProblem(const int numcols, const int numrows,
909  const CoinBigIndex * start, const int* index,
910  const double* value,
911  const double* collb, const double* colub,
912  const double* obj,
913  const double* rowlb, const double* rowub);
914 
917  virtual void loadProblem(const int numcols, const int numrows,
918  const CoinBigIndex * start, const int* index,
919  const double* value,
920  const double* collb, const double* colub,
921  const double* obj,
922  const char* rowsen, const double* rowrhs,
923  const double* rowrng);
925  virtual int loadFromCoinModel ( CoinModel & modelObject, bool keepSolution=false);
926 
927  using OsiSolverInterface::readMps ;
930  virtual int readMps(const char *filename,
931  const char *extension = "mps") ;
934  int readMps(const char *filename,bool keepNames,bool allowErrors);
936  virtual int readMps (const char *filename, const char*extension,
937  int & numberSets, CoinSet ** & sets);
938 
943  virtual void writeMps(const char *filename,
944  const char *extension = "mps",
945  double objSense=0.0) const;
954  virtual int writeMpsNative(const char *filename,
955  const char ** rowNames, const char ** columnNames,
956  int formatType=0,int numberAcross=2,
957  double objSense=0.0) const ;
959  virtual int readLp(const char *filename, const double epsilon = 1e-5);
965  virtual void writeLp(const char *filename,
966  const char *extension = "lp",
967  double epsilon = 1e-5,
968  int numberAcross = 10,
969  int decimals = 5,
970  double objSense = 0.0,
971  bool useRowNames = true) const;
976  virtual void writeLp(FILE *fp,
977  double epsilon = 1e-5,
978  int numberAcross = 10,
979  int decimals = 5,
980  double objSense = 0.0,
981  bool useRowNames = true) const;
987  virtual void replaceMatrixOptional(const CoinPackedMatrix & matrix);
989  virtual void replaceMatrix(const CoinPackedMatrix & matrix) ;
991 
1002  virtual void passInMessageHandler(CoinMessageHandler * handler);
1004  void newLanguage(CoinMessages::Language language);
1005  void setLanguage(CoinMessages::Language language)
1006  {newLanguage(language);}
1008  void setLogLevel(int value);
1010  void generateCpp( FILE * fp);
1012  //---------------------------------------------------------------------------
1013 
1016  ClpSimplex * getModelPtr() const ;
1019  inline ClpSimplex * swapModelPtr(ClpSimplex * newModel)
1020  { ClpSimplex * model = modelPtr_; modelPtr_=newModel;return model;}
1022  inline unsigned int specialOptions() const
1023  { return specialOptions_;}
1024  void setSpecialOptions(unsigned int value);
1026  inline int lastAlgorithm() const
1027  { return lastAlgorithm_;}
1029  inline void setLastAlgorithm(int value)
1030  { lastAlgorithm_ = value;}
1032  inline int cleanupScaling() const
1033  { return cleanupScaling_;}
1046  inline void setCleanupScaling(int value)
1047  { cleanupScaling_=value;}
1050  inline double smallestElementInCut() const
1051  { return smallestElementInCut_;}
1054  inline void setSmallestElementInCut(double value)
1055  { smallestElementInCut_=value;}
1062  inline double smallestChangeInCut() const
1063  { return smallestChangeInCut_;}
1070  inline void setSmallestChangeInCut(double value)
1071  { smallestChangeInCut_=value;}
1073  inline void setSolveOptions(const ClpSolve & options)
1074  { solveOptions_ = options;}
1078  virtual int tightenBounds(int lightweight=0);
1080  virtual CoinBigIndex getSizeL() const;
1082  virtual CoinBigIndex getSizeU() const;
1085  { return disasterHandler_;}
1090  { return fakeObjective_;}
1094  void setFakeObjective(double * fakeObjective);
1114  void setupForRepeatedUse(int senseOfAdventure=0, int printOut=0);
1116  virtual void synchronizeModel();
1121  void setSpecialOptionsMutable(unsigned int value) const;
1122 
1124 
1125  //---------------------------------------------------------------------------
1126 
1131 
1133  virtual OsiSolverInterface * clone(bool copyData = true) const;
1134 
1137 
1139  OsiClpSolverInterface (ClpSimplex * rhs, bool reallyOwn=false);
1140 
1142  void releaseClp();
1143 
1146 
1148  virtual ~OsiClpSolverInterface ();
1149 
1151  virtual void reset();
1153 
1154  //---------------------------------------------------------------------------
1155 
1156 protected:
1158 
1159 
1160  virtual void applyRowCut(const OsiRowCut& rc);
1161 
1163  virtual void applyColCut(const OsiColCut& cc);
1165 
1166  //---------------------------------------------------------------------------
1167 
1168 protected:
1171  void gutsOfDestructor();
1173 
1175  void freeCachedResults() const;
1176 
1178  void freeCachedResults0() const;
1179 
1181  void freeCachedResults1() const;
1182 
1184  void extractSenseRhsRange() const;
1185 
1187  void fillParamMaps();
1196  CoinWarmStartBasis getBasis(ClpSimplex * model) const;
1205  void setBasis( const CoinWarmStartBasis & basis, ClpSimplex * model);
1207  void crunch();
1209  void redoScaleFactors(int numberRows,const CoinBigIndex * starts,
1210  const int * indices, const double * elements);
1211 public:
1214  void setBasis( const CoinWarmStartBasis & basis);
1216  inline void setBasis( )
1219  CoinWarmStartDiff * getBasisDiff(const unsigned char * statusArray) const ;
1221  CoinWarmStartBasis * getBasis(const unsigned char * statusArray) const ;
1223  void deleteScaleFactors();
1225  inline const double * upRange() const
1226  { return rowActivity_;}
1227  inline const double * downRange() const
1228  { return columnActivity_;}
1230  inline void passInRanges(int * array)
1231  { whichRange_=array;}
1233  void setSOSData(int numberSOS,const char * type,
1234  const int * start,const int * indices, const double * weights=NULL);
1236  void computeLargestAway();
1238  inline double largestAway() const
1239  { return largestAway_;}
1241  inline void setLargestAway(double value)
1242  { largestAway_ = value;}
1244  void lexSolve();
1246 
1247 protected:
1250  mutable ClpSimplex * modelPtr_;
1253 
1255  mutable char *rowsense_;
1257 
1259  mutable double *rhs_;
1260 
1264  mutable double *rowrange_;
1265 
1268  mutable CoinWarmStartBasis* ws_;
1271  mutable double * rowActivity_;
1272  mutable double * columnActivity_;
1278  CoinSet * setInfo_;
1295  CoinWarmStartBasis basis_;
1298 
1309  mutable int lastAlgorithm_;
1310 
1313 
1315  mutable CoinPackedMatrix *matrixByRow_;
1316 
1318  CoinPackedMatrix *matrixByRowAtContinuous_;
1319 
1322 
1328 
1329  //std::map<OsiIntParam, ClpIntParam> intParamMap_;
1330  //std::map<OsiDblParam, ClpDblParam> dblParamMap_;
1331  //std::map<OsiStrParam, ClpStrParam> strParamMap_;
1332 
1334  mutable bool fakeMinInSimplex_ ;
1341  mutable double *linearObjective_;
1342 
1387  mutable unsigned int specialOptions_;
1399  CoinDoubleArrayWithLength rowScale_;
1401  CoinDoubleArrayWithLength columnScale_;
1403 };
1404 
1406 public:
1410  virtual void intoSimplex();
1413  virtual bool check() const ;
1415  virtual void saveInfo();
1417  virtual int typeOfDisaster();
1419 
1420 
1427  virtual ~OsiClpDisasterHandler();
1428  // Copy
1430  // Assignment
1433  virtual ClpDisasterHandler * clone() const;
1434 
1436 
1441  void setOsiModel(OsiClpSolverInterface * model);
1444  { return osiModel_;}
1446  inline void setWhereFrom(int value)
1447  { whereFrom_=value;}
1449  inline int whereFrom() const
1450  { return whereFrom_;}
1452  inline void setPhase(int value)
1453  { phase_=value;}
1455  inline int phase() const
1456  { return phase_;}
1458  inline bool inTrouble() const
1459  { return inTrouble_;}
1460 
1462 
1463 
1464 protected:
1468  OsiClpSolverInterface * osiModel_;
1485  int phase_;
1489 };
1490 // So unit test can find out if NDEBUG set
1491 bool OsiClpHasNDEBUG();
1492 //#############################################################################
1494 void OsiClpSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir);
1495 #endif
ClpLinearObjective * fakeObjective() const
Get fake objective.
virtual void writeLp(const char *filename, const char *extension="lp", double epsilon=1e-5, int numberAcross=10, int decimals=5, double objSense=0.0, bool useRowNames=true) const
Write the problem into an Lp file of the given filename.
virtual int pivot(int colIn, int colOut, int outStatus)
Perform a pivot by substituting a colIn for colOut in the basis.
void setStuff(double tolerance, double increment)
Sets integer tolerance and increment.
This is a very simple class to guide algorithms.
Definition: ClpSolve.hpp:20
char * integerInformation_
Pointer to integer information.
unsigned int specialOptions_
Special options 0x80000000 off 0 simple stuff for branch and bound 1 try and keep work regions as muc...
int numberSOS_
Number of SOS sets.
int phase_
phase 0 initial 1 trying continuing with back in and maybe different perturb 2 trying continuing with...
virtual void branchAndBound()
Invoke solver&#39;s built-in enumeration algorithm.
virtual void initialSolve()
Solve initial LP relaxation.
virtual void markHotStart()
Create a hotstart point of the optimization process.
double smallestElementInCut_
Smallest allowed element in cut.
void redoScaleFactors(int numberRows, const CoinBigIndex *starts, const int *indices, const double *elements)
Extend scale factors.
void lexSolve()
Sort of lexicographic resolve.
bool getDblParam(OsiDblParam key, double &value) const
int lastAlgorithm_
Last algorithm used.
double * linearObjective_
Linear objective.
const CoinWarmStartBasis * getConstPointerToWarmStart() const
Get warmstarting information.
void setLargestAway(double value)
Set largest amount continuous away from bound.
virtual void assignProblem(CoinPackedMatrix *&matrix, double *&collb, double *&colub, double *&obj, double *&rowlb, double *&rowub)
Load in an problem by assuming ownership of the arguments (the constraints on the rows are given by l...
virtual void disableFactorization() const
Undo any setting changes made by enableFactorization.
virtual double getObjSense() const
Get objective function sense (1 for min (default), -1 for max)
virtual bool isProvenOptimal() const
Is optimality proven?
virtual void passInMessageHandler(CoinMessageHandler *handler)
Pass in a message handler.
Abstract base class for Clp Matrices.
bool getStrParam(OsiStrParam key, std::string &value) const
void setWhereFrom(int value)
Set where from.
double * rowActivity_
also save row and column information for hot starts only used in hotstarts so can be casual ...
int numberColumns() const
Definition: ClpModel.hpp:325
virtual void getBInvARow(int row, double *z, double *slack=NULL) const
Get a row of the tableau (slack part in slack if not NULL)
virtual void applyRowCuts(int numberCuts, const OsiRowCut *cuts)
Apply a collection of row cuts which are all effective.
double * objective() const
Objective.
Definition: ClpModel.hpp:651
virtual int primalPivotResult(int colIn, int sign, int &colOut, int &outStatus, double &t, CoinPackedVector *dx)
Obtain a result of the primal pivot Outputs: colOut – leaving column, outStatus – its status...
friend void OsiClpSolverInterfaceUnitTest(const std::string &mpsDir, const std::string &netlibDir)
A function that tests the methods in the OsiClpSolverInterface class.
virtual int readLp(const char *filename, const double epsilon=1e-5)
Read file in LP format (with names)
virtual void enableSimplexInterface(bool doingPrimal)
Enables simplex mode 2 (individual pivot control)
virtual void getBInvACol(int col, double *vec) const
Get a column of the tableau.
virtual ~OsiClpSolverInterface()
Destructor.
void newLanguage(CoinMessages::Language language)
Set language.
int phase() const
Get phase.
ClpSimplex * continuousModel_
Continuous model.
void freeCachedResults0() const
Deletes all mutable stuff for row ranges etc.
void setSpecialOptions(unsigned int value)
ClpSimplex * modelPtr_
Clp model represented by this class instance.
void freeCachedResults() const
Deletes all mutable stuff.
bool setDblParam(OsiDblParam key, double value)
virtual bool isContinuous(int colNumber) const
Return true if column is continuous.
void copyEnabledSuff(OsiClpSolverInterface &rhs)
Copy across enabled stuff from one solver to another.
virtual bool isInteger(int colIndex) const
Return true if column is integer.
Base class for Clp disaster handling.
virtual void synchronizeModel()
Synchronize model (really if no cuts in tree)
virtual void getBInvCol(int col, double *vec) const
Get a column of the basis inverse.
double * rowLower() const
Row lower.
Definition: ClpModel.hpp:496
virtual void setObjSense(double s)
Set objective function sense (1 for min (default), -1 for max,)
double * columnLower() const
Column Lower.
Definition: ClpModel.hpp:683
ClpSimplex * smallModel_
Alternate model (hot starts) - but also could be permanent and used for crunch.
virtual void applyColCut(const OsiColCut &cc)
Apply a column cut (adjust one or more bounds).
Clp Solver Interface.
virtual void writeMps(const char *filename, const char *extension="mps", double objSense=0.0) const
Write the problem into an mps file of the given filename.
ClpSimplex * swapModelPtr(ClpSimplex *newModel)
Set pointer to Clp model and return old.
CoinDoubleArrayWithLength columnScale_
Column scale factors (has inverse at end)
int cleanupScaling() const
Get scaling action option.
void setPhase(int value)
Set phase.
This just implements CoinFactorization when an ClpMatrixBase object is passed.
int lastNumberRows_
Number of rows when last "scaled".
virtual std::string getRowName(int rowIndex, unsigned maxLen=static_cast< unsigned >(std::string::npos)) const
Return name of row if one exists or Rnnnnnnn maxLen is currently ignored and only there to match the ...
virtual void setRowSetTypes(const int *indexFirst, const int *indexLast, const char *senseList, const double *rhsList, const double *rangeList)
Set the type of a number of rows simultaneously The default implementation just invokes setRowType()...
double optimizationDirection() const
Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
Definition: ClpModel.hpp:457
virtual const double * getRowActivity() const
Get pointer to array[getNumRows()] of row activity levels (constraint matrix times the solution vecto...
void setSmallestElementInCut(double value)
Set smallest allowed element in cut.
double * columnUpper() const
Column Upper.
Definition: ClpModel.hpp:690
unsigned int specialOptions() const
Get special options.
void setLogLevel(int value)
Set log level (will also set underlying solver&#39;s log level)
virtual void setColBounds(int elementIndex, double lower, double upper)
Set a single column lower and upper bound.
CoinPackedMatrix * matrix() const
Matrix (if not ClpPackedmatrix be careful about memory leak.
Definition: ClpModel.hpp:697
virtual int getIterationCount() const
Get how many iterations it took to solve the problem (whatever "iteration" mean to the solver...
ClpSimplex * baseModel_
Copy of model when option 131072 set.
virtual void getBasics(int *index) const
Get basic indices (order of indices corresponds to the order of elements in a vector retured by getBI...
virtual void disableSimplexInterface()
Undo setting changes made by enableSimplexInterface.
void generateCpp(FILE *fp)
Create C++ lines to get to current state.
virtual const CoinPackedMatrix * getMatrixByCol() const
Get pointer to column-wise copy of matrix.
virtual void solveFromHotStart()
Optimize starting from the hotstart.
double largestAway() const
Get largest amount continuous away from bound.
OsiClpDisasterHandler * disasterHandler_
Possible disaster handler.
void crossover(int options, int basis)
Solve when primal column and dual row solutions are near-optimal options - 0 no presolve (use primal ...
ClpFactorization * factorization_
factorization for hot starts
OsiClpSolverInterface()
Default Constructor.
virtual void restoreBaseModel(int numberRows)
Strip off rows to get to this number of rows.
virtual int dualPivotResult(int &colIn, int &sign, int colOut, int outStatus, double &t, CoinPackedVector *dx)
Obtain a result of the dual pivot (similar to the previous method) Differences: entering variable and...
virtual int writeMpsNative(const char *filename, const char **rowNames, const char **columnNames, int formatType=0, int numberAcross=2, double objSense=0.0) const
Write the problem into an mps file of the given filename, names may be null.
virtual int findIntegersAndSOS(bool justCount)
Identify integer variables and SOS and create corresponding objects.
virtual void setRowSetBounds(const int *indexFirst, const int *indexLast, const double *boundList)
Set the bounds on a number of rows simultaneously The default implementation just invokes setRowLowe...
double smallestElementInCut() const
Get smallest allowed element in cut.
virtual const char * getColType(bool refresh=false) const
Return array of column length 0 - continuous 1 - binary (may get fixed later) 2 - general integer (ma...
char * spareArrays_
Arrays for hot starts.
void setBasis()
Just puts current basis_ into ClpSimplex model.
virtual void deleteRows(const int num, const int *rowIndices)
virtual const CoinPackedMatrix * getMatrixByRow() const
Get pointer to row-wise copy of matrix.
virtual const double * getRowUpper() const
Get pointer to array[getNumRows()] of row upper bounds.
virtual const double * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
virtual void setObjective(const double *array)
Set the objective coefficients for all columns array [getNumCols()] is an array of values for the obj...
double smallestChangeInCut_
Smallest change in cut.
int cleanupScaling_
Scaling option When scaling is on it is possible that the scaled problem is feasible but the unscaled...
bool setStrParam(OsiStrParam key, const std::string &value)
virtual const char * getRowSense() const
Get pointer to array[getNumRows()] of row constraint senses.
virtual void addCol(const CoinPackedVectorBase &vec, const double collb, const double colub, const double obj)
virtual const double * getColSolution() const
Get pointer to array[getNumCols()] of primal solution vector.
double * rhs_
Pointer to dense vector of row right-hand side values.
double smallestChangeInCut() const
Get smallest change in cut.
virtual void addRow(const CoinPackedVectorBase &vec, const double rowlb, const double rowub)
int numberSOS() const
Number of SOS sets.
void setCleanupScaling(int value)
Set Scaling option When scaling is on it is possible that the scaled problem is feasible but the unsc...
bool OsiClpHasNDEBUG()
virtual void setColUpper(int elementIndex, double elementValue)
Set a single column upper bound Use DBL_MAX for infinity.
bool notOwned_
To say if destructor should delete underlying model.
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:55
virtual CoinBigIndex getSizeL() const
Return number of entries in L part of current factorization.
void setOptimizationDirection(double value)
ClpDataSave saveData_
To save data in OsiSimplex stuff.
void setSolveOptions(const ClpSolve &options)
Pass in initial solve options.
virtual const double * getRightHandSide() const
Get pointer to array[getNumRows()] of rows right-hand sides.
void gutsOfDestructor()
The real work of a copy constructor (used by copy and assignment)
virtual int getNumElements() const
Get number of nonzero elements.
virtual void setColName(int colIndex, std::string name)
Set name of column.
void freeCachedResults1() const
Deletes all mutable stuff for matrix etc.
virtual void setRowUpper(int elementIndex, double elementValue)
Set a single row upper bound Use DBL_MAX for infinity.
virtual void setRowType(int index, char sense, double rightHandSide, double range)
Set the type of a single row
void passInRanges(int *array)
Pass in range array.
void crunch()
Crunch down problem a bit.
virtual CoinWarmStart * getEmptyWarmStart() const
Get an empty warm start object.
int * whichRange_
Pointer to variables for which we want range information The number is in [0] memory is not owned by ...
virtual const double * getRowLower() const
Get pointer to array[getNumRows()] of row lower bounds.
virtual double getInfinity() const
Get solver&#39;s value for infinity.
virtual CoinBigIndex getSizeU() const
Return number of entries in U part of current factorization.
CoinSet * setInfo_
SOS set info.
void modifyCoefficient(int row, int column, double newElement, bool keepZero=false)
virtual void setColSetBounds(const int *indexFirst, const int *indexLast, const double *boundList)
Set the bounds on a number of columns simultaneously The default implementation just invokes setColL...
virtual void replaceMatrix(const CoinPackedMatrix &matrix)
And if it does matter (not used at present)
virtual void setRowName(int rowIndex, std::string name)
Set name of row.
void setFakeObjective(ClpLinearObjective *fakeObjective)
Set fake objective (and take ownership)
int itlimOrig_
The original iteration limit before hotstarts started.
This is a tiny class where data can be saved round calls.
Definition: ClpModel.hpp:1267
void setLastAlgorithm(int value)
Set last algorithm used , 1 = primal, 2 = dual other unknown.
void stopFastDual()
Stop fast dual.
virtual void setContinuous(int index)
Set the index-th variable to be a continuous variable.
virtual bool setHintParam(OsiHintParam key, bool yesNo=true, OsiHintStrength strength=OsiHintTry, void *otherInformation=NULL)
virtual bool isFreeBinary(int colIndex) const
Return true if variable is binary and not fixed at either bound.
OsiClpSolverInterface & operator=(const OsiClpSolverInterface &rhs)
Assignment operator.
virtual int setBasisStatus(const int *cstat, const int *rstat)
Set the status of structural/artificial variables and factorize, update solution etc.
bool inTrouble_
Are we in trouble.
virtual void reset()
Resets as if default constructor.
CoinPackedMatrix * matrixByRow_
Pointer to row-wise copy of problem matrix coefficients.
bool isOptionalInteger(int colIndex) const
Return true if column is integer but does not have to be declared as such.
virtual const double * getReducedCost() const
Get a pointer to array[getNumCols()] of reduced costs.
CoinWarmStartBasis getBasis(ClpSimplex *model) const
Warm start.
ClpNodeStuff stuff_
Stuff for fast dual.
double * rowrange_
Pointer to dense vector of slack upper bounds for range constraints (undefined for non-range rows) ...
double * rowUpper() const
Row upper.
Definition: ClpModel.hpp:503
int lastAlgorithm() const
Last algorithm used , 1 = primal, 2 = dual other unknown.
virtual bool isProvenPrimalInfeasible() const
Is primal infeasiblity proven?
virtual void applyRowCut(const OsiRowCut &rc)
Apply a row cut (append to constraint matrix).
Linear Objective Class.
virtual void setRowPrice(const double *rowprice)
Set dual solution vector.
CoinPackedMatrix * matrixByRowAtContinuous_
Pointer to row-wise copy of continuous problem matrix coefficients.
const CoinSet * setInfo() const
SOS set info.
virtual void setRowBounds(int elementIndex, double lower, double upper)
Set a single row lower and upper bound.
virtual bool isIterationLimitReached() const
Iteration limit reached?
bool fakeMinInSimplex_
Faking min to get proper dual solution signs in simplex API.
static const double OsiClpInfinity
ClpLinearObjective * fakeObjective_
Fake objective.
virtual OsiSolverInterface * clone(bool copyData=true) const
Clone.
virtual int readMps(const char *filename, const char *extension="mps")
Read an mps file from the given filename (defaults to Osi reader) - returns number of errors (see Osi...
virtual void addCols(const int numcols, const CoinPackedVectorBase *const *cols, const double *collb, const double *colub, const double *obj)
CoinWarmStartBasis * getPointerToWarmStart()
Get warmstarting information.
virtual ApplyCutsReturnCode applyCuts(const OsiCuts &cs, double effectivenessLb=0.0)
Apply a collection of cuts.
virtual std::vector< double * > getPrimalRays(int maxNumRays) const
Get as many primal rays as the solver can provide.
ClpSolve solveOptions_
Options for initialSolve.
bool getIntParam(OsiIntParam key, int &value) const
virtual void setColLower(int elementIndex, double elementValue)
Set a single column lower bound Use -DBL_MAX for -infinity.
virtual std::string getColName(int colIndex, unsigned maxLen=static_cast< unsigned >(std::string::npos)) const
Return name of column if one exists or Cnnnnnnn maxLen is currently ignored and only there to match t...
void copyEnabledStuff(ClpSimplex &rhs)
Copy across enabled stuff from one solver to another.
virtual void resolveGub(int needed)
Resolve an LP relaxation after problem modification (try GUB)
void modifyCoefficient(int row, int column, double newElement, bool keepZero=false)
Modify one element of a matrix.
Definition: ClpModel.hpp:231
double largestAway_
Largest amount continuous away from bound.
void extractSenseRhsRange() const
A method that fills up the rowsense_, rhs_ and rowrange_ arrays.
virtual const double * getRowRange() const
Get pointer to array[getNumRows()] of row ranges.
OsiClpSolverInterface * osiModel() const
Get model.
void setSpecialOptionsMutable(unsigned int value) const
Set special options in underlying clp solver.
virtual void replaceMatrixOptional(const CoinPackedMatrix &matrix)
I (JJF) am getting annoyed because I can&#39;t just replace a matrix.
virtual bool isDualObjectiveLimitReached() const
Is the given dual objective limit reached?
CoinWarmStartBasis basis_
Warmstart information to be used in resolves.
void setupForRepeatedUse(int senseOfAdventure=0, int printOut=0)
Set up solver for repeated use by Osi interface.
int numberIterations() const
Number of iterations.
Definition: ClpModel.hpp:363
int numberRows() const
Number of rows.
Definition: ClpModel.hpp:315
virtual void loadProblem(const CoinPackedMatrix &matrix, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub)
Load in an problem by copying the arguments (the constraints on the rows are given by lower and upper...
virtual double getObjValue() const
Get objective function value.
virtual void setRowLower(int elementIndex, double elementValue)
Set a single row lower bound Use -DBL_MAX for -infinity.
virtual const double * getRowPrice() const
Get pointer to array[getNumRows()] of dual prices.
void setSOSData(int numberSOS, const char *type, const int *start, const int *indices, const double *weights=NULL)
Pass in sos stuff from AMPl.
int whereFrom_
Where from 0 dual (resolve) 1 crunch 2 primal (resolve) 4 dual (initialSolve) 6 primal (initialSolve)...
virtual void resolve()
Resolve an LP relaxation after problem modification.
virtual void setInteger(int index)
Set the index-th variable to be an integer variable.
virtual void getReducedGradient(double *columnReducedCosts, double *duals, const double *c) const
Get the reduced gradient for the cost vector c.
virtual void unmarkHotStart()
Delete the snapshot.
virtual void getBasisStatus(int *cstat, int *rstat) const
The following two methods may be replaced by the methods of OsiSolverInterface using OsiWarmStartBasi...
virtual bool isIntegerNonBinary(int colIndex) const
Return true if variable is general integer.
void setSmallestChangeInCut(double value)
Set smallest change in cut.
const double * upRange() const
If doing fast hot start then ranges are computed.
void passInDisasterHandler(OsiClpDisasterHandler *handler)
Pass in disaster handler.
virtual int tightenBounds(int lightweight=0)
Tighten bounds - lightweight or very lightweight 0 - normal, 1 lightweight but just integers...
CoinWarmStartBasis * ws_
A pointer to the warmstart information to be used in the hotstarts.
virtual void getBInvRow(int row, double *z) const
Get a row of the basis inverse.
virtual int canDoSimplexInterface() const
Simplex API capability.
virtual void setColSolution(const double *colsol)
Set the primal solution column values.
virtual const double * getObjCoefficients() const
Get pointer to array[getNumCols()] of objective function coefficients.
virtual CoinWarmStart * getWarmStart() const
Get warmstarting information.
void setLanguage(CoinMessages::Language language)
virtual void deleteCols(const int num, const int *colIndices)
virtual bool isAbandoned() const
Are there a numerical difficulties?
void deleteScaleFactors()
Delete all scale factor stuff and reset option.
int whereFrom() const
Get where from.
void computeLargestAway()
Compute largest amount any at continuous away from bound.
virtual void addRows(const int numrows, const CoinPackedVectorBase *const *rows, const double *rowlb, const double *rowub)
virtual bool isPrimalObjectiveLimitReached() const
Is the given primal objective limit reached?
virtual std::vector< double * > getDualRays(int maxNumRays, bool fullRay=false) const
Get as many dual rays as the solver can provide.
const OsiClpDisasterHandler * disasterHandler() const
Get disaster handler.
virtual const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
virtual void enableFactorization() const
Enables simplex mode 1 (tableau access)
virtual int getNumCols() const
Get number of columns.
bool setIntParam(OsiIntParam key, int value)
CoinDoubleArrayWithLength rowScale_
Row scale factors (has inverse at end)
#define OsiSolverInterface
Definition: Idiot.hpp:14
virtual bool basisIsAvailable() const
Returns true if a basis is available AND problem is optimal.
void setOptionalInteger(int index)
Set the index-th variable to be an optional integer variable.
virtual void setObjCoeff(int elementIndex, double elementValue)
Set an objective function coefficient.
virtual bool isBinary(int colIndex) const
Return true if variable is binary.
bool inTrouble() const
are we in trouble
virtual int getNumRows() const
Get number of rows.
ClpSimplex * getModelPtr() const
Get pointer to Clp model.
const double * downRange() const
char * rowsense_
Pointer to dense vector of row sense indicators.
virtual int loadFromCoinModel(CoinModel &modelObject, bool keepSolution=false)
This loads a model from a coinModel object - returns number of errors.
virtual bool setWarmStart(const CoinWarmStart *warmstart)
Set warmstarting information.
int startFastDual(int options)
Start faster dual - returns negative if problems 1 if infeasible, Options to pass to solver 1 - creat...
virtual bool isProvenDualInfeasible() const
Is dual infeasiblity proven?
void releaseClp()
Releases so won&#39;t error.
CoinWarmStartDiff * getBasisDiff(const unsigned char *statusArray) const
Warm start difference from basis_ to statusArray.
virtual CoinPackedMatrix * getMutableMatrixByCol() const
Get pointer to mutable column-wise copy of matrix.
virtual void saveBaseModel()
If solver wants it can save a copy of "base" (continuous) model here.