00001
00002
00003 #ifndef CbcModel_H
00004 #define CbcModel_H
00005 #include <string>
00006 #include <vector>
00007 #include "CoinFinite.hpp"
00008 #include "CoinMessageHandler.hpp"
00009 #include "OsiSolverInterface.hpp"
00010 #include "OsiBranchingObject.hpp"
00011 #include "OsiCuts.hpp"
00012 #include "CoinWarmStartBasis.hpp"
00013 #include "CbcCompareBase.hpp"
00014 #include "CbcMessage.hpp"
00015
00016
00017
00018 class CbcCutGenerator;
00019 class OsiRowCut;
00020 class OsiBabSolver;
00021 class OsiRowCutDebugger;
00022 class CglCutGenerator;
00023 class CbcCutModifier;
00024 class CglTreeProbingInfo;
00025 class CbcHeuristic;
00026 class OsiObject;
00027 class CbcTree;
00028 class CbcStrategy;
00029 class CbcFeasibilityBase;
00030 class CbcStatistics;
00031 class CbcEventHandler ;
00032 class CglPreProcess;
00033 # ifdef COIN_HAS_CLP
00034 class ClpNodeStuff;
00035 #endif
00036
00037
00038
00039
00092 class CbcModel {
00093
00094 public:
00095
00096 enum CbcIntParam {
00098 CbcMaxNumNode=0,
00100 CbcMaxNumSol,
00110 CbcFathomDiscipline,
00114 CbcPrinting,
00116 CbcLastIntParam
00117 };
00118
00119 enum CbcDblParam {
00122 CbcIntegerTolerance=0,
00125 CbcInfeasibilityWeight,
00128 CbcCutoffIncrement,
00135 CbcAllowableGap,
00142 CbcAllowableFractionGap,
00145 CbcMaximumSeconds,
00147 CbcCurrentCutoff,
00149 CbcOptimizationDirection,
00151 CbcCurrentObjectiveValue,
00153 CbcCurrentMinimizationObjectiveValue,
00156 CbcStartSeconds,
00158 CbcLastDblParam
00159 };
00160
00161
00162
00163 public:
00165
00166
00170 void initialSolve();
00171
00182 void branchAndBound(int doStatistics=0);
00183
00188 CbcModel * cleanModel(const double * lower, const double * upper);
00205 int subBranchAndBound(CbcModel * model2,
00206 CbcModel * presolvedModel,
00207 int maximumNodes);
00223 int subBranchAndBound(const double * lower, const double * upper,
00224 int maximumNodes);
00225
00232 OsiSolverInterface * strengthenedModel();
00242 CglPreProcess * preProcess( int makeEquality=0, int numberPasses=5,
00243 int tuning=5);
00246 void postProcess(CglPreProcess * process);
00247 private:
00255 bool solveWithCuts(OsiCuts & cuts, int numberTries,CbcNode * node);
00262 CbcNode ** solveOneNode(int whichSolver,CbcNode * node,
00263 int & numberNodesOutput, int & status) ;
00265 void resizeWhichGenerator(int numberNow, int numberAfter);
00266 public:
00267 #ifndef CBC_THREAD
00268 #define NEW_UPDATE_OBJECT 2
00269 #else
00270 #define NEW_UPDATE_OBJECT 2
00271 #endif
00272 #if NEW_UPDATE_OBJECT>1
00274 void addUpdateInformation(const CbcObjectUpdateData & data);
00275 #endif
00276
00282 int doOneNode(CbcModel * baseModel, CbcNode * & node, CbcNode * & newNode);
00283
00285 bool isLocked() const;
00287 #if 0
00288 int whileIterating(bool & locked, threadId, threadInfo,condition_mutex,condition_main,
00289 timeWaiting,threadModel,threadStats,totalTime,cutoff,
00290 eventHandler,saveCompare,lastDepth,lastUnsatisfied,createdNode);
00291 #else
00292 int whileIterating(int numberIterations);
00293 #endif
00294 #ifdef CBC_THREAD
00295
00299 void lockThread();
00303 void unlockThread();
00304 #else
00305 inline void lockThread() {}
00306 inline void unlockThread() {}
00307 #endif
00308 private:
00315 void moveToModel(CbcModel * baseModel,int mode);
00316 public:
00330 int resolve(CbcNodeInfo * parent, int whereFrom,
00331 double * saveSolution=NULL,
00332 double * saveLower=NULL,
00333 double * saveUpper=NULL);
00335 void makeGlobalCuts(int numberRows,const int * which);
00337 void makeGlobalCut(const OsiRowCut * cut);
00339 void makeGlobalCut(const OsiRowCut & cut);
00341
00344
00356 CbcModel * findCliques(bool makeEquality, int atLeastThisMany,
00357 int lessThanThis, int defaultValue=1000);
00358
00367 CbcModel * integerPresolve(bool weak=false);
00368
00373 bool integerPresolveThisModel(OsiSolverInterface * originalSolver,bool weak=false);
00374
00375
00377 void originalModel(CbcModel * presolvedModel,bool weak);
00378
00399 bool tightenVubs(int type,bool allowMultipleBinary=false,
00400 double useCutoff=1.0e50);
00401
00407 bool tightenVubs(int numberVubs, const int * which,
00408 double useCutoff=1.0e50);
00412 void analyzeObjective();
00413
00414
00416
00422
00424 inline int numberObjects() const { return numberObjects_;}
00426 inline void setNumberObjects(int number)
00427 { numberObjects_=number;}
00428
00430 inline OsiObject ** objects() const { return object_;}
00431
00433 const inline OsiObject * object(int which) const { return object_[which];}
00435 inline OsiObject * modifiableObject(int which) const { return object_[which];}
00436
00438 void deleteObjects(bool findIntegers=true);
00439
00444 void addObjects(int numberObjects, OsiObject ** objects);
00445
00450 void addObjects(int numberObjects, CbcObject ** objects);
00451
00453 void synchronizeModel() ;
00454
00464 void findIntegers(bool startAgain,int type=0);
00465
00467
00468
00469
00479
00480 inline bool setIntParam(CbcIntParam key, int value) {
00481 intParam_[key] = value;
00482 return true;
00483 }
00485 inline bool setDblParam(CbcDblParam key, double value) {
00486 dblParam_[key] = value;
00487 return true;
00488 }
00490 inline int getIntParam(CbcIntParam key) const {
00491 return intParam_[key];
00492 }
00494 inline double getDblParam(CbcDblParam key) const {
00495 return dblParam_[key];
00496 }
00502 void setCutoff(double value) ;
00503
00505 inline double getCutoff() const
00506 {
00507
00508
00509 return dblParam_[CbcCurrentCutoff];
00510 }
00511
00513 inline bool setMaximumNodes( int value)
00514 { return setIntParam(CbcMaxNumNode,value); }
00515
00517 inline int getMaximumNodes() const
00518 { return getIntParam(CbcMaxNumNode); }
00519
00524 inline bool setMaximumSolutions( int value) {
00525 return setIntParam(CbcMaxNumSol,value);
00526 }
00531 inline int getMaximumSolutions() const {
00532 return getIntParam(CbcMaxNumSol);
00533 }
00535 inline bool setPrintingMode( int value)
00536 { return setIntParam(CbcPrinting,value); }
00537
00539 inline int getPrintingMode() const
00540 { return getIntParam(CbcPrinting); }
00541
00546 inline bool setMaximumSeconds( double value) {
00547 return setDblParam(CbcMaximumSeconds,value);
00548 }
00553 inline double getMaximumSeconds() const {
00554 return getDblParam(CbcMaximumSeconds);
00555 }
00557 double getCurrentSeconds() const ;
00558
00562 inline bool setIntegerTolerance( double value) {
00563 return setDblParam(CbcIntegerTolerance,value);
00564 }
00568 inline double getIntegerTolerance() const {
00569 return getDblParam(CbcIntegerTolerance);
00570 }
00571
00576 inline bool setInfeasibilityWeight( double value) {
00577 return setDblParam(CbcInfeasibilityWeight,value);
00578 }
00583 inline double getInfeasibilityWeight() const {
00584 return getDblParam(CbcInfeasibilityWeight);
00585 }
00586
00590 inline bool setAllowableGap( double value) {
00591 return setDblParam(CbcAllowableGap,value);
00592 }
00596 inline double getAllowableGap() const {
00597 return getDblParam(CbcAllowableGap);
00598 }
00599
00603 inline bool setAllowableFractionGap( double value) {
00604 return setDblParam(CbcAllowableFractionGap,value);
00605 }
00609 inline double getAllowableFractionGap() const {
00610 return getDblParam(CbcAllowableFractionGap);
00611 }
00615 inline bool setAllowablePercentageGap( double value) {
00616 return setDblParam(CbcAllowableFractionGap,value*0.01);
00617 }
00621 inline double getAllowablePercentageGap() const {
00622 return 100.0*getDblParam(CbcAllowableFractionGap);
00623 }
00628 inline bool setCutoffIncrement( double value) {
00629 return setDblParam(CbcCutoffIncrement,value);
00630 }
00635 inline double getCutoffIncrement() const {
00636 return getDblParam(CbcCutoffIncrement);
00637 }
00638
00643 void setHotstartSolution(const double * solution, const int * priorities=NULL) ;
00644
00646 inline void setMinimumDrop(double value)
00647 {minimumDrop_=value;}
00649 inline double getMinimumDrop() const
00650 { return minimumDrop_;}
00651
00654 inline void setMaximumCutPassesAtRoot(int value)
00655 {maximumCutPassesAtRoot_=value;}
00657 inline int getMaximumCutPassesAtRoot() const
00658 { return maximumCutPassesAtRoot_;}
00659
00662 inline void setMaximumCutPasses(int value)
00663 {maximumCutPasses_=value;}
00665 inline int getMaximumCutPasses() const
00666 { return maximumCutPasses_;}
00669 inline int getCurrentPassNumber() const
00670 { return currentPassNumber_;}
00671
00677 void setNumberStrong(int number);
00681 inline int numberStrong() const
00682 { return numberStrong_;}
00685 inline void setPreferredWay(int value)
00686 {preferredWay_=value;}
00688 inline int getPreferredWay() const
00689 { return preferredWay_;}
00691 inline int whenCuts() const
00692 { return whenCuts_;}
00694 inline void setWhenCuts(int value)
00695 { whenCuts_ = value;}
00701 bool doCutsNow(int allowForTopOfTree) const;
00705 inline void setSizeMiniTree(int value)
00706 { sizeMiniTree_=value;}
00707 inline int sizeMiniTree() const
00708 { return sizeMiniTree_;}
00709
00715 void setNumberBeforeTrust(int number);
00718 inline int numberBeforeTrust() const
00719 { return numberBeforeTrust_;}
00725 void setNumberPenalties(int number);
00728 inline int numberPenalties() const
00729 { return numberPenalties_;}
00731 inline void setNumberAnalyzeIterations(int number)
00732 { numberAnalyzeIterations_=number;}
00733 inline int numberAnalyzeIterations() const
00734 { return numberAnalyzeIterations_;}
00737 inline double penaltyScaleFactor() const
00738 { return penaltyScaleFactor_;}
00741 void setPenaltyScaleFactor(double value);
00749 void inline setProblemType(int number)
00750 { problemType_=number;}
00751 inline int problemType() const
00752 { return problemType_;}
00754 inline int currentDepth() const
00755 { return currentDepth_;}
00756
00758 void setHowOftenGlobalScan(int number);
00760 inline int howOftenGlobalScan() const
00761 { return howOftenGlobalScan_;}
00763 inline int * originalColumns() const
00764 { return originalColumns_;}
00766 void setOriginalColumns(const int * originalColumns) ;
00767
00775 inline void setPrintFrequency(int number)
00776 { printFrequency_=number;}
00778 inline int printFrequency() const
00779 { return printFrequency_;}
00781
00782
00784
00785
00786 bool isAbandoned() const;
00788 bool isProvenOptimal() const;
00790 bool isProvenInfeasible() const;
00792 bool isContinuousUnbounded() const;
00794 bool isProvenDualInfeasible() const;
00796 bool isNodeLimitReached() const;
00798 bool isSecondsLimitReached() const;
00800 bool isSolutionLimitReached() const;
00802 inline int getIterationCount() const
00803 { return numberIterations_;}
00805 inline void incrementIterationCount(int value)
00806 { numberIterations_ += value;}
00808 inline int getNodeCount() const
00809 { return numberNodes_;}
00811 inline void incrementNodeCount(int value)
00812 { numberNodes_ += value;}
00822 inline int status() const
00823 { return status_;}
00824 inline void setProblemStatus(int value)
00825 { status_=value;}
00837 inline int secondaryStatus() const
00838 { return secondaryStatus_;}
00839 inline void setSecondaryStatus(int value)
00840 { secondaryStatus_=value;}
00842 bool isInitialSolveAbandoned() const ;
00844 bool isInitialSolveProvenOptimal() const ;
00846 bool isInitialSolveProvenPrimalInfeasible() const ;
00848 bool isInitialSolveProvenDualInfeasible() const ;
00849
00851
00852
00865
00866 inline int numberRowsAtContinuous() const
00867 { return numberRowsAtContinuous_;}
00868
00870 inline int getNumCols() const
00871 { return solver_->getNumCols();}
00872
00874 inline int getNumRows() const
00875 { return solver_->getNumRows();}
00876
00878 inline CoinBigIndex getNumElements() const
00879 { return solver_->getNumElements();}
00880
00882 inline int numberIntegers() const
00883 { return numberIntegers_;}
00884
00885 inline const int * integerVariable() const
00886 { return integerVariable_;}
00888 inline char integerType(int i) const
00889 { return integerInfo_[i];}
00891 inline const char * integerType() const
00892 { return integerInfo_;}
00893
00895 inline const double * getColLower() const
00896 { return solver_->getColLower();}
00897
00899 inline const double * getColUpper() const
00900 { return solver_->getColUpper();}
00901
00911 inline const char * getRowSense() const
00912 { return solver_->getRowSense();}
00913
00922 inline const double * getRightHandSide() const
00923 { return solver_->getRightHandSide();}
00924
00933 inline const double * getRowRange() const
00934 { return solver_->getRowRange();}
00935
00937 inline const double * getRowLower() const
00938 { return solver_->getRowLower();}
00939
00941 inline const double * getRowUpper() const
00942 { return solver_->getRowUpper();}
00943
00945 inline const double * getObjCoefficients() const
00946 { return solver_->getObjCoefficients();}
00947
00949 inline double getObjSense() const
00950 {
00951
00952 return dblParam_[CbcOptimizationDirection];}
00953
00955 inline bool isContinuous(int colIndex) const
00956 { return solver_->isContinuous(colIndex);}
00957
00959 inline bool isBinary(int colIndex) const
00960 { return solver_->isBinary(colIndex);}
00961
00966 inline bool isInteger(int colIndex) const
00967 { return solver_->isInteger(colIndex);}
00968
00970 inline bool isIntegerNonBinary(int colIndex) const
00971 { return solver_->isIntegerNonBinary(colIndex);}
00972
00974 inline bool isFreeBinary(int colIndex) const
00975 { return solver_->isFreeBinary(colIndex) ;}
00976
00978 inline const CoinPackedMatrix * getMatrixByRow() const
00979 { return solver_->getMatrixByRow();}
00980
00982 inline const CoinPackedMatrix * getMatrixByCol() const
00983 { return solver_->getMatrixByCol();}
00984
00986 inline double getInfinity() const
00987 { return solver_->getInfinity();}
00989 inline const double * getCbcColLower() const
00990 { return cbcColLower_;}
00992 inline const double * getCbcColUpper() const
00993 { return cbcColUpper_;}
00995 inline const double * getCbcRowLower() const
00996 { return cbcRowLower_;}
00998 inline const double * getCbcRowUpper() const
00999 { return cbcRowUpper_;}
01001 inline const double * getCbcColSolution() const
01002 { return cbcColSolution_;}
01004 inline const double * getCbcRowPrice() const
01005 { return cbcRowPrice_;}
01007 inline const double * getCbcReducedCost() const
01008 { return cbcReducedCost_;}
01010 inline const double * getCbcRowActivity() const
01011 { return cbcRowActivity_;}
01013
01014
01017
01018 inline double * continuousSolution() const
01019 { return continuousSolution_;}
01024 inline int * usedInSolution() const
01025 { return usedInSolution_;}
01027 void incrementUsed(const double * solution);
01029 void setBestSolution(CBC_Message how,
01030 double & objectiveValue, const double *solution,
01031 int fixVariables=0);
01033 void setBestObjectiveValue( double objectiveValue);
01034
01041 double checkSolution(double cutoff, double * solution,
01042 int fixVariables, double originalObjValue);
01049 bool feasibleSolution(int & numberIntegerInfeasibilities,
01050 int & numberObjectInfeasibilities) const;
01051
01057 inline double * currentSolution() const
01058 { return currentSolution_;}
01062 inline const double * testSolution() const
01063 { return testSolution_;}
01064 inline void setTestSolution(const double * solution)
01065 { testSolution_ = solution;}
01067 void reserveCurrentSolution(const double * solution=NULL);
01068
01070 inline const double * getColSolution() const
01071 { return solver_->getColSolution();}
01072
01074 inline const double * getRowPrice() const
01075 { return solver_->getRowPrice();}
01076
01078 inline const double * getReducedCost() const
01079 { return solver_->getReducedCost();}
01080
01082 inline const double * getRowActivity() const
01083 { return solver_->getRowActivity();}
01084
01086 inline double getCurrentObjValue() const
01087 { return dblParam_[CbcCurrentObjectiveValue]; }
01089 inline double getCurrentMinimizationObjValue() const
01090 { return dblParam_[CbcCurrentMinimizationObjectiveValue];}
01091
01093 inline double getMinimizationObjValue() const
01094 { return bestObjective_;}
01096 inline void setMinimizationObjValue(double value)
01097 { bestObjective_=value;}
01098
01100 inline double getObjValue() const
01101 { return bestObjective_ * solver_->getObjSense() ; }
01107 double getBestPossibleObjValue() const;
01109 inline void setObjValue(double value)
01110 { bestObjective_=value * solver_->getObjSense() ;}
01111
01118 inline double * bestSolution() const
01119 { return bestSolution_;}
01126 void setBestSolution(const double * solution,int numberColumns,
01127 double objectiveValue,bool check=false);
01128
01130 inline int getSolutionCount() const
01131 { return numberSolutions_;}
01132
01134 inline void setSolutionCount(int value)
01135 { numberSolutions_=value;}
01144 inline int phase() const
01145 { return phase_;}
01146
01148 inline int getNumberHeuristicSolutions() const { return numberHeuristicSolutions_;}
01150 inline void setNumberHeuristicSolutions(int value) { numberHeuristicSolutions_=value;}
01151
01153 inline void setObjSense(double s) { dblParam_[CbcOptimizationDirection]=s;
01154 solver_->setObjSense(s);}
01155
01157 inline double getContinuousObjective() const
01158 { return originalContinuousObjective_;}
01159 inline void setContinuousObjective(double value)
01160 { originalContinuousObjective_=value;}
01162 inline int getContinuousInfeasibilities() const
01163 { return continuousInfeasibilities_;}
01164 inline void setContinuousInfeasibilities(int value)
01165 { continuousInfeasibilities_=value;}
01167 inline double rootObjectiveAfterCuts() const
01168 { return continuousObjective_;}
01170 inline double sumChangeObjective() const
01171 { return sumChangeObjective1_;}
01174 inline int numberGlobalViolations() const
01175 { return numberGlobalViolations_;}
01176 inline void clearNumberGlobalViolations()
01177 { numberGlobalViolations_=0;}
01179 inline bool resolveAfterTakeOffCuts() const
01180 { return resolveAfterTakeOffCuts_;}
01181 inline void setResolveAfterTakeOffCuts(bool yesNo)
01182 { resolveAfterTakeOffCuts_=yesNo;}
01184 inline int maximumRows() const
01185 { return maximumRows_;}
01187 inline CoinWarmStartBasis & workingBasis()
01188 { return workingBasis_;}
01190 inline int getNumberThreads() const
01191 { return numberThreads_;}
01193 inline void setNumberThreads(int value)
01194 { numberThreads_=value;}
01196 inline int getThreadMode() const
01197 { return threadMode_;}
01205 inline void setThreadMode(int value)
01206 { threadMode_=value;}
01213 inline int parallelMode() const
01214 { if (!numberThreads_) {
01215 if ((threadMode_&1)==0)
01216 return 0;
01217 else
01218 return -1;
01219 return 0;
01220 } else {
01221 if ((threadMode_&1)==0)
01222 return 1;
01223 else
01224 return -2;
01225 }
01226 }
01228 inline int getStopNumberIterations() const
01229 { return stopNumberIterations_;}
01231 inline void setStopNumberIterations(int value)
01232 { stopNumberIterations_=value;}
01234
01237
01238 inline CbcCompareBase * nodeComparison() const
01239 { return nodeCompare_;}
01240 void setNodeComparison(CbcCompareBase * compare);
01241 void setNodeComparison(CbcCompareBase & compare);
01243
01246
01247 inline CbcFeasibilityBase * problemFeasibility() const
01248 { return problemFeasibility_;}
01249 void setProblemFeasibility(CbcFeasibilityBase * feasibility);
01250 void setProblemFeasibility(CbcFeasibilityBase & feasibility);
01252
01255
01256 inline CbcTree * tree() const
01257 { return tree_;}
01259 void passInTreeHandler(CbcTree & tree);
01263 void passInSubTreeModel(CbcModel & model);
01268 CbcModel * subTreeModel(OsiSolverInterface * solver=NULL) const;
01270 inline int numberStoppedSubTrees() const
01271 { return numberStoppedSubTrees_;}
01273 inline void incrementSubTreeStopped()
01274 { numberStoppedSubTrees_++;}
01280 inline int typePresolve() const
01281 { return presolve_;}
01282 inline void setTypePresolve(int value)
01283 { presolve_=value;}
01284
01286
01292
01294 inline CbcBranchDecision * branchingMethod() const
01295 { return branchingMethod_;}
01297 inline void setBranchingMethod(CbcBranchDecision * method)
01298 { delete branchingMethod_; branchingMethod_ = method->clone();}
01303 inline void setBranchingMethod(CbcBranchDecision & method)
01304 { delete branchingMethod_; branchingMethod_ = method.clone();}
01306 inline CbcCutModifier * cutModifier() const
01307 { return cutModifier_;}
01309 void setCutModifier(CbcCutModifier * modifier);
01314 void setCutModifier(CbcCutModifier & modifier);
01316
01319
01326 inline int stateOfSearch() const
01327 { return stateOfSearch_;}
01328 inline void setStateOfSearch(int state)
01329 { stateOfSearch_=state;}
01331 inline int searchStrategy() const
01332 { return searchStrategy_;}
01334 inline void setSearchStrategy(int value)
01335 { searchStrategy_ = value; }
01336
01338 inline int numberCutGenerators() const
01339 { return numberCutGenerators_;}
01341 inline CbcCutGenerator ** cutGenerators() const
01342 { return generator_;}
01344 inline CbcCutGenerator * cutGenerator(int i) const
01345 { return generator_[i];}
01347 inline CbcCutGenerator * virginCutGenerator(int i) const
01348 { return virginGenerator_[i];}
01357 void addCutGenerator(CglCutGenerator * generator,
01358 int howOften=1, const char * name=NULL,
01359 bool normal=true, bool atSolution=false,
01360 bool infeasible=false,int howOftenInSub=-100,
01361 int whatDepth=-1, int whatDepthInSub=-1);
01363
01368
01370 inline CbcStrategy * strategy() const
01371 { return strategy_;}
01373 void setStrategy(CbcStrategy & strategy);
01375 inline CbcModel * parentModel() const
01376 { return parentModel_;}
01378 inline void setParentModel(CbcModel & parentModel)
01379 { parentModel_ = &parentModel;}
01381
01382
01389 void addHeuristic(CbcHeuristic * generator, const char *name = NULL,
01390 int before=-1);
01392 inline CbcHeuristic * heuristic(int i) const
01393 { return heuristic_[i];}
01395 inline int numberHeuristics() const
01396 { return numberHeuristics_;}
01398 inline CbcHeuristic * lastHeuristic() const
01399 { return lastHeuristic_;}
01401 inline void setLastHeuristic(CbcHeuristic * last)
01402 { lastHeuristic_=last;}
01403
01422 void passInPriorities(const int * priorities, bool ifNotSimpleIntegers);
01423
01425 inline int priority(int sequence) const
01426 { return object_[sequence]->priority();}
01427
01432 void passInEventHandler(const CbcEventHandler *eventHandler) ;
01433
01435 inline CbcEventHandler* getEventHandler() const
01436 { return (eventHandler_) ; }
01437
01439
01449 void setApplicationData (void * appData);
01450
01452 void * getApplicationData() const;
01465 void passInSolverCharacteristics(OsiBabSolver * solverCharacteristics);
01467 inline const OsiBabSolver * solverCharacteristics() const
01468 { return solverCharacteristics_;}
01470
01471
01472
01475
01476 void passInMessageHandler(CoinMessageHandler * handler);
01478 void newLanguage(CoinMessages::Language language);
01479 inline void setLanguage(CoinMessages::Language language)
01480 {newLanguage(language);}
01482 inline CoinMessageHandler * messageHandler() const
01483 {return handler_;}
01485 inline CoinMessages & messages()
01486 {return messages_;}
01488 inline CoinMessages * messagesPointer()
01489 {return &messages_;}
01491 void setLogLevel(int value);
01493 inline int logLevel() const
01494 { return handler_->logLevel();}
01496
01498
01499
01519
01520 inline void setSpecialOptions(int value)
01521 { specialOptions_=value;}
01523 inline int specialOptions() const
01524 { return specialOptions_;}
01526 inline bool normalSolver() const
01527 { return (specialOptions_&16)==0;}
01529 inline bool ownObjects() const
01530 { return ownObjects_;}
01532 void checkModel();
01534 inline void * mutex()
01535 { return mutex_;}
01537 int splitModel(int numberModels, CbcModel ** model,
01538 int numberNodes);
01540 void startSplitModel(int numberIterations);
01542 void mergeModels(int numberModel, CbcModel ** model,
01543 int numberNodes);
01545
01546
01548
01549
01550 CbcModel();
01551
01553 CbcModel(const OsiSolverInterface &);
01554
01563 void assignSolver(OsiSolverInterface *&solver,bool deleteSolver=true);
01564
01576 inline void setModelOwnsSolver (bool ourSolver)
01577 { ownership_ = ourSolver ? (ownership_ |0x80000000) : (ownership_ & (~0x80000000)) ; }
01578
01584 inline bool modelOwnsSolver () { return ((ownership_&0x80000000)!=0) ; }
01585
01589 CbcModel(const CbcModel & rhs, bool cloneHandler=false);
01590
01592 CbcModel & operator=(const CbcModel& rhs);
01593
01595 ~CbcModel ();
01596
01598 inline OsiSolverInterface * solver() const
01599 { return solver_;}
01600
01602 inline OsiSolverInterface * swapSolver(OsiSolverInterface * solver)
01603 { OsiSolverInterface * returnSolver = solver_; solver_ = solver; return returnSolver;}
01604
01606 inline OsiSolverInterface * continuousSolver() const
01607 { return continuousSolver_;}
01608
01610 inline void createContinuousSolver()
01611 { continuousSolver_ = solver_->clone();}
01613 inline void clearContinuousSolver()
01614 { delete continuousSolver_; continuousSolver_ = NULL;}
01615
01617 inline OsiSolverInterface * referenceSolver() const
01618 { return referenceSolver_;}
01619
01621 void saveReferenceSolver();
01622
01628 void resetToReferenceSolver();
01629
01631 void gutsOfDestructor();
01634 void gutsOfDestructor2();
01637 void resetModel();
01643 void gutsOfCopy(const CbcModel & rhs,int mode=0);
01645 void moveInfo(const CbcModel & rhs);
01647
01649
01650
01651 int getNodeCount2() const
01652 { return numberNodes2_;}
01654 void setPointers(const OsiSolverInterface * solver);
01660 int reducedCostFix() ;
01664 void synchronizeHandlers(int makeDefault);
01665
01667 int resolve(OsiSolverInterface * solver);
01668
01672 int chooseBranch(CbcNode * & newNode, int numberPassesLeft,
01673 CbcNode * oldNode, OsiCuts & cuts,
01674 bool & resolved, CoinWarmStartBasis *lastws,
01675 const double * lowerBefore,const double * upperBefore,
01676 OsiSolverBranch * & branches);
01677 int chooseBranch(CbcNode * newNode, int numberPassesLeft, bool & resolved);
01678
01685 CoinWarmStartBasis *getEmptyBasis(int ns = 0, int na = 0) const ;
01686
01698 int takeOffCuts(OsiCuts &cuts,
01699 bool allowResolve,OsiCuts * saveCuts,
01700 int numberNewCuts=0, const OsiRowCut ** newCuts=NULL) ;
01701
01715 int addCuts(CbcNode * node, CoinWarmStartBasis *&lastws,bool canFix);
01716
01733 bool addCuts1(CbcNode * node, CoinWarmStartBasis *&lastws);
01737 void previousBounds (CbcNode * node, CbcNodeInfo * where,int iColumn,
01738 double & lower, double & upper,int force);
01743 void setObjectiveValue(CbcNode * thisNode, const CbcNode * parentNode) const;
01744
01748 void convertToDynamic();
01750 void synchronizeNumberBeforeTrust(int type=0);
01752 void zapIntegerInformation(bool leaveObjects=true);
01754 int cliquePseudoCosts(int doStatistics);
01756 void pseudoShadow(double * down, double * up);
01763 void fillPseudoCosts(double * downCosts, double * upCosts,
01764 int * numberDown=NULL, int * numberUp=NULL,
01765 int * numberDownInfeasible=NULL,
01766 int * numberUpInfeasible=NULL) const;
01772 void doHeuristicsAtRoot(int deleteHeuristicsAfterwards=0);
01774 void adjustHeuristics();
01776 inline const double * hotstartSolution() const
01777 { return hotstartSolution_;}
01779 inline const int * hotstartPriorities() const
01780 { return hotstartPriorities_;}
01781
01783 inline CbcCountRowCut ** addedCuts() const
01784 { return addedCuts_;}
01786 inline int currentNumberCuts() const
01787 { return currentNumberCuts_;}
01789 inline OsiCuts * globalCuts()
01790 { return &globalCuts_;}
01792 void setNextRowCut(const OsiRowCut & cut);
01794 inline CbcNode * currentNode() const
01795 { return currentNode_;}
01797 inline CglTreeProbingInfo * probingInfo() const
01798 { return probingInfo_;}
01800 inline CoinThreadRandom * randomNumberGenerator()
01801 { return &randomNumberGenerator_;}
01803 inline void setNumberStrongIterations(int number)
01804 { numberStrongIterations_ = number;}
01806 inline int numberStrongIterations() const
01807 { return numberStrongIterations_;}
01809 inline int maximumNumberIterations() const
01810 { return maximumNumberIterations_;}
01812 inline void setMaximumNumberIterations(int value)
01813 { maximumNumberIterations_ = value;}
01814 # ifdef COIN_HAS_CLP
01816 inline void setFastNodeDepth(int value)
01817 { fastNodeDepth_ = value;}
01819 inline int fastNodeDepth() const
01820 { return fastNodeDepth_;}
01821 inline void incrementExtra(int nodes, int iterations)
01822 { numberExtraNodes_ += nodes; numberExtraIterations_ += iterations;}
01823 #endif
01825 inline int numberExtraIterations() const
01826 { return numberExtraIterations_;}
01828 void incrementStrongInfo(int numberTimes, int numberIterations,
01829 int numberFixed, bool ifInfeasible);
01831 inline const int * strongInfo() const
01832 { return strongInfo_;}
01833
01835 inline int * mutableStrongInfo()
01836 { return strongInfo_;}
01837
01839 inline bool allDynamic () const { return ((ownership_&0x40000000)!=0) ; }
01841 void generateCpp( FILE * fp,int options);
01843 OsiBranchingInformation usefulInformation() const;
01850 inline void setBestSolutionBasis(const CoinWarmStartBasis & bestSolutionBasis)
01851 { bestSolutionBasis_ = bestSolutionBasis;}
01853 void redoWalkBack();
01855
01856
01857
01858 private:
01860
01861
01863 OsiSolverInterface * solver_;
01864
01870 unsigned int ownership_ ;
01871
01873 OsiSolverInterface * continuousSolver_;
01874
01876 OsiSolverInterface * referenceSolver_;
01877
01879 CoinMessageHandler * handler_;
01880
01886 bool defaultHandler_;
01887
01889 CoinMessages messages_;
01890
01892 int intParam_[CbcLastIntParam];
01893
01895 double dblParam_[CbcLastDblParam];
01896
01905 mutable CoinWarmStart *emptyWarmStart_ ;
01906
01908 double bestObjective_;
01910 double bestPossibleObjective_;
01912 double sumChangeObjective1_;
01914 double sumChangeObjective2_;
01915
01917 double * bestSolution_;
01918
01923 double * currentSolution_;
01927 mutable const double * testSolution_;
01934 CoinWarmStartBasis bestSolutionBasis_ ;
01936 OsiCuts globalCuts_;
01937
01939 double minimumDrop_;
01941 int numberSolutions_;
01948 int stateOfSearch_;
01950 int whenCuts_;
01952 double * hotstartSolution_;
01954 int * hotstartPriorities_;
01956 int numberHeuristicSolutions_;
01958 int numberNodes_;
01962 int numberNodes2_;
01964 int numberIterations_;
01966 int numberSolves_;
01968 int status_;
01979 int secondaryStatus_;
01981 int numberIntegers_;
01983 int numberRowsAtContinuous_;
01985 int maximumNumberCuts_;
01994 int phase_;
01995
01997 int currentNumberCuts_;
01998
02003 int maximumDepth_;
02009 CbcNodeInfo ** walkback_;
02010 #define NODE_LAST
02011 #ifdef NODE_LAST
02012 CbcNodeInfo ** lastNodeInfo_;
02013 const OsiRowCut ** lastCut_;
02014 int lastDepth_;
02015 int lastNumberCuts2_;
02016 int maximumCuts_;
02017 int * lastNumberCuts_;
02018 #endif
02019
02027 CbcCountRowCut ** addedCuts_;
02028
02032 OsiRowCut * nextRowCut_;
02033
02035 CbcNode * currentNode_;
02036
02038 int * integerVariable_;
02040 char * integerInfo_;
02042 double * continuousSolution_;
02044 int * usedInSolution_;
02051 int specialOptions_;
02053 CbcCompareBase * nodeCompare_;
02055 CbcFeasibilityBase * problemFeasibility_;
02057 CbcTree * tree_;
02059 CbcModel * subTreeModel_;
02061 int numberStoppedSubTrees_;
02063 CbcBranchDecision * branchingMethod_;
02065 CbcCutModifier * cutModifier_;
02067 CbcStrategy * strategy_;
02069 CbcModel * parentModel_;
02075
02076 const double * cbcColLower_;
02078 const double * cbcColUpper_;
02080 const double * cbcRowLower_;
02082 const double * cbcRowUpper_;
02084 const double * cbcColSolution_;
02086 const double * cbcRowPrice_;
02088 const double * cbcReducedCost_;
02090 const double * cbcRowActivity_;
02092 void * appData_;
02094 void * mutex_;
02096 int presolve_;
02100 int numberStrong_;
02106 int numberBeforeTrust_;
02110 int numberPenalties_;
02112 int stopNumberIterations_;
02115 double penaltyScaleFactor_;
02117 int numberAnalyzeIterations_;
02119 double * analyzeResults_;
02121 int numberInfeasibleNodes_;
02128 int problemType_;
02130 int printFrequency_;
02132 int numberCutGenerators_;
02133
02134 CbcCutGenerator ** generator_;
02135
02136 CbcCutGenerator ** virginGenerator_;
02138 int numberHeuristics_;
02140 CbcHeuristic ** heuristic_;
02142 CbcHeuristic * lastHeuristic_;
02143 # ifdef COIN_HAS_CLP
02145 int fastNodeDepth_;
02146 #endif
02147
02148 # ifdef CBC_ONLY_CLP
02149 ClpEventHandler *eventHandler_ ;
02150 # else
02151 CbcEventHandler *eventHandler_ ;
02152 # endif
02153
02155 int numberObjects_;
02156
02167 OsiObject ** object_;
02169 bool ownObjects_;
02170
02172 int * originalColumns_;
02174 int howOftenGlobalScan_;
02177 int numberGlobalViolations_;
02179 int numberExtraIterations_;
02181 int numberExtraNodes_;
02185 double continuousObjective_;
02188 double originalContinuousObjective_;
02190 int continuousInfeasibilities_;
02192 int maximumCutPassesAtRoot_;
02194 int maximumCutPasses_;
02196 int preferredWay_;
02198 int currentPassNumber_;
02200 int maximumWhich_;
02202 int maximumRows_;
02204 int currentDepth_;
02206 mutable CoinThreadRandom randomNumberGenerator_;
02208 CoinWarmStartBasis workingBasis_;
02210 int * whichGenerator_;
02212 int maximumStatistics_;
02214 CbcStatistics ** statistics_;
02216 int maximumDepthActual_;
02218 double numberDJFixed_;
02220 CglTreeProbingInfo * probingInfo_;
02222 int numberFixedAtRoot_;
02224 int numberFixedNow_;
02226 bool stoppedOnGap_;
02228 bool eventHappened_;
02230 int numberLongStrong_;
02232 int numberOldActiveCuts_;
02234 int numberNewCuts_;
02236 int sizeMiniTree_;
02238 int searchStrategy_;
02240 int numberStrongIterations_;
02243 int strongInfo_[7];
02250 OsiBabSolver * solverCharacteristics_;
02252 bool resolveAfterTakeOffCuts_;
02254 int maximumNumberIterations_;
02255 #if NEW_UPDATE_OBJECT>1
02257 int numberUpdateItems_;
02259 int maximumNumberUpdateItems_;
02261 CbcObjectUpdateData * updateItems_;
02262 #endif
02263
02270 int numberThreads_;
02278 int threadMode_;
02280 };
02282 void getIntegerInformation(const OsiObject * object, double & originalLower,
02283 double & originalUpper) ;
02284
02285
02286 class OsiClpSolverInterface;
02287 int CbcMain (int argc, const char *argv[],OsiClpSolverInterface & solver,CbcModel ** babSolver);
02288 int CbcMain (int argc, const char *argv[],CbcModel & babSolver);
02289
02290 int callCbc(const char * input2, OsiClpSolverInterface& solver1);
02291 int callCbc(const char * input2);
02292 int callCbc(const std::string input2, OsiClpSolverInterface& solver1);
02293 int callCbc(const std::string input2) ;
02294
02295 void CbcMain0 (CbcModel & babSolver);
02296 int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver);
02297
02298 int callCbc(const char * input2, CbcModel & babSolver);
02299 int callCbc(const std::string input2, CbcModel & babSolver);
02300
02301 int callCbc1(const char * input2, CbcModel & babSolver);
02302 int callCbc1(const std::string input2, CbcModel & babSolver);
02303
02304 int callCbc1(const char * input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02305 int callCbc1(const std::string input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02306 int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02307
02308 void setCutAndHeuristicOptions(CbcModel & model);
02309 #endif