CbcModel.hpp
Go to the documentation of this file.
1 /* $Id: CbcModel.hpp 1409 2009-12-21 16:59:56Z forrest $ */
2 // Copyright (C) 2002, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 #ifndef CbcModel_H
5 #define CbcModel_H
6 #include <string>
7 #include <vector>
8 #include "CoinFinite.hpp"
9 #include "CoinMessageHandler.hpp"
10 #include "OsiSolverInterface.hpp"
11 #include "OsiBranchingObject.hpp"
12 #include "OsiCuts.hpp"
13 #include "CoinWarmStartBasis.hpp"
14 #include "CbcCompareBase.hpp"
15 #include "CbcMessage.hpp"
16 #include "CbcEventHandler.hpp"
17 #include "ClpDualRowPivot.hpp"
18 
19 //class OsiSolverInterface;
20 
21 class CbcCutGenerator;
22 class CbcBaseModel;
23 class OsiRowCut;
24 class OsiBabSolver;
25 class OsiRowCutDebugger;
26 class CglCutGenerator;
27 class CglStored;
28 class CbcCutModifier;
29 class CglTreeProbingInfo;
30 class CbcHeuristic;
31 class OsiObject;
32 class CbcThread;
33 class CbcTree;
34 class CbcStrategy;
35 class CbcFeasibilityBase;
36 class CbcStatistics;
37 class CbcEventHandler ;
38 class CglPreProcess;
39 # ifdef COIN_HAS_CLP
40 class ClpNodeStuff;
41 #endif
42 // #define CBC_CHECK_BASIS 1
43 
44 //#############################################################################
45 
98 class CbcModel {
99 
100 public:
101 
102  enum CbcIntParam {
126  };
127 
128  enum CbcDblParam {
192  };
193 
194  //---------------------------------------------------------------------------
195 
196 public:
198 
199 
203  void initialSolve();
204 
215  void branchAndBound(int doStatistics = 0);
216 private:
217 
225  bool solveWithCuts(OsiCuts & cuts, int numberTries, CbcNode * node);
233  int serialCuts(OsiCuts & cuts, CbcNode * node, OsiCuts & slackCuts, int lastNumberCuts);
241  int parallelCuts(CbcBaseModel * master, OsiCuts & cuts, CbcNode * node, OsiCuts & slackCuts, int lastNumberCuts);
248  CbcNode ** solveOneNode(int whichSolver, CbcNode * node,
249  int & numberNodesOutput, int & status) ;
251  void resizeWhichGenerator(int numberNow, int numberAfter);
252 public:
253 #ifdef CBC_KEEP_DEPRECATED
254  // See if anyone is using these any more!!
259  CbcModel * cleanModel(const double * lower, const double * upper);
276  int subBranchAndBound(CbcModel * model2,
277  CbcModel * presolvedModel,
278  int maximumNodes);
294  int subBranchAndBound(const double * lower, const double * upper,
295  int maximumNodes);
296 
303  OsiSolverInterface * strengthenedModel();
313  CglPreProcess * preProcess( int makeEquality = 0, int numberPasses = 5,
314  int tuning = 5);
317  void postProcess(CglPreProcess * process);
318 #endif
319  void addUpdateInformation(const CbcObjectUpdateData & data);
327  int doOneNode(CbcModel * baseModel, CbcNode * & node, CbcNode * & newNode);
328 
329 public:
343  int resolve(CbcNodeInfo * parent, int whereFrom,
344  double * saveSolution = NULL,
345  double * saveLower = NULL,
346  double * saveUpper = NULL);
348  void makeGlobalCuts(int numberRows, const int * which);
350  void makeGlobalCut(const OsiRowCut * cut);
352  void makeGlobalCut(const OsiRowCut & cut);
354  void makeGlobalCut(const OsiColCut * cut);
356  void makeGlobalCut(const OsiColCut & cut);
358 
361 
373  CbcModel * findCliques(bool makeEquality, int atLeastThisMany,
374  int lessThanThis, int defaultValue = 1000);
375 
384  CbcModel * integerPresolve(bool weak = false);
385 
390  bool integerPresolveThisModel(OsiSolverInterface * originalSolver, bool weak = false);
391 
392 
394  void originalModel(CbcModel * presolvedModel, bool weak);
395 
416  bool tightenVubs(int type, bool allowMultipleBinary = false,
417  double useCutoff = 1.0e50);
418 
424  bool tightenVubs(int numberVubs, const int * which,
425  double useCutoff = 1.0e50);
429  void analyzeObjective();
430 
434  void AddIntegers();
435 
439  void saveModel(OsiSolverInterface * saveSolver, double * checkCutoffForRestart, bool * feasible);
440 
442 
448 
450  inline int numberObjects() const {
451  return numberObjects_;
452  }
454  inline void setNumberObjects(int number) {
455  numberObjects_ = number;
456  }
457 
459  inline OsiObject ** objects() const {
460  return object_;
461  }
462 
464  const inline OsiObject * object(int which) const {
465  return object_[which];
466  }
468  inline OsiObject * modifiableObject(int which) const {
469  return object_[which];
470  }
471 
472  void setOptionalInteger(int index);
473 
475  void deleteObjects(bool findIntegers = true);
476 
481  void addObjects(int numberObjects, OsiObject ** objects);
482 
488 
490  void synchronizeModel() ;
491 
501  void findIntegers(bool startAgain, int type = 0);
502 
504 
505  //---------------------------------------------------------------------------
506 
516  inline bool setIntParam(CbcIntParam key, int value) {
518  intParam_[key] = value;
519  return true;
520  }
522  inline bool setDblParam(CbcDblParam key, double value) {
523  dblParam_[key] = value;
524  return true;
525  }
527  inline int getIntParam(CbcIntParam key) const {
528  return intParam_[key];
529  }
531  inline double getDblParam(CbcDblParam key) const {
532  return dblParam_[key];
533  }
539  void setCutoff(double value) ;
540 
542  inline double getCutoff() const { //double value ;
543  //solver_->getDblParam(OsiDualObjectiveLimit,value) ;
544  //assert( dblParam_[CbcCurrentCutoff]== value * solver_->getObjSense());
545  return dblParam_[CbcCurrentCutoff];
546  }
547 
549  inline bool setMaximumNodes( int value) {
550  return setIntParam(CbcMaxNumNode, value);
551  }
552 
554  inline int getMaximumNodes() const {
555  return getIntParam(CbcMaxNumNode);
556  }
557 
562  inline bool setMaximumSolutions( int value) {
563  return setIntParam(CbcMaxNumSol, value);
564  }
569  inline int getMaximumSolutions() const {
570  return getIntParam(CbcMaxNumSol);
571  }
573  inline bool setPrintingMode( int value) {
574  return setIntParam(CbcPrinting, value);
575  }
576 
578  inline int getPrintingMode() const {
579  return getIntParam(CbcPrinting);
580  }
581 
586  inline bool setMaximumSeconds( double value) {
587  return setDblParam(CbcMaximumSeconds, value);
588  }
593  inline double getMaximumSeconds() const {
595  }
597  double getCurrentSeconds() const ;
598 
600  bool maximumSecondsReached() const ;
601 
605  inline bool setIntegerTolerance( double value) {
606  return setDblParam(CbcIntegerTolerance, value);
607  }
611  inline double getIntegerTolerance() const {
613  }
614 
619  inline bool setInfeasibilityWeight( double value) {
620  return setDblParam(CbcInfeasibilityWeight, value);
621  }
626  inline double getInfeasibilityWeight() const {
628  }
629 
633  inline bool setAllowableGap( double value) {
634  return setDblParam(CbcAllowableGap, value);
635  }
639  inline double getAllowableGap() const {
641  }
642 
646  inline bool setAllowableFractionGap( double value) {
647  return setDblParam(CbcAllowableFractionGap, value);
648  }
652  inline double getAllowableFractionGap() const {
654  }
658  inline bool setAllowablePercentageGap( double value) {
659  return setDblParam(CbcAllowableFractionGap, value*0.01);
660  }
664  inline double getAllowablePercentageGap() const {
665  return 100.0*getDblParam(CbcAllowableFractionGap);
666  }
670  inline bool setHeuristicGap( double value) {
671  return setDblParam(CbcHeuristicGap, value);
672  }
676  inline double getHeuristicGap() const {
678  }
679 
683  inline bool setHeuristicFractionGap( double value) {
684  return setDblParam(CbcHeuristicFractionGap, value);
685  }
689  inline double getHeuristicFractionGap() const {
691  }
696  inline bool setCutoffIncrement( double value) {
697  return setDblParam(CbcCutoffIncrement, value);
698  }
703  inline double getCutoffIncrement() const {
705  }
706 
711  void setHotstartSolution(const double * solution, const int * priorities = NULL) ;
712 
714  inline void setMinimumDrop(double value) {
715  minimumDrop_ = value;
716  }
718  inline double getMinimumDrop() const {
719  return minimumDrop_;
720  }
721 
724  inline void setMaximumCutPassesAtRoot(int value) {
725  maximumCutPassesAtRoot_ = value;
726  }
728  inline int getMaximumCutPassesAtRoot() const {
730  }
731 
734  inline void setMaximumCutPasses(int value) {
735  maximumCutPasses_ = value;
736  }
738  inline int getMaximumCutPasses() const {
739  return maximumCutPasses_;
740  }
743  inline int getCurrentPassNumber() const {
744  return currentPassNumber_;
745  }
746 
752  void setNumberStrong(int number);
756  inline int numberStrong() const {
757  return numberStrong_;
758  }
761  inline void setPreferredWay(int value) {
762  preferredWay_ = value;
763  }
765  inline int getPreferredWay() const {
766  return preferredWay_;
767  }
769  inline int whenCuts() const {
770  return whenCuts_;
771  }
773  inline void setWhenCuts(int value) {
774  whenCuts_ = value;
775  }
781  bool doCutsNow(int allowForTopOfTree) const;
782 
788  void setNumberBeforeTrust(int number);
791  inline int numberBeforeTrust() const {
792  return numberBeforeTrust_;
793  }
799  void setNumberPenalties(int number);
802  inline int numberPenalties() const {
803  return numberPenalties_;
804  }
806  inline void setNumberAnalyzeIterations(int number) {
807  numberAnalyzeIterations_ = number;
808  }
809  inline int numberAnalyzeIterations() const {
811  }
814  inline double penaltyScaleFactor() const {
815  return penaltyScaleFactor_;
816  }
819  void setPenaltyScaleFactor(double value);
827  void inline setProblemType(int number) {
828  problemType_ = number;
829  }
830  inline int problemType() const {
831  return problemType_;
832  }
834  inline int currentDepth() const {
835  return currentDepth_;
836  }
837 
839  void setHowOftenGlobalScan(int number);
841  inline int howOftenGlobalScan() const {
842  return howOftenGlobalScan_;
843  }
845  inline int * originalColumns() const {
846  return originalColumns_;
847  }
849  void setOriginalColumns(const int * originalColumns) ;
850 
858  inline void setPrintFrequency(int number) {
859  printFrequency_ = number;
860  }
862  inline int printFrequency() const {
863  return printFrequency_;
864  }
866 
867  //---------------------------------------------------------------------------
869 
870  bool isAbandoned() const;
873  bool isProvenOptimal() const;
875  bool isProvenInfeasible() const;
877  bool isContinuousUnbounded() const;
879  bool isProvenDualInfeasible() const;
881  bool isNodeLimitReached() const;
883  bool isSecondsLimitReached() const;
885  bool isSolutionLimitReached() const;
887  inline int getIterationCount() const {
888  return numberIterations_;
889  }
891  inline void incrementIterationCount(int value) {
892  numberIterations_ += value;
893  }
895  inline int getNodeCount() const {
896  return numberNodes_;
897  }
899  inline void incrementNodeCount(int value) {
900  numberNodes_ += value;
901  }
911  inline int status() const {
912  return status_;
913  }
914  inline void setProblemStatus(int value) {
915  status_ = value;
916  }
928  inline int secondaryStatus() const {
929  return secondaryStatus_;
930  }
931  inline void setSecondaryStatus(int value) {
932  secondaryStatus_ = value;
933  }
935  bool isInitialSolveAbandoned() const ;
937  bool isInitialSolveProvenOptimal() const ;
942 
944 
945  //---------------------------------------------------------------------------
958  inline int numberRowsAtContinuous() const {
961  }
962 
964  inline int getNumCols() const {
965  return solver_->getNumCols();
966  }
967 
969  inline int getNumRows() const {
970  return solver_->getNumRows();
971  }
972 
974  inline CoinBigIndex getNumElements() const {
975  return solver_->getNumElements();
976  }
977 
979  inline int numberIntegers() const {
980  return numberIntegers_;
981  }
982  // Integer variables
983  inline const int * integerVariable() const {
984  return integerVariable_;
985  }
987  inline char integerType(int i) const {
988  assert (integerInfo_);
989  assert (integerInfo_[i] == 0 || integerInfo_[i] == 1);
990  return integerInfo_[i];
991  }
993  inline const char * integerType() const {
994  return integerInfo_;
995  }
996 
998  inline const double * getColLower() const {
999  return solver_->getColLower();
1000  }
1001 
1003  inline const double * getColUpper() const {
1004  return solver_->getColUpper();
1005  }
1006 
1016  inline const char * getRowSense() const {
1017  return solver_->getRowSense();
1018  }
1019 
1028  inline const double * getRightHandSide() const {
1029  return solver_->getRightHandSide();
1030  }
1031 
1040  inline const double * getRowRange() const {
1041  return solver_->getRowRange();
1042  }
1043 
1045  inline const double * getRowLower() const {
1046  return solver_->getRowLower();
1047  }
1048 
1050  inline const double * getRowUpper() const {
1051  return solver_->getRowUpper();
1052  }
1053 
1055  inline const double * getObjCoefficients() const {
1056  return solver_->getObjCoefficients();
1057  }
1058 
1060  inline double getObjSense() const {
1061  //assert (dblParam_[CbcOptimizationDirection]== solver_->getObjSense());
1063  }
1064 
1066  inline bool isContinuous(int colIndex) const {
1067  return solver_->isContinuous(colIndex);
1068  }
1069 
1071  inline bool isBinary(int colIndex) const {
1072  return solver_->isBinary(colIndex);
1073  }
1074 
1079  inline bool isInteger(int colIndex) const {
1080  return solver_->isInteger(colIndex);
1081  }
1082 
1084  inline bool isIntegerNonBinary(int colIndex) const {
1085  return solver_->isIntegerNonBinary(colIndex);
1086  }
1087 
1089  inline bool isFreeBinary(int colIndex) const {
1090  return solver_->isFreeBinary(colIndex) ;
1091  }
1092 
1094  inline const CoinPackedMatrix * getMatrixByRow() const {
1095  return solver_->getMatrixByRow();
1096  }
1097 
1099  inline const CoinPackedMatrix * getMatrixByCol() const {
1100  return solver_->getMatrixByCol();
1101  }
1102 
1104  inline double getInfinity() const {
1105  return solver_->getInfinity();
1106  }
1108  inline const double * getCbcColLower() const {
1109  return cbcColLower_;
1110  }
1112  inline const double * getCbcColUpper() const {
1113  return cbcColUpper_;
1114  }
1116  inline const double * getCbcRowLower() const {
1117  return cbcRowLower_;
1118  }
1120  inline const double * getCbcRowUpper() const {
1121  return cbcRowUpper_;
1122  }
1124  inline const double * getCbcColSolution() const {
1125  return cbcColSolution_;
1126  }
1128  inline const double * getCbcRowPrice() const {
1129  return cbcRowPrice_;
1130  }
1132  inline const double * getCbcReducedCost() const {
1133  return cbcReducedCost_;
1134  }
1136  inline const double * getCbcRowActivity() const {
1137  return cbcRowActivity_;
1138  }
1140 
1141 
1144  inline double * continuousSolution() const {
1146  return continuousSolution_;
1147  }
1152  inline int * usedInSolution() const {
1153  return usedInSolution_;
1154  }
1156  void incrementUsed(const double * solution);
1158  void setBestSolution(CBC_Message how,
1159  double & objectiveValue, const double *solution,
1160  int fixVariables = 0);
1162  void setBestObjectiveValue( double objectiveValue);
1165  double objValue,
1166  const double * solution);
1167 
1174  double checkSolution(double cutoff, double * solution,
1175  int fixVariables, double originalObjValue);
1182  bool feasibleSolution(int & numberIntegerInfeasibilities,
1183  int & numberObjectInfeasibilities) const;
1184 
1190  inline double * currentSolution() const {
1191  return currentSolution_;
1192  }
1196  inline const double * testSolution() const {
1197  return testSolution_;
1198  }
1199  inline void setTestSolution(const double * solution) {
1200  testSolution_ = solution;
1201  }
1203  void reserveCurrentSolution(const double * solution = NULL);
1204 
1206  inline const double * getColSolution() const {
1207  return solver_->getColSolution();
1208  }
1209 
1211  inline const double * getRowPrice() const {
1212  return solver_->getRowPrice();
1213  }
1214 
1216  inline const double * getReducedCost() const {
1217  return solver_->getReducedCost();
1218  }
1219 
1221  inline const double * getRowActivity() const {
1222  return solver_->getRowActivity();
1223  }
1224 
1226  inline double getCurrentObjValue() const {
1228  }
1230  inline double getCurrentMinimizationObjValue() const {
1232  }
1233 
1235  inline double getMinimizationObjValue() const {
1236  return bestObjective_;
1237  }
1239  inline void setMinimizationObjValue(double value) {
1240  bestObjective_ = value;
1241  }
1242 
1244  inline double getObjValue() const {
1245  return bestObjective_ * solver_->getObjSense() ;
1246  }
1252  double getBestPossibleObjValue() const;
1254  inline void setObjValue(double value) {
1255  bestObjective_ = value * solver_->getObjSense() ;
1256  }
1258  inline double getSolverObjValue() const {
1259  return solver_->getObjValue() * solver_->getObjSense() ;
1260  }
1261 
1268  inline double * bestSolution() const {
1269  return bestSolution_;
1270  }
1277  void setBestSolution(const double * solution, int numberColumns,
1278  double objectiveValue, bool check = false);
1279 
1281  inline int getSolutionCount() const {
1282  return numberSolutions_;
1283  }
1284 
1286  inline void setSolutionCount(int value) {
1287  numberSolutions_ = value;
1288  }
1290  int numberSavedSolutions() const;
1292  inline int maximumSavedSolutions() const {
1293  return maximumSavedSolutions_;
1294  }
1296  void setMaximumSavedSolutions(int value);
1298  const double * savedSolution(int which) const;
1300  double savedSolutionObjective(int which) const;
1301 
1310  inline int phase() const {
1311  return phase_;
1312  }
1313 
1315  inline int getNumberHeuristicSolutions() const {
1317  }
1319  inline void setNumberHeuristicSolutions(int value) {
1320  numberHeuristicSolutions_ = value;
1321  }
1322 
1324  inline void setObjSense(double s) {
1326  solver_->setObjSense(s);
1327  }
1328 
1330  inline double getContinuousObjective() const {
1332  }
1333  inline void setContinuousObjective(double value) {
1335  }
1337  inline int getContinuousInfeasibilities() const {
1339  }
1340  inline void setContinuousInfeasibilities(int value) {
1342  }
1344  inline double rootObjectiveAfterCuts() const {
1345  return continuousObjective_;
1346  }
1348  inline double sumChangeObjective() const {
1349  return sumChangeObjective1_;
1350  }
1353  inline int numberGlobalViolations() const {
1354  return numberGlobalViolations_;
1355  }
1358  }
1360  inline bool resolveAfterTakeOffCuts() const {
1361  return resolveAfterTakeOffCuts_;
1362  }
1363  inline void setResolveAfterTakeOffCuts(bool yesNo) {
1364  resolveAfterTakeOffCuts_ = yesNo;
1365  }
1367  inline int maximumRows() const {
1368  return maximumRows_;
1369  }
1371  inline CoinWarmStartBasis & workingBasis() {
1372  return workingBasis_;
1373  }
1375  inline int getStopNumberIterations() const {
1376  return stopNumberIterations_;
1377  }
1379  inline void setStopNumberIterations(int value) {
1380  stopNumberIterations_ = value;
1381  }
1383 
1386  // Comparison functions (which may be overridden by inheritance)
1387  inline CbcCompareBase * nodeComparison() const {
1388  return nodeCompare_;
1389  }
1390  void setNodeComparison(CbcCompareBase * compare);
1391  void setNodeComparison(CbcCompareBase & compare);
1393 
1396  // Feasibility functions (which may be overridden by inheritance)
1398  return problemFeasibility_;
1399  }
1400  void setProblemFeasibility(CbcFeasibilityBase * feasibility);
1401  void setProblemFeasibility(CbcFeasibilityBase & feasibility);
1403 
1406  inline CbcTree * tree() const {
1408  return tree_;
1409  }
1411  void passInTreeHandler(CbcTree & tree);
1415  void passInSubTreeModel(CbcModel & model);
1420  CbcModel * subTreeModel(OsiSolverInterface * solver = NULL) const;
1422  inline int numberStoppedSubTrees() const {
1423  return numberStoppedSubTrees_;
1424  }
1426  inline void incrementSubTreeStopped() {
1428  }
1434  inline int typePresolve() const {
1435  return presolve_;
1436  }
1437  inline void setTypePresolve(int value) {
1438  presolve_ = value;
1439  }
1440 
1442 
1448 
1451  return branchingMethod_;
1452  }
1454  inline void setBranchingMethod(CbcBranchDecision * method) {
1455  delete branchingMethod_;
1456  branchingMethod_ = method->clone();
1457  }
1462  inline void setBranchingMethod(CbcBranchDecision & method) {
1463  delete branchingMethod_;
1464  branchingMethod_ = method.clone();
1465  }
1467  inline CbcCutModifier * cutModifier() const {
1468  return cutModifier_;
1469  }
1471  void setCutModifier(CbcCutModifier * modifier);
1476  void setCutModifier(CbcCutModifier & modifier);
1478 
1481 
1488  inline int stateOfSearch() const {
1489  return stateOfSearch_;
1490  }
1491  inline void setStateOfSearch(int state) {
1492  stateOfSearch_ = state;
1493  }
1495  inline int searchStrategy() const {
1496  return searchStrategy_;
1497  }
1499  inline void setSearchStrategy(int value) {
1500  searchStrategy_ = value;
1501  }
1502 
1504  inline int numberCutGenerators() const {
1505  return numberCutGenerators_;
1506  }
1508  inline CbcCutGenerator ** cutGenerators() const {
1509  return generator_;
1510  }
1512  inline CbcCutGenerator * cutGenerator(int i) const {
1513  return generator_[i];
1514  }
1516  inline CbcCutGenerator * virginCutGenerator(int i) const {
1517  return virginGenerator_[i];
1518  }
1527  void addCutGenerator(CglCutGenerator * generator,
1528  int howOften = 1, const char * name = NULL,
1529  bool normal = true, bool atSolution = false,
1530  bool infeasible = false, int howOftenInSub = -100,
1531  int whatDepth = -1, int whatDepthInSub = -1);
1533 
1538 
1540  inline CbcStrategy * strategy() const {
1541  return strategy_;
1542  }
1547  strategy_ = strategy;
1548  }
1550  inline CbcModel * parentModel() const {
1551  return parentModel_;
1552  }
1556  }
1558 
1559 
1566  void addHeuristic(CbcHeuristic * generator, const char *name = NULL,
1567  int before = -1);
1569  inline CbcHeuristic * heuristic(int i) const {
1570  return heuristic_[i];
1571  }
1573  inline int numberHeuristics() const {
1574  return numberHeuristics_;
1575  }
1577  inline CbcHeuristic * lastHeuristic() const {
1578  return lastHeuristic_;
1579  }
1581  inline void setLastHeuristic(CbcHeuristic * last) {
1582  lastHeuristic_ = last;
1583  }
1584 
1603  void passInPriorities(const int * priorities, bool ifNotSimpleIntegers);
1604 
1606  inline int priority(int sequence) const {
1607  return object_[sequence]->priority();
1608  }
1609 
1614  void passInEventHandler(const CbcEventHandler *eventHandler) ;
1615 
1618  return (eventHandler_) ;
1619  }
1620 
1622 
1632  void setApplicationData (void * appData);
1633 
1635  void * getApplicationData() const;
1650  inline const OsiBabSolver * solverCharacteristics() const {
1651  return solverCharacteristics_;
1652  }
1654 
1655  //---------------------------------------------------------------------------
1656 
1659  void passInMessageHandler(CoinMessageHandler * handler);
1662  void newLanguage(CoinMessages::Language language);
1663  inline void setLanguage(CoinMessages::Language language) {
1664  newLanguage(language);
1665  }
1667  inline CoinMessageHandler * messageHandler() const {
1668  return handler_;
1669  }
1671  inline CoinMessages & messages() {
1672  return messages_;
1673  }
1675  inline CoinMessages * messagesPointer() {
1676  return &messages_;
1677  }
1679  void setLogLevel(int value);
1681  inline int logLevel() const {
1682  return handler_->logLevel();
1683  }
1689  inline void setDefaultHandler(bool yesNo) {
1690  defaultHandler_ = yesNo;
1691  }
1693  //---------------------------------------------------------------------------
1695 
1696 
1718  inline void setSpecialOptions(int value) {
1719  specialOptions_ = value;
1720  }
1722  inline int specialOptions() const {
1723  return specialOptions_;
1724  }
1726  inline bool normalSolver() const {
1727  return (specialOptions_&16) == 0;
1728  }
1736  inline void setMoreSpecialOptions(int value) {
1737  moreSpecialOptions_ = value;
1738  }
1740  inline int moreSpecialOptions() const {
1741  return moreSpecialOptions_;
1742  }
1744 #ifdef COIN_HAS_CLP
1745  void goToDantzig(int numberNodes, ClpDualRowPivot *& savePivotMethod);
1746 #endif
1747  inline bool ownObjects() const {
1749  return ownObjects_;
1750  }
1752  void checkModel();
1754  //---------------------------------------------------------------------------
1755 
1757 
1758  CbcModel();
1760 
1762  CbcModel(const OsiSolverInterface &);
1763 
1772  void assignSolver(OsiSolverInterface *&solver, bool deleteSolver = true);
1773 
1785  inline void setModelOwnsSolver (bool ourSolver) {
1786  ownership_ = ourSolver ? (ownership_ | 0x80000000) : (ownership_ & (~0x80000000)) ;
1787  }
1788 
1794  inline bool modelOwnsSolver () {
1795  return ((ownership_&0x80000000) != 0) ;
1796  }
1797 
1801  CbcModel(const CbcModel & rhs, bool cloneHandler = false);
1802 
1804  CbcModel & operator=(const CbcModel& rhs);
1805 
1807  ~CbcModel ();
1808 
1810  inline OsiSolverInterface * solver() const {
1811  return solver_;
1812  }
1813 
1815  inline OsiSolverInterface * swapSolver(OsiSolverInterface * solver) {
1816  OsiSolverInterface * returnSolver = solver_;
1817  solver_ = solver;
1818  return returnSolver;
1819  }
1820 
1822  inline OsiSolverInterface * continuousSolver() const {
1823  return continuousSolver_;
1824  }
1825 
1827  inline void createContinuousSolver() {
1828  continuousSolver_ = solver_->clone();
1829  }
1831  inline void clearContinuousSolver() {
1832  delete continuousSolver_;
1833  continuousSolver_ = NULL;
1834  }
1835 
1837  inline OsiSolverInterface * referenceSolver() const {
1838  return referenceSolver_;
1839  }
1840 
1842  void saveReferenceSolver();
1843 
1849  void resetToReferenceSolver();
1850 
1852  void gutsOfDestructor();
1855  void gutsOfDestructor2();
1858  void resetModel();
1864  void gutsOfCopy(const CbcModel & rhs, int mode = 0);
1866  void moveInfo(const CbcModel & rhs);
1868 
1870 
1871  CbcThread * masterThread() const {
1873  return masterThread_;
1874  }
1876  CbcNodeInfo ** walkback() const {
1877  return walkback_;
1878  }
1880  inline int getNumberThreads() const {
1881  return numberThreads_;
1882  }
1884  inline void setNumberThreads(int value) {
1885  numberThreads_ = value;
1886  }
1888  inline int getThreadMode() const {
1889  return threadMode_;
1890  }
1900  inline void setThreadMode(int value) {
1901  threadMode_ = value;
1902  }
1909  inline int parallelMode() const {
1910  if (!numberThreads_) {
1911  if ((threadMode_&1) == 0)
1912  return 0;
1913  else
1914  return -1;
1915  return 0;
1916  } else {
1917  if ((threadMode_&1) == 0)
1918  return 1;
1919  else
1920  return -2;
1921  }
1922  }
1925  bool isLocked() const;
1926 #ifdef CBC_THREAD
1927 
1931  void lockThread();
1935  void unlockThread();
1936 #else
1937  inline void lockThread() {}
1938  inline void unlockThread() {}
1939 #endif
1940 
1947  void setInfoInChild(int type, CbcThread * info);
1954  void moveToModel(CbcModel * baseModel, int mode);
1956  int splitModel(int numberModels, CbcModel ** model,
1957  int numberNodes);
1959  void startSplitModel(int numberIterations);
1961  void mergeModels(int numberModel, CbcModel ** model,
1962  int numberNodes);
1964 
1966 
1967  int getNodeCount2() const {
1969  return numberNodes2_;
1970  }
1972  void setPointers(const OsiSolverInterface * solver);
1978  int reducedCostFix() ;
1982  void synchronizeHandlers(int makeDefault);
1984  void saveExtraSolution(const double * solution, double objectiveValue);
1986  void saveBestSolution(const double * solution, double objectiveValue);
1988  void deleteSolutions();
1990  int resolve(OsiSolverInterface * solver);
1991 
1995  int chooseBranch(CbcNode * & newNode, int numberPassesLeft,
1996  CbcNode * oldNode, OsiCuts & cuts,
1997  bool & resolved, CoinWarmStartBasis *lastws,
1998  const double * lowerBefore, const double * upperBefore,
1999  OsiSolverBranch * & branches);
2000  int chooseBranch(CbcNode * newNode, int numberPassesLeft, bool & resolved);
2001 
2008  CoinWarmStartBasis *getEmptyBasis(int ns = 0, int na = 0) const ;
2009 
2021  int takeOffCuts(OsiCuts &cuts,
2022  bool allowResolve, OsiCuts * saveCuts,
2023  int numberNewCuts = 0, const OsiRowCut ** newCuts = NULL) ;
2024 
2038  int addCuts(CbcNode * node, CoinWarmStartBasis *&lastws, bool canFix);
2039 
2056  bool addCuts1(CbcNode * node, CoinWarmStartBasis *&lastws);
2060  void previousBounds (CbcNode * node, CbcNodeInfo * where, int iColumn,
2061  double & lower, double & upper, int force);
2066  void setObjectiveValue(CbcNode * thisNode, const CbcNode * parentNode) const;
2067 
2071  void convertToDynamic();
2073  void synchronizeNumberBeforeTrust(int type = 0);
2075  void zapIntegerInformation(bool leaveObjects = true);
2077  int cliquePseudoCosts(int doStatistics);
2079  void pseudoShadow(int type);
2086  void fillPseudoCosts(double * downCosts, double * upCosts,
2087  int * priority = NULL,
2088  int * numberDown = NULL, int * numberUp = NULL,
2089  int * numberDownInfeasible = NULL,
2090  int * numberUpInfeasible = NULL) const;
2096  void doHeuristicsAtRoot(int deleteHeuristicsAfterwards = 0);
2098  void adjustHeuristics();
2100  inline const double * hotstartSolution() const {
2101  return hotstartSolution_;
2102  }
2104  inline const int * hotstartPriorities() const {
2105  return hotstartPriorities_;
2106  }
2107 
2109  inline CbcCountRowCut ** addedCuts() const {
2110  return addedCuts_;
2111  }
2113  inline int currentNumberCuts() const {
2114  return currentNumberCuts_;
2115  }
2117  inline OsiCuts * globalCuts() {
2118  return &globalCuts_;
2119  }
2121  void setNextRowCut(const OsiRowCut & cut);
2123  inline CbcNode * currentNode() const {
2124  return currentNode_;
2125  }
2127  inline CglTreeProbingInfo * probingInfo() const {
2128  return probingInfo_;
2129  }
2131  inline CoinThreadRandom * randomNumberGenerator() {
2132  return &randomNumberGenerator_;
2133  }
2135  inline void setNumberStrongIterations(int number) {
2136  numberStrongIterations_ = number;
2137  }
2139  inline int numberStrongIterations() const {
2140  return numberStrongIterations_;
2141  }
2143  inline int maximumNumberIterations() const {
2144  return maximumNumberIterations_;
2145  }
2147  inline void setMaximumNumberIterations(int value) {
2148  maximumNumberIterations_ = value;
2149  }
2150 # ifdef COIN_HAS_CLP
2151  inline void setFastNodeDepth(int value) {
2153  fastNodeDepth_ = value;
2154  }
2156  inline int fastNodeDepth() const {
2157  return fastNodeDepth_;
2158  }
2160  inline int continuousPriority() const {
2161  return continuousPriority_;
2162  }
2164  inline void setContinuousPriority(int value) {
2165  continuousPriority_ = value;
2166  }
2167  inline void incrementExtra(int nodes, int iterations) {
2168  numberExtraNodes_ += nodes;
2169  numberExtraIterations_ += iterations;
2170  }
2171 #endif
2172  inline int numberExtraIterations() const {
2174  return numberExtraIterations_;
2175  }
2177  void incrementStrongInfo(int numberTimes, int numberIterations,
2178  int numberFixed, bool ifInfeasible);
2180  inline const int * strongInfo() const {
2181  return strongInfo_;
2182  }
2183 
2185  inline int * mutableStrongInfo() {
2186  return strongInfo_;
2187  }
2189  CglStored * storedRowCuts() const {
2190  return storedRowCuts_;
2191  }
2193  void setStoredRowCuts(CglStored * cuts) {
2194  storedRowCuts_ = cuts;
2195  }
2197  inline bool allDynamic () const {
2198  return ((ownership_&0x40000000) != 0) ;
2199  }
2201  void generateCpp( FILE * fp, int options);
2203  OsiBranchingInformation usefulInformation() const;
2210  inline void setBestSolutionBasis(const CoinWarmStartBasis & bestSolutionBasis) {
2211  bestSolutionBasis_ = bestSolutionBasis;
2212  }
2214  void redoWalkBack();
2216 
2217 //---------------------------------------------------------------------------
2218 
2219 private:
2221 
2222 
2224  OsiSolverInterface * solver_;
2225 
2231  unsigned int ownership_ ;
2232 
2234  OsiSolverInterface * continuousSolver_;
2235 
2237  OsiSolverInterface * referenceSolver_;
2238 
2240  CoinMessageHandler * handler_;
2241 
2248 
2250  CoinMessages messages_;
2251 
2254 
2257 
2266  mutable CoinWarmStart *emptyWarmStart_ ;
2267 
2276 
2278  double * bestSolution_;
2280  double ** savedSolutions_;
2281 
2290  mutable const double * testSolution_;
2297  CoinWarmStartBasis bestSolutionBasis_ ;
2299  OsiCuts globalCuts_;
2300 
2335  int status_;
2361  int phase_;
2362 
2365 
2378  const OsiRowCut ** lastCut_;
2383 
2392 
2396  OsiRowCut * nextRowCut_;
2397 
2400 
2460  const double * cbcColLower_;
2463  const double * cbcColUpper_;
2465  const double * cbcRowLower_;
2467  const double * cbcRowUpper_;
2469  const double * cbcColSolution_;
2471  const double * cbcRowPrice_;
2473  const double * cbcReducedCost_;
2475  const double * cbcRowActivity_;
2477  void * appData_;
2516  // Cut generators
2518  // Cut generators before any changes
2526 # ifdef COIN_HAS_CLP
2527  int fastNodeDepth_;
2529 #endif
2530 
2531 # ifdef CBC_ONLY_CLP
2532  ClpEventHandler *eventHandler_ ;
2533 # else
2535 # endif
2536 
2539 
2550  OsiObject ** object_;
2553 
2589  mutable CoinThreadRandom randomNumberGenerator_;
2591  CoinWarmStartBasis workingBasis_;
2603  CglTreeProbingInfo * probingInfo_;
2611  mutable bool eventHappened_;
2624  int strongInfo_[7];
2631  OsiBabSolver * solverCharacteristics_;
2645  CglStored * storedRowCuts_;
2667 };
2669 void getIntegerInformation(const OsiObject * object, double & originalLower,
2670  double & originalUpper) ;
2671 // So we can call from other programs
2672 // Real main program
2673 class OsiClpSolverInterface;
2674 int CbcMain (int argc, const char *argv[], OsiClpSolverInterface & solver, CbcModel ** babSolver);
2675 int CbcMain (int argc, const char *argv[], CbcModel & babSolver);
2676 // four ways of calling
2677 int callCbc(const char * input2, OsiClpSolverInterface& solver1);
2678 int callCbc(const char * input2);
2679 int callCbc(const std::string input2, OsiClpSolverInterface& solver1);
2680 int callCbc(const std::string input2) ;
2681 // When we want to load up CbcModel with options first
2682 void CbcMain0 (CbcModel & babSolver);
2683 int CbcMain1 (int argc, const char *argv[], CbcModel & babSolver);
2684 // two ways of calling
2685 int callCbc(const char * input2, CbcModel & babSolver);
2686 int callCbc(const std::string input2, CbcModel & babSolver);
2687 // And when CbcMain0 already called to initialize
2688 int callCbc1(const char * input2, CbcModel & babSolver);
2689 int callCbc1(const std::string input2, CbcModel & babSolver);
2690 // And when CbcMain0 already called to initialize (with call back) (see CbcMain1 for whereFrom)
2691 int callCbc1(const char * input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
2692 int callCbc1(const std::string input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
2693 int CbcMain1 (int argc, const char *argv[], CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
2694 // For uniform setting of cut and heuristic options
2695 void setCutAndHeuristicOptions(CbcModel & model);
2696 #endif
2697