00001
00002
00003
00004
00005
00006 #ifndef CbcModel_H
00007 #define CbcModel_H
00008 #include <string>
00009 #include <vector>
00010 #include "CoinMessageHandler.hpp"
00011 #include "OsiSolverInterface.hpp"
00012 #include "OsiBranchingObject.hpp"
00013 #include "OsiCuts.hpp"
00014 #include "CoinWarmStartBasis.hpp"
00015 #include "CbcCompareBase.hpp"
00016 #include "CbcCountRowCut.hpp"
00017 #include "CbcMessage.hpp"
00018 #include "CbcEventHandler.hpp"
00019 #include "ClpDualRowPivot.hpp"
00020
00021
00022 class CbcCutGenerator;
00023 class CbcBaseModel;
00024 class OsiRowCut;
00025 class OsiBabSolver;
00026 class OsiRowCutDebugger;
00027 class CglCutGenerator;
00028 class CglStored;
00029 class CbcCutModifier;
00030 class CglTreeProbingInfo;
00031 class CbcHeuristic;
00032 class OsiObject;
00033 class CbcThread;
00034 class CbcTree;
00035 class CbcStrategy;
00036 class CbcFeasibilityBase;
00037 class CbcStatistics;
00038 class CbcFullNodeInfo;
00039 class CbcEventHandler ;
00040 class CglPreProcess;
00041 # ifdef COIN_HAS_CLP
00042 class OsiClpSolverInterface;
00043 class ClpNodeStuff;
00044 #endif
00045
00046
00047
00048
00101 class CbcModel {
00102
00103 public:
00104
00105 enum CbcIntParam {
00107 CbcMaxNumNode = 0,
00109 CbcMaxNumSol,
00119 CbcFathomDiscipline,
00123 CbcPrinting,
00126 CbcNumberBranches,
00128 CbcLastIntParam
00129 };
00130
00131 enum CbcDblParam {
00134 CbcIntegerTolerance = 0,
00137 CbcInfeasibilityWeight,
00140 CbcCutoffIncrement,
00147 CbcAllowableGap,
00154 CbcAllowableFractionGap,
00157 CbcMaximumSeconds,
00159 CbcCurrentCutoff,
00161 CbcOptimizationDirection,
00163 CbcCurrentObjectiveValue,
00165 CbcCurrentMinimizationObjectiveValue,
00168 CbcStartSeconds,
00176 CbcHeuristicGap,
00184 CbcHeuristicFractionGap,
00186 CbcSmallestChange,
00188 CbcSumChange,
00190 CbcLargestChange,
00192 CbcSmallChange,
00194 CbcLastDblParam
00195 };
00196
00197
00198
00199 public:
00201
00202
00206 void initialSolve();
00207
00218 void branchAndBound(int doStatistics = 0);
00219 private:
00220
00228 bool solveWithCuts(OsiCuts & cuts, int numberTries, CbcNode * node);
00236 int serialCuts(OsiCuts & cuts, CbcNode * node, OsiCuts & slackCuts, int lastNumberCuts);
00244 int parallelCuts(CbcBaseModel * master, OsiCuts & cuts, CbcNode * node, OsiCuts & slackCuts, int lastNumberCuts);
00251 CbcNode ** solveOneNode(int whichSolver, CbcNode * node,
00252 int & numberNodesOutput, int & status) ;
00254 void resizeWhichGenerator(int numberNow, int numberAfter);
00255 public:
00256 #ifdef CBC_KEEP_DEPRECATED
00257
00262 CbcModel * cleanModel(const double * lower, const double * upper);
00279 int subBranchAndBound(CbcModel * model2,
00280 CbcModel * presolvedModel,
00281 int maximumNodes);
00297 int subBranchAndBound(const double * lower, const double * upper,
00298 int maximumNodes);
00299
00306 OsiSolverInterface * strengthenedModel();
00316 CglPreProcess * preProcess( int makeEquality = 0, int numberPasses = 5,
00317 int tuning = 5);
00320 void postProcess(CglPreProcess * process);
00321 #endif
00323 void addUpdateInformation(const CbcObjectUpdateData & data);
00324
00330 int doOneNode(CbcModel * baseModel, CbcNode * & node, CbcNode * & newNode);
00331
00332 public:
00346 int resolve(CbcNodeInfo * parent, int whereFrom,
00347 double * saveSolution = NULL,
00348 double * saveLower = NULL,
00349 double * saveUpper = NULL);
00351 void makeGlobalCuts(int numberRows, const int * which);
00353 void makeGlobalCut(const OsiRowCut * cut);
00355 void makeGlobalCut(const OsiRowCut & cut);
00357 void makeGlobalCut(const OsiColCut * cut);
00359 void makeGlobalCut(const OsiColCut & cut);
00361 void makePartialCut(const OsiRowCut * cut);
00363 void makeGlobalCuts();
00365 inline const int * whichGenerator() const
00366 { return whichGenerator_;}
00368
00371
00383 CbcModel * findCliques(bool makeEquality, int atLeastThisMany,
00384 int lessThanThis, int defaultValue = 1000);
00385
00394 CbcModel * integerPresolve(bool weak = false);
00395
00400 bool integerPresolveThisModel(OsiSolverInterface * originalSolver, bool weak = false);
00401
00402
00404 void originalModel(CbcModel * presolvedModel, bool weak);
00405
00426 bool tightenVubs(int type, bool allowMultipleBinary = false,
00427 double useCutoff = 1.0e50);
00428
00434 bool tightenVubs(int numberVubs, const int * which,
00435 double useCutoff = 1.0e50);
00439 void analyzeObjective();
00440
00444 void AddIntegers();
00445
00449 void saveModel(OsiSolverInterface * saveSolver, double * checkCutoffForRestart, bool * feasible);
00453 void flipModel();
00454
00456
00462
00464 inline int numberObjects() const {
00465 return numberObjects_;
00466 }
00468 inline void setNumberObjects(int number) {
00469 numberObjects_ = number;
00470 }
00471
00473 inline OsiObject ** objects() const {
00474 return object_;
00475 }
00476
00478 const inline OsiObject * object(int which) const {
00479 return object_[which];
00480 }
00482 inline OsiObject * modifiableObject(int which) const {
00483 return object_[which];
00484 }
00485
00486 void setOptionalInteger(int index);
00487
00489 void deleteObjects(bool findIntegers = true);
00490
00495 void addObjects(int numberObjects, OsiObject ** objects);
00496
00501 void addObjects(int numberObjects, CbcObject ** objects);
00502
00504 void synchronizeModel() ;
00505
00515 void findIntegers(bool startAgain, int type = 0);
00516
00518
00519
00520
00530
00531 inline bool setIntParam(CbcIntParam key, int value) {
00532 intParam_[key] = value;
00533 return true;
00534 }
00536 inline bool setDblParam(CbcDblParam key, double value) {
00537 dblParam_[key] = value;
00538 return true;
00539 }
00541 inline int getIntParam(CbcIntParam key) const {
00542 return intParam_[key];
00543 }
00545 inline double getDblParam(CbcDblParam key) const {
00546 return dblParam_[key];
00547 }
00553 void setCutoff(double value) ;
00554
00556 inline double getCutoff() const {
00557
00558
00559 return dblParam_[CbcCurrentCutoff];
00560 }
00561
00563 inline bool setMaximumNodes( int value) {
00564 return setIntParam(CbcMaxNumNode, value);
00565 }
00566
00568 inline int getMaximumNodes() const {
00569 return getIntParam(CbcMaxNumNode);
00570 }
00571
00576 inline bool setMaximumSolutions( int value) {
00577 return setIntParam(CbcMaxNumSol, value);
00578 }
00583 inline int getMaximumSolutions() const {
00584 return getIntParam(CbcMaxNumSol);
00585 }
00587 inline bool setPrintingMode( int value) {
00588 return setIntParam(CbcPrinting, value);
00589 }
00590
00592 inline int getPrintingMode() const {
00593 return getIntParam(CbcPrinting);
00594 }
00595
00600 inline bool setMaximumSeconds( double value) {
00601 return setDblParam(CbcMaximumSeconds, value);
00602 }
00607 inline double getMaximumSeconds() const {
00608 return getDblParam(CbcMaximumSeconds);
00609 }
00611 double getCurrentSeconds() const ;
00612
00614 bool maximumSecondsReached() const ;
00615
00619 inline bool setIntegerTolerance( double value) {
00620 return setDblParam(CbcIntegerTolerance, value);
00621 }
00625 inline double getIntegerTolerance() const {
00626 return getDblParam(CbcIntegerTolerance);
00627 }
00628
00633 inline bool setInfeasibilityWeight( double value) {
00634 return setDblParam(CbcInfeasibilityWeight, value);
00635 }
00640 inline double getInfeasibilityWeight() const {
00641 return getDblParam(CbcInfeasibilityWeight);
00642 }
00643
00647 inline bool setAllowableGap( double value) {
00648 return setDblParam(CbcAllowableGap, value);
00649 }
00653 inline double getAllowableGap() const {
00654 return getDblParam(CbcAllowableGap);
00655 }
00656
00660 inline bool setAllowableFractionGap( double value) {
00661 return setDblParam(CbcAllowableFractionGap, value);
00662 }
00666 inline double getAllowableFractionGap() const {
00667 return getDblParam(CbcAllowableFractionGap);
00668 }
00672 inline bool setAllowablePercentageGap( double value) {
00673 return setDblParam(CbcAllowableFractionGap, value*0.01);
00674 }
00678 inline double getAllowablePercentageGap() const {
00679 return 100.0*getDblParam(CbcAllowableFractionGap);
00680 }
00684 inline bool setHeuristicGap( double value) {
00685 return setDblParam(CbcHeuristicGap, value);
00686 }
00690 inline double getHeuristicGap() const {
00691 return getDblParam(CbcHeuristicGap);
00692 }
00693
00697 inline bool setHeuristicFractionGap( double value) {
00698 return setDblParam(CbcHeuristicFractionGap, value);
00699 }
00703 inline double getHeuristicFractionGap() const {
00704 return getDblParam(CbcHeuristicFractionGap);
00705 }
00710 inline bool setCutoffIncrement( double value) {
00711 return setDblParam(CbcCutoffIncrement, value);
00712 }
00717 inline double getCutoffIncrement() const {
00718 return getDblParam(CbcCutoffIncrement);
00719 }
00721 bool canStopOnGap() const;
00722
00727 void setHotstartSolution(const double * solution, const int * priorities = NULL) ;
00728
00730 inline void setMinimumDrop(double value) {
00731 minimumDrop_ = value;
00732 }
00734 inline double getMinimumDrop() const {
00735 return minimumDrop_;
00736 }
00737
00740 inline void setMaximumCutPassesAtRoot(int value) {
00741 maximumCutPassesAtRoot_ = value;
00742 }
00744 inline int getMaximumCutPassesAtRoot() const {
00745 return maximumCutPassesAtRoot_;
00746 }
00747
00750 inline void setMaximumCutPasses(int value) {
00751 maximumCutPasses_ = value;
00752 }
00754 inline int getMaximumCutPasses() const {
00755 return maximumCutPasses_;
00756 }
00759 inline int getCurrentPassNumber() const {
00760 return currentPassNumber_;
00761 }
00762
00768 void setNumberStrong(int number);
00772 inline int numberStrong() const {
00773 return numberStrong_;
00774 }
00777 inline void setPreferredWay(int value) {
00778 preferredWay_ = value;
00779 }
00781 inline int getPreferredWay() const {
00782 return preferredWay_;
00783 }
00785 inline int whenCuts() const {
00786 return whenCuts_;
00787 }
00789 inline void setWhenCuts(int value) {
00790 whenCuts_ = value;
00791 }
00797 bool doCutsNow(int allowForTopOfTree) const;
00798
00804 void setNumberBeforeTrust(int number);
00807 inline int numberBeforeTrust() const {
00808 return numberBeforeTrust_;
00809 }
00815 void setNumberPenalties(int number);
00818 inline int numberPenalties() const {
00819 return numberPenalties_;
00820 }
00822 inline const CbcFullNodeInfo * topOfTree() const
00823 { return topOfTree_;}
00825 inline void setNumberAnalyzeIterations(int number) {
00826 numberAnalyzeIterations_ = number;
00827 }
00828 inline int numberAnalyzeIterations() const {
00829 return numberAnalyzeIterations_;
00830 }
00833 inline double penaltyScaleFactor() const {
00834 return penaltyScaleFactor_;
00835 }
00838 void setPenaltyScaleFactor(double value);
00846 void inline setProblemType(int number) {
00847 problemType_ = number;
00848 }
00849 inline int problemType() const {
00850 return problemType_;
00851 }
00853 inline int currentDepth() const {
00854 return currentDepth_;
00855 }
00856
00858 void setHowOftenGlobalScan(int number);
00860 inline int howOftenGlobalScan() const {
00861 return howOftenGlobalScan_;
00862 }
00864 inline int * originalColumns() const {
00865 return originalColumns_;
00866 }
00868 void setOriginalColumns(const int * originalColumns) ;
00869
00877 inline void setPrintFrequency(int number) {
00878 printFrequency_ = number;
00879 }
00881 inline int printFrequency() const {
00882 return printFrequency_;
00883 }
00885
00886
00888
00889
00890 bool isAbandoned() const;
00892 bool isProvenOptimal() const;
00894 bool isProvenInfeasible() const;
00896 bool isContinuousUnbounded() const;
00898 bool isProvenDualInfeasible() const;
00900 bool isNodeLimitReached() const;
00902 bool isSecondsLimitReached() const;
00904 bool isSolutionLimitReached() const;
00906 inline int getIterationCount() const {
00907 return numberIterations_;
00908 }
00910 inline void incrementIterationCount(int value) {
00911 numberIterations_ += value;
00912 }
00914 inline int getNodeCount() const {
00915 return numberNodes_;
00916 }
00918 inline void incrementNodeCount(int value) {
00919 numberNodes_ += value;
00920 }
00922 inline int getExtraNodeCount() const {
00923 return numberExtraNodes_;
00924 }
00934 inline int status() const {
00935 return status_;
00936 }
00937 inline void setProblemStatus(int value) {
00938 status_ = value;
00939 }
00952 inline int secondaryStatus() const {
00953 return secondaryStatus_;
00954 }
00955 inline void setSecondaryStatus(int value) {
00956 secondaryStatus_ = value;
00957 }
00959 bool isInitialSolveAbandoned() const ;
00961 bool isInitialSolveProvenOptimal() const ;
00963 bool isInitialSolveProvenPrimalInfeasible() const ;
00965 bool isInitialSolveProvenDualInfeasible() const ;
00966
00968
00969
00982
00983 inline int numberRowsAtContinuous() const {
00984 return numberRowsAtContinuous_;
00985 }
00986
00988 inline int getNumCols() const {
00989 return solver_->getNumCols();
00990 }
00991
00993 inline int getNumRows() const {
00994 return solver_->getNumRows();
00995 }
00996
00998 inline CoinBigIndex getNumElements() const {
00999 return solver_->getNumElements();
01000 }
01001
01003 inline int numberIntegers() const {
01004 return numberIntegers_;
01005 }
01006
01007 inline const int * integerVariable() const {
01008 return integerVariable_;
01009 }
01011 inline char integerType(int i) const {
01012 assert (integerInfo_);
01013 assert (integerInfo_[i] == 0 || integerInfo_[i] == 1);
01014 return integerInfo_[i];
01015 }
01017 inline const char * integerType() const {
01018 return integerInfo_;
01019 }
01020
01022 inline const double * getColLower() const {
01023 return solver_->getColLower();
01024 }
01025
01027 inline const double * getColUpper() const {
01028 return solver_->getColUpper();
01029 }
01030
01040 inline const char * getRowSense() const {
01041 return solver_->getRowSense();
01042 }
01043
01052 inline const double * getRightHandSide() const {
01053 return solver_->getRightHandSide();
01054 }
01055
01064 inline const double * getRowRange() const {
01065 return solver_->getRowRange();
01066 }
01067
01069 inline const double * getRowLower() const {
01070 return solver_->getRowLower();
01071 }
01072
01074 inline const double * getRowUpper() const {
01075 return solver_->getRowUpper();
01076 }
01077
01079 inline const double * getObjCoefficients() const {
01080 return solver_->getObjCoefficients();
01081 }
01082
01084 inline double getObjSense() const {
01085
01086 return dblParam_[CbcOptimizationDirection];
01087 }
01088
01090 inline bool isContinuous(int colIndex) const {
01091 return solver_->isContinuous(colIndex);
01092 }
01093
01095 inline bool isBinary(int colIndex) const {
01096 return solver_->isBinary(colIndex);
01097 }
01098
01103 inline bool isInteger(int colIndex) const {
01104 return solver_->isInteger(colIndex);
01105 }
01106
01108 inline bool isIntegerNonBinary(int colIndex) const {
01109 return solver_->isIntegerNonBinary(colIndex);
01110 }
01111
01113 inline bool isFreeBinary(int colIndex) const {
01114 return solver_->isFreeBinary(colIndex) ;
01115 }
01116
01118 inline const CoinPackedMatrix * getMatrixByRow() const {
01119 return solver_->getMatrixByRow();
01120 }
01121
01123 inline const CoinPackedMatrix * getMatrixByCol() const {
01124 return solver_->getMatrixByCol();
01125 }
01126
01128 inline double getInfinity() const {
01129 return solver_->getInfinity();
01130 }
01132 inline const double * getCbcColLower() const {
01133 return cbcColLower_;
01134 }
01136 inline const double * getCbcColUpper() const {
01137 return cbcColUpper_;
01138 }
01140 inline const double * getCbcRowLower() const {
01141 return cbcRowLower_;
01142 }
01144 inline const double * getCbcRowUpper() const {
01145 return cbcRowUpper_;
01146 }
01148 inline const double * getCbcColSolution() const {
01149 return cbcColSolution_;
01150 }
01152 inline const double * getCbcRowPrice() const {
01153 return cbcRowPrice_;
01154 }
01156 inline const double * getCbcReducedCost() const {
01157 return cbcReducedCost_;
01158 }
01160 inline const double * getCbcRowActivity() const {
01161 return cbcRowActivity_;
01162 }
01164
01165
01168
01169 inline double * continuousSolution() const {
01170 return continuousSolution_;
01171 }
01176 inline int * usedInSolution() const {
01177 return usedInSolution_;
01178 }
01180 void incrementUsed(const double * solution);
01182 void setBestSolution(CBC_Message how,
01183 double & objectiveValue, const double *solution,
01184 int fixVariables = 0);
01186 void setBestObjectiveValue( double objectiveValue);
01188 CbcEventHandler::CbcAction dealWithEventHandler(CbcEventHandler::CbcEvent event,
01189 double objValue,
01190 const double * solution);
01191
01199 virtual double checkSolution(double cutoff, double * solution,
01200 int fixVariables, double originalObjValue);
01207 bool feasibleSolution(int & numberIntegerInfeasibilities,
01208 int & numberObjectInfeasibilities) const;
01209
01215 inline double * currentSolution() const {
01216 return currentSolution_;
01217 }
01221 inline const double * testSolution() const {
01222 return testSolution_;
01223 }
01224 inline void setTestSolution(const double * solution) {
01225 testSolution_ = solution;
01226 }
01228 void reserveCurrentSolution(const double * solution = NULL);
01229
01231 inline const double * getColSolution() const {
01232 return solver_->getColSolution();
01233 }
01234
01236 inline const double * getRowPrice() const {
01237 return solver_->getRowPrice();
01238 }
01239
01241 inline const double * getReducedCost() const {
01242 return solver_->getReducedCost();
01243 }
01244
01246 inline const double * getRowActivity() const {
01247 return solver_->getRowActivity();
01248 }
01249
01251 inline double getCurrentObjValue() const {
01252 return dblParam_[CbcCurrentObjectiveValue];
01253 }
01255 inline double getCurrentMinimizationObjValue() const {
01256 return dblParam_[CbcCurrentMinimizationObjectiveValue];
01257 }
01258
01260 inline double getMinimizationObjValue() const {
01261 return bestObjective_;
01262 }
01264 inline void setMinimizationObjValue(double value) {
01265 bestObjective_ = value;
01266 }
01267
01269 inline double getObjValue() const {
01270 return bestObjective_ * solver_->getObjSense() ;
01271 }
01277 double getBestPossibleObjValue() const;
01279 inline void setObjValue(double value) {
01280 bestObjective_ = value * solver_->getObjSense() ;
01281 }
01283 inline double getSolverObjValue() const {
01284 return solver_->getObjValue() * solver_->getObjSense() ;
01285 }
01286
01293 inline double * bestSolution() const {
01294 return bestSolution_;
01295 }
01302 void setBestSolution(const double * solution, int numberColumns,
01303 double objectiveValue, bool check = false);
01304
01306 inline int getSolutionCount() const {
01307 return numberSolutions_;
01308 }
01309
01311 inline void setSolutionCount(int value) {
01312 numberSolutions_ = value;
01313 }
01315 int numberSavedSolutions() const;
01317 inline int maximumSavedSolutions() const {
01318 return maximumSavedSolutions_;
01319 }
01321 void setMaximumSavedSolutions(int value);
01323 const double * savedSolution(int which) const;
01325 double savedSolutionObjective(int which) const;
01327 void deleteSavedSolution(int which);
01328
01337 inline int phase() const {
01338 return phase_;
01339 }
01340
01342 inline int getNumberHeuristicSolutions() const {
01343 return numberHeuristicSolutions_;
01344 }
01346 inline void setNumberHeuristicSolutions(int value) {
01347 numberHeuristicSolutions_ = value;
01348 }
01349
01351 inline void setObjSense(double s) {
01352 dblParam_[CbcOptimizationDirection] = s;
01353 solver_->setObjSense(s);
01354 }
01355
01357 inline double getContinuousObjective() const {
01358 return originalContinuousObjective_;
01359 }
01360 inline void setContinuousObjective(double value) {
01361 originalContinuousObjective_ = value;
01362 }
01364 inline int getContinuousInfeasibilities() const {
01365 return continuousInfeasibilities_;
01366 }
01367 inline void setContinuousInfeasibilities(int value) {
01368 continuousInfeasibilities_ = value;
01369 }
01371 inline double rootObjectiveAfterCuts() const {
01372 return continuousObjective_;
01373 }
01375 inline double sumChangeObjective() const {
01376 return sumChangeObjective1_;
01377 }
01380 inline int numberGlobalViolations() const {
01381 return numberGlobalViolations_;
01382 }
01383 inline void clearNumberGlobalViolations() {
01384 numberGlobalViolations_ = 0;
01385 }
01387 inline bool resolveAfterTakeOffCuts() const {
01388 return resolveAfterTakeOffCuts_;
01389 }
01390 inline void setResolveAfterTakeOffCuts(bool yesNo) {
01391 resolveAfterTakeOffCuts_ = yesNo;
01392 }
01394 inline int maximumRows() const {
01395 return maximumRows_;
01396 }
01398 inline CoinWarmStartBasis & workingBasis() {
01399 return workingBasis_;
01400 }
01402 inline int getStopNumberIterations() const {
01403 return stopNumberIterations_;
01404 }
01406 inline void setStopNumberIterations(int value) {
01407 stopNumberIterations_ = value;
01408 }
01410 inline CbcModel * heuristicModel() const
01411 { return heuristicModel_;}
01413 inline void setHeuristicModel(CbcModel * model)
01414 { heuristicModel_ = model;}
01416
01419
01420 inline CbcCompareBase * nodeComparison() const {
01421 return nodeCompare_;
01422 }
01423 void setNodeComparison(CbcCompareBase * compare);
01424 void setNodeComparison(CbcCompareBase & compare);
01426
01429
01430 inline CbcFeasibilityBase * problemFeasibility() const {
01431 return problemFeasibility_;
01432 }
01433 void setProblemFeasibility(CbcFeasibilityBase * feasibility);
01434 void setProblemFeasibility(CbcFeasibilityBase & feasibility);
01436
01439
01440 inline CbcTree * tree() const {
01441 return tree_;
01442 }
01444 void passInTreeHandler(CbcTree & tree);
01448 void passInSubTreeModel(CbcModel & model);
01453 CbcModel * subTreeModel(OsiSolverInterface * solver = NULL) const;
01455 inline int numberStoppedSubTrees() const {
01456 return numberStoppedSubTrees_;
01457 }
01459 inline void incrementSubTreeStopped() {
01460 numberStoppedSubTrees_++;
01461 }
01467 inline int typePresolve() const {
01468 return presolve_;
01469 }
01470 inline void setTypePresolve(int value) {
01471 presolve_ = value;
01472 }
01473
01475
01481
01483 inline CbcBranchDecision * branchingMethod() const {
01484 return branchingMethod_;
01485 }
01487 inline void setBranchingMethod(CbcBranchDecision * method) {
01488 delete branchingMethod_;
01489 branchingMethod_ = method->clone();
01490 }
01495 inline void setBranchingMethod(CbcBranchDecision & method) {
01496 delete branchingMethod_;
01497 branchingMethod_ = method.clone();
01498 }
01500 inline CbcCutModifier * cutModifier() const {
01501 return cutModifier_;
01502 }
01504 void setCutModifier(CbcCutModifier * modifier);
01509 void setCutModifier(CbcCutModifier & modifier);
01511
01514
01521 inline int stateOfSearch() const {
01522 return stateOfSearch_;
01523 }
01524 inline void setStateOfSearch(int state) {
01525 stateOfSearch_ = state;
01526 }
01528 inline int searchStrategy() const {
01529 return searchStrategy_;
01530 }
01532 inline void setSearchStrategy(int value) {
01533 searchStrategy_ = value;
01534 }
01536 inline int strongStrategy() const {
01537 return strongStrategy_;
01538 }
01540 inline void setStrongStrategy(int value) {
01541 strongStrategy_ = value;
01542 }
01543
01545 inline int numberCutGenerators() const {
01546 return numberCutGenerators_;
01547 }
01549 inline CbcCutGenerator ** cutGenerators() const {
01550 return generator_;
01551 }
01553 inline CbcCutGenerator * cutGenerator(int i) const {
01554 return generator_[i];
01555 }
01557 inline CbcCutGenerator * virginCutGenerator(int i) const {
01558 return virginGenerator_[i];
01559 }
01568 void addCutGenerator(CglCutGenerator * generator,
01569 int howOften = 1, const char * name = NULL,
01570 bool normal = true, bool atSolution = false,
01571 bool infeasible = false, int howOftenInSub = -100,
01572 int whatDepth = -1, int whatDepthInSub = -1);
01574
01579
01581 inline CbcStrategy * strategy() const {
01582 return strategy_;
01583 }
01585 void setStrategy(CbcStrategy & strategy);
01587 inline void setStrategy(CbcStrategy * strategy) {
01588 strategy_ = strategy;
01589 }
01591 inline CbcModel * parentModel() const {
01592 return parentModel_;
01593 }
01595 inline void setParentModel(CbcModel & parentModel) {
01596 parentModel_ = &parentModel;
01597 }
01599
01600
01607 void addHeuristic(CbcHeuristic * generator, const char *name = NULL,
01608 int before = -1);
01610 inline CbcHeuristic * heuristic(int i) const {
01611 return heuristic_[i];
01612 }
01614 inline int numberHeuristics() const {
01615 return numberHeuristics_;
01616 }
01618 inline void setNumberHeuristics(int value) {
01619 numberHeuristics_ = value;
01620 }
01622 inline CbcHeuristic * lastHeuristic() const {
01623 return lastHeuristic_;
01624 }
01626 inline void setLastHeuristic(CbcHeuristic * last) {
01627 lastHeuristic_ = last;
01628 }
01629
01648 void passInPriorities(const int * priorities, bool ifNotSimpleIntegers);
01649
01651 inline int priority(int sequence) const {
01652 return object_[sequence]->priority();
01653 }
01654
01659 void passInEventHandler(const CbcEventHandler *eventHandler) ;
01660
01662 inline CbcEventHandler* getEventHandler() const {
01663 return (eventHandler_) ;
01664 }
01665
01667
01677 void setApplicationData (void * appData);
01678
01680 void * getApplicationData() const;
01693 void passInSolverCharacteristics(OsiBabSolver * solverCharacteristics);
01695 inline const OsiBabSolver * solverCharacteristics() const {
01696 return solverCharacteristics_;
01697 }
01699
01700
01701
01704
01705 void passInMessageHandler(CoinMessageHandler * handler);
01707 void newLanguage(CoinMessages::Language language);
01708 inline void setLanguage(CoinMessages::Language language) {
01709 newLanguage(language);
01710 }
01712 inline CoinMessageHandler * messageHandler() const {
01713 return handler_;
01714 }
01716 inline CoinMessages & messages() {
01717 return messages_;
01718 }
01720 inline CoinMessages * messagesPointer() {
01721 return &messages_;
01722 }
01724 void setLogLevel(int value);
01726 inline int logLevel() const {
01727 return handler_->logLevel();
01728 }
01734 inline void setDefaultHandler(bool yesNo) {
01735 defaultHandler_ = yesNo;
01736 }
01738
01740
01741
01768 inline void setSpecialOptions(int value) {
01769 specialOptions_ = value;
01770 }
01772 inline int specialOptions() const {
01773 return specialOptions_;
01774 }
01776 inline void setRandomSeed(int value) {
01777 randomSeed_ = value;
01778 }
01780 inline int getRandomSeed() const {
01781 return randomSeed_;
01782 }
01784 inline void setMultipleRootTries(int value) {
01785 multipleRootTries_ = value;
01786 }
01788 inline int getMultipleRootTries() const {
01789 return multipleRootTries_;
01790 }
01792 inline void sayEventHappened()
01793 { eventHappened_=true;}
01795 inline bool normalSolver() const {
01796 return (specialOptions_&16) == 0;
01797 }
01802 inline bool waitingForMiniBranchAndBound() const {
01803 return (specialOptions_&1048576) != 0;
01804 }
01822 inline void setMoreSpecialOptions(int value) {
01823 moreSpecialOptions_ = value;
01824 }
01826 inline int moreSpecialOptions() const {
01827 return moreSpecialOptions_;
01828 }
01830 inline void setUseElapsedTime(bool yesNo) {
01831 if (yesNo)
01832 moreSpecialOptions_ |= 131072;
01833 else
01834 moreSpecialOptions_ &= ~131072;
01835 }
01837 inline bool useElapsedTime() const {
01838 return (moreSpecialOptions_&131072)!=0;
01839 }
01841 #ifdef COIN_HAS_CLP
01842 void goToDantzig(int numberNodes, ClpDualRowPivot *& savePivotMethod);
01843 #endif
01845 inline bool ownObjects() const {
01846 return ownObjects_;
01847 }
01849 void checkModel();
01851
01852
01854
01855
01856 CbcModel();
01857
01859 CbcModel(const OsiSolverInterface &);
01860
01869 void assignSolver(OsiSolverInterface *&solver, bool deleteSolver = true);
01870
01882 inline void setModelOwnsSolver (bool ourSolver) {
01883 ownership_ = ourSolver ? (ownership_ | 0x80000000) : (ownership_ & (~0x80000000)) ;
01884 }
01885
01891 inline bool modelOwnsSolver () {
01892 return ((ownership_&0x80000000) != 0) ;
01893 }
01894
01898 CbcModel(const CbcModel & rhs, bool cloneHandler = false);
01899
01901 CbcModel & operator=(const CbcModel& rhs);
01902
01904 virtual ~CbcModel ();
01905
01907 inline OsiSolverInterface * solver() const {
01908 return solver_;
01909 }
01910
01912 inline OsiSolverInterface * swapSolver(OsiSolverInterface * solver) {
01913 OsiSolverInterface * returnSolver = solver_;
01914 solver_ = solver;
01915 return returnSolver;
01916 }
01917
01919 inline OsiSolverInterface * continuousSolver() const {
01920 return continuousSolver_;
01921 }
01922
01924 inline void createContinuousSolver() {
01925 continuousSolver_ = solver_->clone();
01926 }
01928 inline void clearContinuousSolver() {
01929 delete continuousSolver_;
01930 continuousSolver_ = NULL;
01931 }
01932
01934 inline OsiSolverInterface * referenceSolver() const {
01935 return referenceSolver_;
01936 }
01937
01939 void saveReferenceSolver();
01940
01946 void resetToReferenceSolver();
01947
01949 void gutsOfDestructor();
01952 void gutsOfDestructor2();
01955 void resetModel();
01961 void gutsOfCopy(const CbcModel & rhs, int mode = 0);
01963 void moveInfo(const CbcModel & rhs);
01965
01967
01968
01969 static bool haveMultiThreadSupport();
01971 CbcThread * masterThread() const {
01972 return masterThread_;
01973 }
01975 CbcNodeInfo ** walkback() const {
01976 return walkback_;
01977 }
01979 inline int getNumberThreads() const {
01980 return numberThreads_;
01981 }
01983 inline void setNumberThreads(int value) {
01984 numberThreads_ = value;
01985 }
01987 inline int getThreadMode() const {
01988 return threadMode_;
01989 }
01999 inline void setThreadMode(int value) {
02000 threadMode_ = value;
02001 }
02008 inline int parallelMode() const {
02009 if (!numberThreads_) {
02010 if ((threadMode_&1) == 0)
02011 return 0;
02012 else
02013 return -1;
02014 return 0;
02015 } else {
02016 if ((threadMode_&1) == 0)
02017 return 1;
02018 else
02019 return -2;
02020 }
02021 }
02024 bool isLocked() const;
02025 #ifdef CBC_THREAD
02026
02030 void lockThread();
02034 void unlockThread();
02035 #else
02036 inline void lockThread() {}
02037 inline void unlockThread() {}
02038 #endif
02039
02046 void setInfoInChild(int type, CbcThread * info);
02053 void moveToModel(CbcModel * baseModel, int mode);
02055 int splitModel(int numberModels, CbcModel ** model,
02056 int numberNodes);
02058 void startSplitModel(int numberIterations);
02060 void mergeModels(int numberModel, CbcModel ** model,
02061 int numberNodes);
02063
02065
02066
02067 int getNodeCount2() const {
02068 return numberNodes2_;
02069 }
02071 void setPointers(const OsiSolverInterface * solver);
02077 int reducedCostFix() ;
02081 void synchronizeHandlers(int makeDefault);
02083 void saveExtraSolution(const double * solution, double objectiveValue);
02085 void saveBestSolution(const double * solution, double objectiveValue);
02087 void deleteSolutions();
02089 int resolve(OsiSolverInterface * solver);
02090 #ifdef CLP_RESOLVE
02092 int resolveClp(OsiClpSolverInterface * solver, int type);
02093 #endif
02094
02098 int chooseBranch(CbcNode * & newNode, int numberPassesLeft,
02099 CbcNode * oldNode, OsiCuts & cuts,
02100 bool & resolved, CoinWarmStartBasis *lastws,
02101 const double * lowerBefore, const double * upperBefore,
02102 OsiSolverBranch * & branches);
02103 int chooseBranch(CbcNode * newNode, int numberPassesLeft, bool & resolved);
02104
02111 CoinWarmStartBasis *getEmptyBasis(int ns = 0, int na = 0) const ;
02112
02124 int takeOffCuts(OsiCuts &cuts,
02125 bool allowResolve, OsiCuts * saveCuts,
02126 int numberNewCuts = 0, const OsiRowCut ** newCuts = NULL) ;
02127
02141 int addCuts(CbcNode * node, CoinWarmStartBasis *&lastws, bool canFix);
02142
02159 bool addCuts1(CbcNode * node, CoinWarmStartBasis *&lastws);
02163 void previousBounds (CbcNode * node, CbcNodeInfo * where, int iColumn,
02164 double & lower, double & upper, int force);
02169 void setObjectiveValue(CbcNode * thisNode, const CbcNode * parentNode) const;
02170
02174 void convertToDynamic();
02176 void synchronizeNumberBeforeTrust(int type = 0);
02178 void zapIntegerInformation(bool leaveObjects = true);
02180 int cliquePseudoCosts(int doStatistics);
02182 void pseudoShadow(int type);
02189 void fillPseudoCosts(double * downCosts, double * upCosts,
02190 int * priority = NULL,
02191 int * numberDown = NULL, int * numberUp = NULL,
02192 int * numberDownInfeasible = NULL,
02193 int * numberUpInfeasible = NULL) const;
02199 void doHeuristicsAtRoot(int deleteHeuristicsAfterwards = 0);
02201 void adjustHeuristics();
02203 inline const double * hotstartSolution() const {
02204 return hotstartSolution_;
02205 }
02207 inline const int * hotstartPriorities() const {
02208 return hotstartPriorities_;
02209 }
02210
02212 inline CbcCountRowCut ** addedCuts() const {
02213 return addedCuts_;
02214 }
02216 inline int currentNumberCuts() const {
02217 return currentNumberCuts_;
02218 }
02220 inline CbcRowCuts * globalCuts() {
02221 return &globalCuts_;
02222 }
02224 void setNextRowCut(const OsiRowCut & cut);
02226 inline CbcNode * currentNode() const {
02227 return currentNode_;
02228 }
02230 inline CglTreeProbingInfo * probingInfo() const {
02231 return probingInfo_;
02232 }
02234 inline CoinThreadRandom * randomNumberGenerator() {
02235 return &randomNumberGenerator_;
02236 }
02238 inline void setNumberStrongIterations(int number) {
02239 numberStrongIterations_ = number;
02240 }
02242 inline int numberStrongIterations() const {
02243 return numberStrongIterations_;
02244 }
02246 inline int maximumNumberIterations() const {
02247 return maximumNumberIterations_;
02248 }
02250 inline void setMaximumNumberIterations(int value) {
02251 maximumNumberIterations_ = value;
02252 }
02253 # ifdef COIN_HAS_CLP
02255 inline void setFastNodeDepth(int value) {
02256 fastNodeDepth_ = value;
02257 }
02259 inline int fastNodeDepth() const {
02260 return fastNodeDepth_;
02261 }
02263 inline int continuousPriority() const {
02264 return continuousPriority_;
02265 }
02267 inline void setContinuousPriority(int value) {
02268 continuousPriority_ = value;
02269 }
02270 inline void incrementExtra(int nodes, int iterations) {
02271 numberExtraNodes_ += nodes;
02272 numberExtraIterations_ += iterations;
02273 }
02274 #endif
02276 inline int numberExtraIterations() const {
02277 return numberExtraIterations_;
02278 }
02280 void incrementStrongInfo(int numberTimes, int numberIterations,
02281 int numberFixed, bool ifInfeasible);
02283 inline const int * strongInfo() const {
02284 return strongInfo_;
02285 }
02286
02288 inline int * mutableStrongInfo() {
02289 return strongInfo_;
02290 }
02292 CglStored * storedRowCuts() const {
02293 return storedRowCuts_;
02294 }
02296 void setStoredRowCuts(CglStored * cuts) {
02297 storedRowCuts_ = cuts;
02298 }
02300 inline bool allDynamic () const {
02301 return ((ownership_&0x40000000) != 0) ;
02302 }
02304 void generateCpp( FILE * fp, int options);
02306 OsiBranchingInformation usefulInformation() const;
02313 inline void setBestSolutionBasis(const CoinWarmStartBasis & bestSolutionBasis) {
02314 bestSolutionBasis_ = bestSolutionBasis;
02315 }
02317 void redoWalkBack();
02319
02320
02321
02322 private:
02324
02325
02327 OsiSolverInterface * solver_;
02328
02334 unsigned int ownership_ ;
02335
02337 OsiSolverInterface * continuousSolver_;
02338
02340 OsiSolverInterface * referenceSolver_;
02341
02343 CoinMessageHandler * handler_;
02344
02350 bool defaultHandler_;
02351
02353 CoinMessages messages_;
02354
02356 int intParam_[CbcLastIntParam];
02357
02359 double dblParam_[CbcLastDblParam];
02360
02369 mutable CoinWarmStart *emptyWarmStart_ ;
02370
02372 double bestObjective_;
02374 double bestPossibleObjective_;
02376 double sumChangeObjective1_;
02378 double sumChangeObjective2_;
02379
02381 double * bestSolution_;
02383 double ** savedSolutions_;
02384
02389 double * currentSolution_;
02393 mutable const double * testSolution_;
02400 CoinWarmStartBasis bestSolutionBasis_ ;
02402 CbcRowCuts globalCuts_;
02404 CbcRowCuts * globalConflictCuts_;
02405
02407 double minimumDrop_;
02409 int numberSolutions_;
02411 int numberSavedSolutions_;
02413 int maximumSavedSolutions_;
02420 int stateOfSearch_;
02422 int whenCuts_;
02424 double * hotstartSolution_;
02426 int * hotstartPriorities_;
02428 int numberHeuristicSolutions_;
02430 int numberNodes_;
02434 int numberNodes2_;
02436 int numberIterations_;
02438 int numberSolves_;
02440 int status_;
02451 int secondaryStatus_;
02453 int numberIntegers_;
02455 int numberRowsAtContinuous_;
02457 int maximumNumberCuts_;
02466 int phase_;
02467
02469 int currentNumberCuts_;
02470
02475 int maximumDepth_;
02481 CbcNodeInfo ** walkback_;
02482 CbcNodeInfo ** lastNodeInfo_;
02483 const OsiRowCut ** lastCut_;
02484 int lastDepth_;
02485 int lastNumberCuts2_;
02486 int maximumCuts_;
02487 int * lastNumberCuts_;
02488
02496 CbcCountRowCut ** addedCuts_;
02497
02501 OsiRowCut * nextRowCut_;
02502
02504 CbcNode * currentNode_;
02505
02507 int * integerVariable_;
02509 char * integerInfo_;
02511 double * continuousSolution_;
02513 int * usedInSolution_;
02537 int specialOptions_;
02552 int moreSpecialOptions_;
02554 CbcCompareBase * nodeCompare_;
02556 CbcFeasibilityBase * problemFeasibility_;
02558 CbcTree * tree_;
02560 CbcFullNodeInfo * topOfTree_;
02562 CbcModel * subTreeModel_;
02564 CbcModel * heuristicModel_;
02566 int numberStoppedSubTrees_;
02568 CbcBranchDecision * branchingMethod_;
02570 CbcCutModifier * cutModifier_;
02572 CbcStrategy * strategy_;
02574 CbcModel * parentModel_;
02580
02581 const double * cbcColLower_;
02583 const double * cbcColUpper_;
02585 const double * cbcRowLower_;
02587 const double * cbcRowUpper_;
02589 const double * cbcColSolution_;
02591 const double * cbcRowPrice_;
02593 const double * cbcReducedCost_;
02595 const double * cbcRowActivity_;
02597 void * appData_;
02599 int presolve_;
02603 int numberStrong_;
02609 int numberBeforeTrust_;
02613 int numberPenalties_;
02615 int stopNumberIterations_;
02618 double penaltyScaleFactor_;
02620 int numberAnalyzeIterations_;
02622 double * analyzeResults_;
02624 int numberInfeasibleNodes_;
02631 int problemType_;
02633 int printFrequency_;
02635 int numberCutGenerators_;
02636
02637 CbcCutGenerator ** generator_;
02638
02639 CbcCutGenerator ** virginGenerator_;
02641 int numberHeuristics_;
02643 CbcHeuristic ** heuristic_;
02645 CbcHeuristic * lastHeuristic_;
02647 int fastNodeDepth_;
02649 # ifdef CBC_ONLY_CLP
02650 ClpEventHandler *eventHandler_ ;
02651 # else
02652 CbcEventHandler *eventHandler_ ;
02653 # endif
02654
02656 int numberObjects_;
02657
02668 OsiObject ** object_;
02670 bool ownObjects_;
02671
02673 int * originalColumns_;
02675 int howOftenGlobalScan_;
02678 int numberGlobalViolations_;
02680 int numberExtraIterations_;
02682 int numberExtraNodes_;
02686 double continuousObjective_;
02689 double originalContinuousObjective_;
02691 int continuousInfeasibilities_;
02693 int maximumCutPassesAtRoot_;
02695 int maximumCutPasses_;
02697 int preferredWay_;
02699 int currentPassNumber_;
02701 int maximumWhich_;
02703 int maximumRows_;
02705 int randomSeed_;
02707 int multipleRootTries_;
02709 int currentDepth_;
02711 mutable CoinThreadRandom randomNumberGenerator_;
02713 CoinWarmStartBasis workingBasis_;
02715 int * whichGenerator_;
02717 int maximumStatistics_;
02719 CbcStatistics ** statistics_;
02721 int maximumDepthActual_;
02723 double numberDJFixed_;
02725 CglTreeProbingInfo * probingInfo_;
02727 int numberFixedAtRoot_;
02729 int numberFixedNow_;
02731 bool stoppedOnGap_;
02733 mutable bool eventHappened_;
02735 int numberLongStrong_;
02737 int numberOldActiveCuts_;
02739 int numberNewCuts_;
02741 int searchStrategy_;
02753 int strongStrategy_;
02755 int numberStrongIterations_;
02758 int strongInfo_[7];
02765 OsiBabSolver * solverCharacteristics_;
02767 bool resolveAfterTakeOffCuts_;
02769 int maximumNumberIterations_;
02771 int continuousPriority_;
02773 int numberUpdateItems_;
02775 int maximumNumberUpdateItems_;
02777 CbcObjectUpdateData * updateItems_;
02779 CglStored * storedRowCuts_;
02787 int numberThreads_;
02795 int threadMode_;
02797 CbcBaseModel * master_;
02799 CbcThread * masterThread_;
02801 };
02803 void getIntegerInformation(const OsiObject * object, double & originalLower,
02804 double & originalUpper) ;
02805
02806
02807 class OsiClpSolverInterface;
02808 int CbcMain (int argc, const char *argv[], OsiClpSolverInterface & solver, CbcModel ** babSolver);
02809 int CbcMain (int argc, const char *argv[], CbcModel & babSolver);
02810
02811 int callCbc(const char * input2, OsiClpSolverInterface& solver1);
02812 int callCbc(const char * input2);
02813 int callCbc(const std::string input2, OsiClpSolverInterface& solver1);
02814 int callCbc(const std::string input2) ;
02815
02816 void CbcMain0 (CbcModel & babSolver);
02817 int CbcMain1 (int argc, const char *argv[], CbcModel & babSolver);
02818
02819 int callCbc(const char * input2, CbcModel & babSolver);
02820 int callCbc(const std::string input2, CbcModel & babSolver);
02821
02822 int callCbc1(const char * input2, CbcModel & babSolver);
02823 int callCbc1(const std::string input2, CbcModel & babSolver);
02824
02825 int callCbc1(const char * input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02826 int callCbc1(const std::string input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02827 int CbcMain1 (int argc, const char *argv[], CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02828
02829 void setCutAndHeuristicOptions(CbcModel & model);
02830 #endif
02831