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);
00332 void makeGlobalCuts(int numberRows,const int * which);
00334 void makeGlobalCut(const OsiRowCut * cut);
00336 void makeGlobalCut(const OsiRowCut & cut);
00338
00341
00353 CbcModel * findCliques(bool makeEquality, int atLeastThisMany,
00354 int lessThanThis, int defaultValue=1000);
00355
00364 CbcModel * integerPresolve(bool weak=false);
00365
00370 bool integerPresolveThisModel(OsiSolverInterface * originalSolver,bool weak=false);
00371
00372
00374 void originalModel(CbcModel * presolvedModel,bool weak);
00375
00396 bool tightenVubs(int type,bool allowMultipleBinary=false,
00397 double useCutoff=1.0e50);
00398
00404 bool tightenVubs(int numberVubs, const int * which,
00405 double useCutoff=1.0e50);
00409 void analyzeObjective();
00410
00411
00413
00419
00421 inline int numberObjects() const { return numberObjects_;}
00423 inline void setNumberObjects(int number)
00424 { numberObjects_=number;}
00425
00427 inline OsiObject ** objects() const { return object_;}
00428
00430 const inline OsiObject * object(int which) const { return object_[which];}
00432 inline OsiObject * modifiableObject(int which) const { return object_[which];}
00433
00435 void deleteObjects(bool findIntegers=true);
00436
00441 void addObjects(int numberObjects, OsiObject ** objects);
00442
00447 void addObjects(int numberObjects, CbcObject ** objects);
00448
00450 void synchronizeModel() ;
00451
00461 void findIntegers(bool startAgain,int type=0);
00462
00464
00465
00466
00476
00477 inline bool setIntParam(CbcIntParam key, int value) {
00478 intParam_[key] = value;
00479 return true;
00480 }
00482 inline bool setDblParam(CbcDblParam key, double value) {
00483 dblParam_[key] = value;
00484 return true;
00485 }
00487 inline int getIntParam(CbcIntParam key) const {
00488 return intParam_[key];
00489 }
00491 inline double getDblParam(CbcDblParam key) const {
00492 return dblParam_[key];
00493 }
00499 void setCutoff(double value) ;
00500
00502 inline double getCutoff() const
00503 {
00504
00505
00506 return dblParam_[CbcCurrentCutoff];
00507 }
00508
00510 inline bool setMaximumNodes( int value)
00511 { return setIntParam(CbcMaxNumNode,value); }
00512
00514 inline int getMaximumNodes() const
00515 { return getIntParam(CbcMaxNumNode); }
00516
00521 inline bool setMaximumSolutions( int value) {
00522 return setIntParam(CbcMaxNumSol,value);
00523 }
00528 inline int getMaximumSolutions() const {
00529 return getIntParam(CbcMaxNumSol);
00530 }
00532 inline bool setPrintingMode( int value)
00533 { return setIntParam(CbcPrinting,value); }
00534
00536 inline int getPrintingMode() const
00537 { return getIntParam(CbcPrinting); }
00538
00543 inline bool setMaximumSeconds( double value) {
00544 return setDblParam(CbcMaximumSeconds,value);
00545 }
00550 inline double getMaximumSeconds() const {
00551 return getDblParam(CbcMaximumSeconds);
00552 }
00554 double getCurrentSeconds() const ;
00555
00559 inline bool setIntegerTolerance( double value) {
00560 return setDblParam(CbcIntegerTolerance,value);
00561 }
00565 inline double getIntegerTolerance() const {
00566 return getDblParam(CbcIntegerTolerance);
00567 }
00568
00573 inline bool setInfeasibilityWeight( double value) {
00574 return setDblParam(CbcInfeasibilityWeight,value);
00575 }
00580 inline double getInfeasibilityWeight() const {
00581 return getDblParam(CbcInfeasibilityWeight);
00582 }
00583
00587 inline bool setAllowableGap( double value) {
00588 return setDblParam(CbcAllowableGap,value);
00589 }
00593 inline double getAllowableGap() const {
00594 return getDblParam(CbcAllowableGap);
00595 }
00596
00600 inline bool setAllowableFractionGap( double value) {
00601 return setDblParam(CbcAllowableFractionGap,value);
00602 }
00606 inline double getAllowableFractionGap() const {
00607 return getDblParam(CbcAllowableFractionGap);
00608 }
00612 inline bool setAllowablePercentageGap( double value) {
00613 return setDblParam(CbcAllowableFractionGap,value*0.01);
00614 }
00618 inline double getAllowablePercentageGap() const {
00619 return 100.0*getDblParam(CbcAllowableFractionGap);
00620 }
00625 inline bool setCutoffIncrement( double value) {
00626 return setDblParam(CbcCutoffIncrement,value);
00627 }
00632 inline double getCutoffIncrement() const {
00633 return getDblParam(CbcCutoffIncrement);
00634 }
00635
00640 void setHotstartSolution(const double * solution, const int * priorities=NULL) ;
00641
00643 inline void setMinimumDrop(double value)
00644 {minimumDrop_=value;}
00646 inline double getMinimumDrop() const
00647 { return minimumDrop_;}
00648
00651 inline void setMaximumCutPassesAtRoot(int value)
00652 {maximumCutPassesAtRoot_=value;}
00654 inline int getMaximumCutPassesAtRoot() const
00655 { return maximumCutPassesAtRoot_;}
00656
00659 inline void setMaximumCutPasses(int value)
00660 {maximumCutPasses_=value;}
00662 inline int getMaximumCutPasses() const
00663 { return maximumCutPasses_;}
00666 inline int getCurrentPassNumber() const
00667 { return currentPassNumber_;}
00668
00674 void setNumberStrong(int number);
00678 inline int numberStrong() const
00679 { return numberStrong_;}
00682 inline void setPreferredWay(int value)
00683 {preferredWay_=value;}
00685 inline int getPreferredWay() const
00686 { return preferredWay_;}
00688 inline int whenCuts() const
00689 { return whenCuts_;}
00691 inline void setWhenCuts(int value)
00692 { whenCuts_ = value;}
00698 bool doCutsNow(int allowForTopOfTree) const;
00702 inline void setSizeMiniTree(int value)
00703 { sizeMiniTree_=value;}
00704 inline int sizeMiniTree() const
00705 { return sizeMiniTree_;}
00706
00712 void setNumberBeforeTrust(int number);
00715 inline int numberBeforeTrust() const
00716 { return numberBeforeTrust_;}
00722 void setNumberPenalties(int number);
00725 inline int numberPenalties() const
00726 { return numberPenalties_;}
00728 inline void setNumberAnalyzeIterations(int number)
00729 { numberAnalyzeIterations_=number;}
00730 inline int numberAnalyzeIterations() const
00731 { return numberAnalyzeIterations_;}
00734 inline double penaltyScaleFactor() const
00735 { return penaltyScaleFactor_;}
00738 void setPenaltyScaleFactor(double value);
00746 void inline setProblemType(int number)
00747 { problemType_=number;}
00748 inline int problemType() const
00749 { return problemType_;}
00751 inline int currentDepth() const
00752 { return currentDepth_;}
00753
00755 void setHowOftenGlobalScan(int number);
00757 inline int howOftenGlobalScan() const
00758 { return howOftenGlobalScan_;}
00760 inline int * originalColumns() const
00761 { return originalColumns_;}
00763 void setOriginalColumns(const int * originalColumns) ;
00764
00772 inline void setPrintFrequency(int number)
00773 { printFrequency_=number;}
00775 inline int printFrequency() const
00776 { return printFrequency_;}
00778
00779
00781
00782
00783 bool isAbandoned() const;
00785 bool isProvenOptimal() const;
00787 bool isProvenInfeasible() const;
00789 bool isContinuousUnbounded() const;
00791 bool isProvenDualInfeasible() const;
00793 bool isNodeLimitReached() const;
00795 bool isSecondsLimitReached() const;
00797 bool isSolutionLimitReached() const;
00799 inline int getIterationCount() const
00800 { return numberIterations_;}
00802 inline void incrementIterationCount(int value)
00803 { numberIterations_ += value;}
00805 inline int getNodeCount() const
00806 { return numberNodes_;}
00808 inline void incrementNodeCount(int value)
00809 { numberNodes_ += value;}
00819 inline int status() const
00820 { return status_;}
00821 inline void setProblemStatus(int value)
00822 { status_=value;}
00834 inline int secondaryStatus() const
00835 { return secondaryStatus_;}
00836 inline void setSecondaryStatus(int value)
00837 { secondaryStatus_=value;}
00839 bool isInitialSolveAbandoned() const ;
00841 bool isInitialSolveProvenOptimal() const ;
00843 bool isInitialSolveProvenPrimalInfeasible() const ;
00845 bool isInitialSolveProvenDualInfeasible() const ;
00846
00848
00849
00862
00863 inline int numberRowsAtContinuous() const
00864 { return numberRowsAtContinuous_;}
00865
00867 inline int getNumCols() const
00868 { return solver_->getNumCols();}
00869
00871 inline int getNumRows() const
00872 { return solver_->getNumRows();}
00873
00875 inline CoinBigIndex getNumElements() const
00876 { return solver_->getNumElements();}
00877
00879 inline int numberIntegers() const
00880 { return numberIntegers_;}
00881
00882 inline const int * integerVariable() const
00883 { return integerVariable_;}
00885 inline char integerType(int i) const
00886 { return integerInfo_[i];}
00888 inline const char * integerType() const
00889 { return integerInfo_;}
00890
00892 inline const double * getColLower() const
00893 { return solver_->getColLower();}
00894
00896 inline const double * getColUpper() const
00897 { return solver_->getColUpper();}
00898
00908 inline const char * getRowSense() const
00909 { return solver_->getRowSense();}
00910
00919 inline const double * getRightHandSide() const
00920 { return solver_->getRightHandSide();}
00921
00930 inline const double * getRowRange() const
00931 { return solver_->getRowRange();}
00932
00934 inline const double * getRowLower() const
00935 { return solver_->getRowLower();}
00936
00938 inline const double * getRowUpper() const
00939 { return solver_->getRowUpper();}
00940
00942 inline const double * getObjCoefficients() const
00943 { return solver_->getObjCoefficients();}
00944
00946 inline double getObjSense() const
00947 {
00948
00949 return dblParam_[CbcOptimizationDirection];}
00950
00952 inline bool isContinuous(int colIndex) const
00953 { return solver_->isContinuous(colIndex);}
00954
00956 inline bool isBinary(int colIndex) const
00957 { return solver_->isBinary(colIndex);}
00958
00963 inline bool isInteger(int colIndex) const
00964 { return solver_->isInteger(colIndex);}
00965
00967 inline bool isIntegerNonBinary(int colIndex) const
00968 { return solver_->isIntegerNonBinary(colIndex);}
00969
00971 inline bool isFreeBinary(int colIndex) const
00972 { return solver_->isFreeBinary(colIndex) ;}
00973
00975 inline const CoinPackedMatrix * getMatrixByRow() const
00976 { return solver_->getMatrixByRow();}
00977
00979 inline const CoinPackedMatrix * getMatrixByCol() const
00980 { return solver_->getMatrixByCol();}
00981
00983 inline double getInfinity() const
00984 { return solver_->getInfinity();}
00986 inline const double * getCbcColLower() const
00987 { return cbcColLower_;}
00989 inline const double * getCbcColUpper() const
00990 { return cbcColUpper_;}
00992 inline const double * getCbcRowLower() const
00993 { return cbcRowLower_;}
00995 inline const double * getCbcRowUpper() const
00996 { return cbcRowUpper_;}
00998 inline const double * getCbcColSolution() const
00999 { return cbcColSolution_;}
01001 inline const double * getCbcRowPrice() const
01002 { return cbcRowPrice_;}
01004 inline const double * getCbcReducedCost() const
01005 { return cbcReducedCost_;}
01007 inline const double * getCbcRowActivity() const
01008 { return cbcRowActivity_;}
01010
01011
01014
01015 inline double * continuousSolution() const
01016 { return continuousSolution_;}
01021 inline int * usedInSolution() const
01022 { return usedInSolution_;}
01024 void incrementUsed(const double * solution);
01026 void setBestSolution(CBC_Message how,
01027 double & objectiveValue, const double *solution,
01028 int fixVariables=0);
01030 void setBestObjectiveValue( double objectiveValue);
01031
01038 double checkSolution(double cutoff, double * solution,
01039 int fixVariables, double originalObjValue);
01046 bool feasibleSolution(int & numberIntegerInfeasibilities,
01047 int & numberObjectInfeasibilities) const;
01048
01054 inline double * currentSolution() const
01055 { return currentSolution_;}
01059 inline const double * testSolution() const
01060 { return testSolution_;}
01061 inline void setTestSolution(const double * solution)
01062 { testSolution_ = solution;}
01064 void reserveCurrentSolution(const double * solution=NULL);
01065
01067 inline const double * getColSolution() const
01068 { return solver_->getColSolution();}
01069
01071 inline const double * getRowPrice() const
01072 { return solver_->getRowPrice();}
01073
01075 inline const double * getReducedCost() const
01076 { return solver_->getReducedCost();}
01077
01079 inline const double * getRowActivity() const
01080 { return solver_->getRowActivity();}
01081
01083 inline double getCurrentObjValue() const
01084 { return dblParam_[CbcCurrentObjectiveValue]; }
01086 inline double getCurrentMinimizationObjValue() const
01087 { return dblParam_[CbcCurrentMinimizationObjectiveValue];}
01088
01090 inline double getMinimizationObjValue() const
01091 { return bestObjective_;}
01093 inline void setMinimizationObjValue(double value)
01094 { bestObjective_=value;}
01095
01097 inline double getObjValue() const
01098 { return bestObjective_ * solver_->getObjSense() ; }
01104 double getBestPossibleObjValue() const;
01106 inline void setObjValue(double value)
01107 { bestObjective_=value * solver_->getObjSense() ;}
01108
01115 inline double * bestSolution() const
01116 { return bestSolution_;}
01123 void setBestSolution(const double * solution,int numberColumns,
01124 double objectiveValue,bool check=false);
01125
01127 inline int getSolutionCount() const
01128 { return numberSolutions_;}
01129
01131 inline void setSolutionCount(int value)
01132 { numberSolutions_=value;}
01141 inline int phase() const
01142 { return phase_;}
01143
01145 inline int getNumberHeuristicSolutions() const { return numberHeuristicSolutions_;}
01147 inline void setNumberHeuristicSolutions(int value) { numberHeuristicSolutions_=value;}
01148
01150 inline void setObjSense(double s) { dblParam_[CbcOptimizationDirection]=s;
01151 solver_->setObjSense(s);}
01152
01154 inline double getContinuousObjective() const
01155 { return originalContinuousObjective_;}
01156 inline void setContinuousObjective(double value)
01157 { originalContinuousObjective_=value;}
01159 inline int getContinuousInfeasibilities() const
01160 { return continuousInfeasibilities_;}
01161 inline void setContinuousInfeasibilities(int value)
01162 { continuousInfeasibilities_=value;}
01164 inline double rootObjectiveAfterCuts() const
01165 { return continuousObjective_;}
01167 inline double sumChangeObjective() const
01168 { return sumChangeObjective1_;}
01171 inline int numberGlobalViolations() const
01172 { return numberGlobalViolations_;}
01173 inline void clearNumberGlobalViolations()
01174 { numberGlobalViolations_=0;}
01176 inline bool resolveAfterTakeOffCuts() const
01177 { return resolveAfterTakeOffCuts_;}
01178 inline void setResolveAfterTakeOffCuts(bool yesNo)
01179 { resolveAfterTakeOffCuts_=yesNo;}
01181 inline int maximumRows() const
01182 { return maximumRows_;}
01184 inline CoinWarmStartBasis & workingBasis()
01185 { return workingBasis_;}
01187 inline int getNumberThreads() const
01188 { return numberThreads_;}
01190 inline void setNumberThreads(int value)
01191 { numberThreads_=value;}
01193 inline int getThreadMode() const
01194 { return threadMode_;}
01201 inline void setThreadMode(int value)
01202 { threadMode_=value;}
01204 inline int getStopNumberIterations() const
01205 { return stopNumberIterations_;}
01207 inline void setStopNumberIterations(int value)
01208 { stopNumberIterations_=value;}
01210
01213
01214 inline CbcCompareBase * nodeComparison() const
01215 { return nodeCompare_;}
01216 void setNodeComparison(CbcCompareBase * compare);
01217 void setNodeComparison(CbcCompareBase & compare);
01219
01222
01223 inline CbcFeasibilityBase * problemFeasibility() const
01224 { return problemFeasibility_;}
01225 void setProblemFeasibility(CbcFeasibilityBase * feasibility);
01226 void setProblemFeasibility(CbcFeasibilityBase & feasibility);
01228
01231
01232 inline CbcTree * tree() const
01233 { return tree_;}
01235 void passInTreeHandler(CbcTree & tree);
01239 void passInSubTreeModel(CbcModel & model);
01244 CbcModel * subTreeModel(OsiSolverInterface * solver=NULL) const;
01246 inline int numberStoppedSubTrees() const
01247 { return numberStoppedSubTrees_;}
01249 inline void incrementSubTreeStopped()
01250 { numberStoppedSubTrees_++;}
01256 inline int typePresolve() const
01257 { return presolve_;}
01258 inline void setTypePresolve(int value)
01259 { presolve_=value;}
01260
01262
01268
01270 inline CbcBranchDecision * branchingMethod() const
01271 { return branchingMethod_;}
01273 inline void setBranchingMethod(CbcBranchDecision * method)
01274 { delete branchingMethod_; branchingMethod_ = method->clone();}
01279 inline void setBranchingMethod(CbcBranchDecision & method)
01280 { delete branchingMethod_; branchingMethod_ = method.clone();}
01282 inline CbcCutModifier * cutModifier() const
01283 { return cutModifier_;}
01285 void setCutModifier(CbcCutModifier * modifier);
01290 void setCutModifier(CbcCutModifier & modifier);
01292
01295
01302 inline int stateOfSearch() const
01303 { return stateOfSearch_;}
01304 inline void setStateOfSearch(int state)
01305 { stateOfSearch_=state;}
01307 inline int searchStrategy() const
01308 { return searchStrategy_;}
01310 inline void setSearchStrategy(int value)
01311 { searchStrategy_ = value; }
01312
01314 inline int numberCutGenerators() const
01315 { return numberCutGenerators_;}
01317 inline CbcCutGenerator ** cutGenerators() const
01318 { return generator_;}
01320 inline CbcCutGenerator * cutGenerator(int i) const
01321 { return generator_[i];}
01323 inline CbcCutGenerator * virginCutGenerator(int i) const
01324 { return virginGenerator_[i];}
01333 void addCutGenerator(CglCutGenerator * generator,
01334 int howOften=1, const char * name=NULL,
01335 bool normal=true, bool atSolution=false,
01336 bool infeasible=false,int howOftenInSub=-100,
01337 int whatDepth=-1, int whatDepthInSub=-1);
01339
01344
01346 inline CbcStrategy * strategy() const
01347 { return strategy_;}
01349 void setStrategy(CbcStrategy & strategy);
01351 inline CbcModel * parentModel() const
01352 { return parentModel_;}
01354 inline void setParentModel(CbcModel & parentModel)
01355 { parentModel_ = &parentModel;}
01357
01358
01365 void addHeuristic(CbcHeuristic * generator, const char *name = NULL,
01366 int before=-1);
01368 inline CbcHeuristic * heuristic(int i) const
01369 { return heuristic_[i];}
01371 inline int numberHeuristics() const
01372 { return numberHeuristics_;}
01374 inline CbcHeuristic * lastHeuristic() const
01375 { return lastHeuristic_;}
01377 inline void setLastHeuristic(CbcHeuristic * last)
01378 { lastHeuristic_=last;}
01379
01398 void passInPriorities(const int * priorities, bool ifNotSimpleIntegers);
01399
01401 inline int priority(int sequence) const
01402 { return object_[sequence]->priority();}
01403
01408 void passInEventHandler(const CbcEventHandler *eventHandler) ;
01409
01411 inline CbcEventHandler* getEventHandler() const
01412 { return (eventHandler_) ; }
01413
01415
01425 void setApplicationData (void * appData);
01426
01428 void * getApplicationData() const;
01441 void passInSolverCharacteristics(OsiBabSolver * solverCharacteristics);
01443 inline const OsiBabSolver * solverCharacteristics() const
01444 { return solverCharacteristics_;}
01446
01447
01448
01451
01452 void passInMessageHandler(CoinMessageHandler * handler);
01454 void newLanguage(CoinMessages::Language language);
01455 inline void setLanguage(CoinMessages::Language language)
01456 {newLanguage(language);}
01458 inline CoinMessageHandler * messageHandler() const
01459 {return handler_;}
01461 inline CoinMessages & messages()
01462 {return messages_;}
01464 inline CoinMessages * messagesPointer()
01465 {return &messages_;}
01467 void setLogLevel(int value);
01469 inline int logLevel() const
01470 { return handler_->logLevel();}
01472
01474
01475
01490
01491 inline void setSpecialOptions(int value)
01492 { specialOptions_=value;}
01494 inline int specialOptions() const
01495 { return specialOptions_;}
01497 inline bool normalSolver() const
01498 { return (specialOptions_&16)==0;}
01500 inline bool ownObjects() const
01501 { return ownObjects_;}
01503 inline void * mutex()
01504 { return mutex_;}
01506 int splitModel(int numberModels, CbcModel ** model,
01507 int numberNodes);
01509 void startSplitModel(int numberIterations);
01511 void mergeModels(int numberModel, CbcModel ** model,
01512 int numberNodes);
01514
01515
01517
01518
01519 CbcModel();
01520
01522 CbcModel(const OsiSolverInterface &);
01523
01532 void assignSolver(OsiSolverInterface *&solver,bool deleteSolver=true);
01533
01545 inline void setModelOwnsSolver (bool ourSolver)
01546 { ownership_ = ourSolver ? (ownership_ |0x80000000) : (ownership_ & (~0x80000000)) ; }
01547
01553 inline bool modelOwnsSolver () { return ((ownership_&0x80000000)!=0) ; }
01554
01558 CbcModel(const CbcModel & rhs, bool cloneHandler=false);
01559
01561 CbcModel & operator=(const CbcModel& rhs);
01562
01564 ~CbcModel ();
01565
01567 inline OsiSolverInterface * solver() const
01568 { return solver_;}
01569
01571 inline OsiSolverInterface * swapSolver(OsiSolverInterface * solver)
01572 { OsiSolverInterface * returnSolver = solver_; solver_ = solver; return returnSolver;}
01573
01575 inline OsiSolverInterface * continuousSolver() const
01576 { return continuousSolver_;}
01577
01579 inline void createContinuousSolver()
01580 { continuousSolver_ = solver_->clone();}
01582 inline void clearContinuousSolver()
01583 { delete continuousSolver_; continuousSolver_ = NULL;}
01584
01586 inline OsiSolverInterface * referenceSolver() const
01587 { return referenceSolver_;}
01588
01590 void saveReferenceSolver();
01591
01597 void resetToReferenceSolver();
01598
01600 void gutsOfDestructor();
01603 void gutsOfDestructor2();
01606 void resetModel();
01612 void gutsOfCopy(const CbcModel & rhs,int mode=0);
01614 void moveInfo(const CbcModel & rhs);
01616
01618
01619
01620 int getNodeCount2() const
01621 { return numberNodes2_;}
01623 void setPointers(const OsiSolverInterface * solver);
01629 int reducedCostFix() ;
01631 int resolve(OsiSolverInterface * solver);
01632
01636 int chooseBranch(CbcNode * newNode, int numberPassesLeft,
01637 CbcNode * oldNode, OsiCuts & cuts,
01638 bool & resolved, CoinWarmStartBasis *lastws,
01639 const double * lowerBefore,const double * upperBefore,
01640 OsiSolverBranch * & branches);
01641 int chooseBranch(CbcNode * newNode, int numberPassesLeft, bool & resolved);
01642
01649 CoinWarmStartBasis *getEmptyBasis(int ns = 0, int na = 0) const ;
01650
01662 int takeOffCuts(OsiCuts &cuts,
01663 bool allowResolve,OsiCuts * saveCuts,
01664 int numberNewCuts=0, const OsiRowCut ** newCuts=NULL) ;
01665
01679 int addCuts(CbcNode * node, CoinWarmStartBasis *&lastws,bool canFix);
01680
01697 bool addCuts1(CbcNode * node, CoinWarmStartBasis *&lastws);
01701 void previousBounds (CbcNode * node, CbcNodeInfo * where,int iColumn,
01702 double & lower, double & upper,int force);
01707 void setObjectiveValue(CbcNode * thisNode, const CbcNode * parentNode) const;
01708
01712 void convertToDynamic();
01714 void synchronizeNumberBeforeTrust(int type=0);
01716 void zapIntegerInformation(bool leaveObjects=true);
01718 int cliquePseudoCosts(int doStatistics);
01720 void pseudoShadow(double * down, double * up);
01727 void fillPseudoCosts(double * downCosts, double * upCosts,
01728 int * numberDown=NULL, int * numberUp=NULL,
01729 int * numberDownInfeasible=NULL,
01730 int * numberUpInfeasible=NULL) const;
01736 void doHeuristicsAtRoot(int deleteHeuristicsAfterwards=0);
01738 inline const double * hotstartSolution() const
01739 { return hotstartSolution_;}
01741 inline const int * hotstartPriorities() const
01742 { return hotstartPriorities_;}
01743
01745 inline CbcCountRowCut ** addedCuts() const
01746 { return addedCuts_;}
01748 inline int currentNumberCuts() const
01749 { return currentNumberCuts_;}
01751 inline OsiCuts * globalCuts()
01752 { return &globalCuts_;}
01754 void setNextRowCut(const OsiRowCut & cut);
01756 inline CbcNode * currentNode() const
01757 { return currentNode_;}
01759 inline CglTreeProbingInfo * probingInfo() const
01760 { return probingInfo_;}
01762 inline CoinThreadRandom * randomNumberGenerator()
01763 { return &randomNumberGenerator_;}
01765 inline void setNumberStrongIterations(int number)
01766 { numberStrongIterations_ = number;}
01768 inline int numberStrongIterations() const
01769 { return numberStrongIterations_;}
01771 inline int maximumNumberIterations() const
01772 { return maximumNumberIterations_;}
01774 inline void setMaximumNumberIterations(int value)
01775 { maximumNumberIterations_ = value;}
01776 # ifdef COIN_HAS_CLP
01778 inline void setFastNodeDepth(int value)
01779 { fastNodeDepth_ = value;}
01781 inline int fastNodeDepth() const
01782 { return fastNodeDepth_;}
01783 inline void incrementExtra(int nodes, int iterations)
01784 { numberExtraNodes_ += nodes; numberExtraIterations_ += iterations;}
01785 #endif
01787 void incrementStrongInfo(int numberTimes, int numberIterations,
01788 int numberFixed, bool ifInfeasible);
01790 inline const int * strongInfo() const
01791 { return strongInfo_;}
01792
01794 inline int * mutableStrongInfo()
01795 { return strongInfo_;}
01796
01798 inline bool allDynamic () const { return ((ownership_&0x40000000)!=0) ; }
01800 void generateCpp( FILE * fp,int options);
01802 OsiBranchingInformation usefulInformation() const;
01809 inline void setBestSolutionBasis(const CoinWarmStartBasis & bestSolutionBasis)
01810 { bestSolutionBasis_ = bestSolutionBasis;}
01812 void redoWalkBack();
01814
01815
01816
01817 private:
01819
01820
01822 OsiSolverInterface * solver_;
01823
01829 unsigned int ownership_ ;
01830
01832 OsiSolverInterface * continuousSolver_;
01833
01835 OsiSolverInterface * referenceSolver_;
01836
01838 CoinMessageHandler * handler_;
01839
01845 bool defaultHandler_;
01846
01848 CoinMessages messages_;
01849
01851 int intParam_[CbcLastIntParam];
01852
01854 double dblParam_[CbcLastDblParam];
01855
01864 mutable CoinWarmStart *emptyWarmStart_ ;
01865
01867 double bestObjective_;
01869 double bestPossibleObjective_;
01871 double sumChangeObjective1_;
01873 double sumChangeObjective2_;
01874
01876 double * bestSolution_;
01877
01882 double * currentSolution_;
01886 mutable const double * testSolution_;
01893 CoinWarmStartBasis bestSolutionBasis_ ;
01895 OsiCuts globalCuts_;
01896
01898 double minimumDrop_;
01900 int numberSolutions_;
01907 int stateOfSearch_;
01909 int whenCuts_;
01911 double * hotstartSolution_;
01913 int * hotstartPriorities_;
01915 int numberHeuristicSolutions_;
01917 int numberNodes_;
01921 int numberNodes2_;
01923 int numberIterations_;
01925 int status_;
01936 int secondaryStatus_;
01938 int numberIntegers_;
01940 int numberRowsAtContinuous_;
01942 int maximumNumberCuts_;
01951 int phase_;
01952
01954 int currentNumberCuts_;
01955
01960 int maximumDepth_;
01966 CbcNodeInfo ** walkback_;
01967
01968 #ifdef NODE_LAST
01969 CbcNodeInfo ** lastNodeInfo_;
01970 const OsiRowCut ** lastCut_;
01971 int lastDepth_;
01972 int lastNumberCuts2_;
01973 int maximumCuts_;
01974 int * lastNumberCuts_;
01975 #endif
01976
01984 CbcCountRowCut ** addedCuts_;
01985
01989 OsiRowCut * nextRowCut_;
01990
01992 CbcNode * currentNode_;
01993
01995 int * integerVariable_;
01997 char * integerInfo_;
01999 double * continuousSolution_;
02001 int * usedInSolution_;
02008 int specialOptions_;
02010 CbcCompareBase * nodeCompare_;
02012 CbcFeasibilityBase * problemFeasibility_;
02014 CbcTree * tree_;
02016 CbcModel * subTreeModel_;
02018 int numberStoppedSubTrees_;
02020 CbcBranchDecision * branchingMethod_;
02022 CbcCutModifier * cutModifier_;
02024 CbcStrategy * strategy_;
02026 CbcModel * parentModel_;
02032
02033 const double * cbcColLower_;
02035 const double * cbcColUpper_;
02037 const double * cbcRowLower_;
02039 const double * cbcRowUpper_;
02041 const double * cbcColSolution_;
02043 const double * cbcRowPrice_;
02045 const double * cbcReducedCost_;
02047 const double * cbcRowActivity_;
02049 void * appData_;
02051 void * mutex_;
02053 int presolve_;
02057 int numberStrong_;
02063 int numberBeforeTrust_;
02067 int numberPenalties_;
02069 int stopNumberIterations_;
02072 double penaltyScaleFactor_;
02074 int numberAnalyzeIterations_;
02076 double * analyzeResults_;
02078 int numberInfeasibleNodes_;
02085 int problemType_;
02087 int printFrequency_;
02089 int numberCutGenerators_;
02090
02091 CbcCutGenerator ** generator_;
02092
02093 CbcCutGenerator ** virginGenerator_;
02095 int numberHeuristics_;
02097 CbcHeuristic ** heuristic_;
02099 CbcHeuristic * lastHeuristic_;
02100 # ifdef COIN_HAS_CLP
02102 int fastNodeDepth_;
02103 #endif
02104
02105 # ifdef CBC_ONLY_CLP
02106 ClpEventHandler *eventHandler_ ;
02107 # else
02108 CbcEventHandler *eventHandler_ ;
02109 # endif
02110
02112 int numberObjects_;
02113
02124 OsiObject ** object_;
02126 bool ownObjects_;
02127
02129 int * originalColumns_;
02131 int howOftenGlobalScan_;
02134 int numberGlobalViolations_;
02136 int numberExtraIterations_;
02138 int numberExtraNodes_;
02142 double continuousObjective_;
02145 double originalContinuousObjective_;
02147 int continuousInfeasibilities_;
02149 int maximumCutPassesAtRoot_;
02151 int maximumCutPasses_;
02153 int preferredWay_;
02155 int currentPassNumber_;
02157 int maximumWhich_;
02159 int maximumRows_;
02161 int currentDepth_;
02163 mutable CoinThreadRandom randomNumberGenerator_;
02165 CoinWarmStartBasis workingBasis_;
02167 int * whichGenerator_;
02169 int maximumStatistics_;
02171 CbcStatistics ** statistics_;
02173 int maximumDepthActual_;
02175 double numberDJFixed_;
02177 CglTreeProbingInfo * probingInfo_;
02179 int numberFixedAtRoot_;
02181 int numberFixedNow_;
02183 bool stoppedOnGap_;
02185 bool eventHappened_;
02187 int numberLongStrong_;
02189 int numberOldActiveCuts_;
02191 int numberNewCuts_;
02193 int sizeMiniTree_;
02195 int searchStrategy_;
02197 int numberStrongIterations_;
02200 int strongInfo_[7];
02207 OsiBabSolver * solverCharacteristics_;
02209 bool resolveAfterTakeOffCuts_;
02211 int maximumNumberIterations_;
02212 #if NEW_UPDATE_OBJECT>1
02214 int numberUpdateItems_;
02216 int maximumNumberUpdateItems_;
02218 CbcObjectUpdateData * updateItems_;
02219 #endif
02220
02227 int numberThreads_;
02234 int threadMode_;
02236 };
02238 void getIntegerInformation(const OsiObject * object, double & originalLower,
02239 double & originalUpper) ;
02240
02241
02242 class OsiClpSolverInterface;
02243 int CbcMain (int argc, const char *argv[],OsiClpSolverInterface & solver,CbcModel ** babSolver);
02244 int CbcMain (int argc, const char *argv[],CbcModel & babSolver);
02245
02246 int callCbc(const char * input2, OsiClpSolverInterface& solver1);
02247 int callCbc(const char * input2);
02248 int callCbc(const std::string input2, OsiClpSolverInterface& solver1);
02249 int callCbc(const std::string input2) ;
02250
02251 void CbcMain0 (CbcModel & babSolver);
02252 int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver);
02253
02254 int callCbc(const char * input2, CbcModel & babSolver);
02255 int callCbc(const std::string input2, CbcModel & babSolver);
02256
02257 int callCbc1(const char * input2, CbcModel & babSolver);
02258 int callCbc1(const std::string input2, CbcModel & babSolver);
02259
02260 int callCbc1(const char * input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02261 int callCbc1(const std::string input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02262 int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02263
02264 void setCutAndHeuristicOptions(CbcModel & model);
02265 #endif