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
00034
00035
00036
00037
00090 class CbcModel {
00091
00092 public:
00093
00094 enum CbcIntParam {
00096 CbcMaxNumNode=0,
00098 CbcMaxNumSol,
00108 CbcFathomDiscipline,
00112 CbcPrinting,
00114 CbcLastIntParam
00115 };
00116
00117 enum CbcDblParam {
00120 CbcIntegerTolerance=0,
00123 CbcInfeasibilityWeight,
00126 CbcCutoffIncrement,
00133 CbcAllowableGap,
00140 CbcAllowableFractionGap,
00143 CbcMaximumSeconds,
00145 CbcCurrentCutoff,
00147 CbcOptimizationDirection,
00149 CbcCurrentObjectiveValue,
00151 CbcCurrentMinimizationObjectiveValue,
00154 CbcStartSeconds,
00156 CbcLastDblParam
00157 };
00158
00159
00160
00161 public:
00163
00164
00168 void initialSolve();
00169
00180 void branchAndBound(int doStatistics=0);
00181
00186 CbcModel * cleanModel(const double * lower, const double * upper);
00203 int subBranchAndBound(CbcModel * model2,
00204 CbcModel * presolvedModel,
00205 int maximumNodes);
00221 int subBranchAndBound(const double * lower, const double * upper,
00222 int maximumNodes);
00223
00230 OsiSolverInterface * strengthenedModel();
00240 CglPreProcess * preProcess( int makeEquality=0, int numberPasses=5,
00241 int tuning=5);
00244 void postProcess(CglPreProcess * process);
00245 private:
00253 bool solveWithCuts(OsiCuts & cuts, int numberTries,CbcNode * node);
00260 CbcNode ** solveOneNode(int whichSolver,CbcNode * node,
00261 int & numberNodesOutput, int & status) ;
00263 void resizeWhichGenerator(int numberNow, int numberAfter);
00264 public:
00265 #ifndef CBC_THREAD
00266 #define NEW_UPDATE_OBJECT 0
00267 #else
00268 #define NEW_UPDATE_OBJECT 2
00269 #endif
00270 #if NEW_UPDATE_OBJECT>1
00272 void addUpdateInformation(const CbcObjectUpdateData & data);
00273 #endif
00274
00280 int doOneNode(CbcModel * baseModel, CbcNode * & node, CbcNode * & newNode);
00281
00283 bool isLocked() const;
00284 #ifdef CBC_THREAD
00285
00289 void lockThread();
00293 void unlockThread();
00294 #else
00295 inline void lockThread() {}
00296 inline void unlockThread() {}
00297 #endif
00298 private:
00305 void moveToModel(CbcModel * baseModel,int mode);
00306 public:
00320 int resolve(CbcNodeInfo * parent, int whereFrom);
00322 void makeGlobalCuts(int numberRows,const int * which);
00324 void makeGlobalCut(const OsiRowCut * cut);
00326 void makeGlobalCut(const OsiRowCut & cut);
00328
00331
00343 CbcModel * findCliques(bool makeEquality, int atLeastThisMany,
00344 int lessThanThis, int defaultValue=1000);
00345
00354 CbcModel * integerPresolve(bool weak=false);
00355
00360 bool integerPresolveThisModel(OsiSolverInterface * originalSolver,bool weak=false);
00361
00362
00364 void originalModel(CbcModel * presolvedModel,bool weak);
00365
00386 bool tightenVubs(int type,bool allowMultipleBinary=false,
00387 double useCutoff=1.0e50);
00388
00394 bool tightenVubs(int numberVubs, const int * which,
00395 double useCutoff=1.0e50);
00399 void analyzeObjective();
00400
00401
00403
00409
00411 inline int numberObjects() const { return numberObjects_;}
00413 inline void setNumberObjects(int number)
00414 { numberObjects_=number;}
00415
00417 inline OsiObject ** objects() const { return object_;}
00418
00420 const inline OsiObject * object(int which) const { return object_[which];}
00422 inline OsiObject * modifiableObject(int which) const { return object_[which];}
00423
00425 void deleteObjects(bool findIntegers=true);
00426
00431 void addObjects(int numberObjects, OsiObject ** objects);
00432
00437 void addObjects(int numberObjects, CbcObject ** objects);
00438
00440 void synchronizeModel() ;
00441
00451 void findIntegers(bool startAgain,int type=0);
00452
00454
00455
00456
00466
00467 inline bool setIntParam(CbcIntParam key, int value) {
00468 intParam_[key] = value;
00469 return true;
00470 }
00472 inline bool setDblParam(CbcDblParam key, double value) {
00473 dblParam_[key] = value;
00474 return true;
00475 }
00477 inline int getIntParam(CbcIntParam key) const {
00478 return intParam_[key];
00479 }
00481 inline double getDblParam(CbcDblParam key) const {
00482 return dblParam_[key];
00483 }
00489 void setCutoff(double value) ;
00490
00492 inline double getCutoff() const
00493 {
00494
00495
00496 return dblParam_[CbcCurrentCutoff];
00497 }
00498
00500 inline bool setMaximumNodes( int value)
00501 { return setIntParam(CbcMaxNumNode,value); }
00502
00504 inline int getMaximumNodes() const
00505 { return getIntParam(CbcMaxNumNode); }
00506
00511 inline bool setMaximumSolutions( int value) {
00512 return setIntParam(CbcMaxNumSol,value);
00513 }
00518 inline int getMaximumSolutions() const {
00519 return getIntParam(CbcMaxNumSol);
00520 }
00522 inline bool setPrintingMode( int value)
00523 { return setIntParam(CbcPrinting,value); }
00524
00526 inline int getPrintingMode() const
00527 { return getIntParam(CbcPrinting); }
00528
00533 inline bool setMaximumSeconds( double value) {
00534 return setDblParam(CbcMaximumSeconds,value);
00535 }
00540 inline double getMaximumSeconds() const {
00541 return getDblParam(CbcMaximumSeconds);
00542 }
00544 double getCurrentSeconds() const ;
00545
00549 inline bool setIntegerTolerance( double value) {
00550 return setDblParam(CbcIntegerTolerance,value);
00551 }
00555 inline double getIntegerTolerance() const {
00556 return getDblParam(CbcIntegerTolerance);
00557 }
00558
00563 inline bool setInfeasibilityWeight( double value) {
00564 return setDblParam(CbcInfeasibilityWeight,value);
00565 }
00570 inline double getInfeasibilityWeight() const {
00571 return getDblParam(CbcInfeasibilityWeight);
00572 }
00573
00577 inline bool setAllowableGap( double value) {
00578 return setDblParam(CbcAllowableGap,value);
00579 }
00583 inline double getAllowableGap() const {
00584 return getDblParam(CbcAllowableGap);
00585 }
00586
00590 inline bool setAllowableFractionGap( double value) {
00591 return setDblParam(CbcAllowableFractionGap,value);
00592 }
00596 inline double getAllowableFractionGap() const {
00597 return getDblParam(CbcAllowableFractionGap);
00598 }
00602 inline bool setAllowablePercentageGap( double value) {
00603 return setDblParam(CbcAllowableFractionGap,value*0.01);
00604 }
00608 inline double getAllowablePercentageGap() const {
00609 return 100.0*getDblParam(CbcAllowableFractionGap);
00610 }
00615 inline bool setCutoffIncrement( double value) {
00616 return setDblParam(CbcCutoffIncrement,value);
00617 }
00622 inline double getCutoffIncrement() const {
00623 return getDblParam(CbcCutoffIncrement);
00624 }
00625
00630 void setHotstartSolution(const double * solution, const int * priorities=NULL) ;
00631
00633 inline void setMinimumDrop(double value)
00634 {minimumDrop_=value;}
00636 inline double getMinimumDrop() const
00637 { return minimumDrop_;}
00638
00641 inline void setMaximumCutPassesAtRoot(int value)
00642 {maximumCutPassesAtRoot_=value;}
00644 inline int getMaximumCutPassesAtRoot() const
00645 { return maximumCutPassesAtRoot_;}
00646
00649 inline void setMaximumCutPasses(int value)
00650 {maximumCutPasses_=value;}
00652 inline int getMaximumCutPasses() const
00653 { return maximumCutPasses_;}
00656 inline int getCurrentPassNumber() const
00657 { return currentPassNumber_;}
00658
00664 void setNumberStrong(int number);
00668 inline int numberStrong() const
00669 { return numberStrong_;}
00672 inline void setPreferredWay(int value)
00673 {preferredWay_=value;}
00675 inline int getPreferredWay() const
00676 { return preferredWay_;}
00680 inline void setSizeMiniTree(int value)
00681 { sizeMiniTree_=value;}
00682 inline int sizeMiniTree() const
00683 { return sizeMiniTree_;}
00684
00690 void setNumberBeforeTrust(int number);
00693 inline int numberBeforeTrust() const
00694 { return numberBeforeTrust_;}
00700 void setNumberPenalties(int number);
00703 inline int numberPenalties() const
00704 { return numberPenalties_;}
00706 inline void setNumberAnalyzeIterations(int number)
00707 { numberAnalyzeIterations_=number;}
00708 inline int numberAnalyzeIterations() const
00709 { return numberAnalyzeIterations_;}
00712 inline double penaltyScaleFactor() const
00713 { return penaltyScaleFactor_;}
00716 void setPenaltyScaleFactor(double value);
00724 void inline setProblemType(int number)
00725 { problemType_=number;}
00726 inline int problemType() const
00727 { return problemType_;}
00728
00730 void setHowOftenGlobalScan(int number);
00732 inline int howOftenGlobalScan() const
00733 { return howOftenGlobalScan_;}
00735 inline int * originalColumns() const
00736 { return originalColumns_;}
00738 void setOriginalColumns(const int * originalColumns) ;
00739
00747 inline void setPrintFrequency(int number)
00748 { printFrequency_=number;}
00750 inline int printFrequency() const
00751 { return printFrequency_;}
00753
00754
00756
00757
00758 bool isAbandoned() const;
00760 bool isProvenOptimal() const;
00762 bool isProvenInfeasible() const;
00764 bool isContinuousUnbounded() const;
00766 bool isProvenDualInfeasible() const;
00768 bool isNodeLimitReached() const;
00770 bool isSecondsLimitReached() const;
00772 bool isSolutionLimitReached() const;
00774 inline int getIterationCount() const
00775 { return numberIterations_;}
00777 inline int getNodeCount() const
00778 { return numberNodes_;}
00788 inline int status() const
00789 { return status_;}
00790 inline void setProblemStatus(int value)
00791 { status_=value;}
00803 inline int secondaryStatus() const
00804 { return secondaryStatus_;}
00805 inline void setSecondaryStatus(int value)
00806 { secondaryStatus_=value;}
00808 bool isInitialSolveAbandoned() const ;
00810 bool isInitialSolveProvenOptimal() const ;
00812 bool isInitialSolveProvenPrimalInfeasible() const ;
00814 bool isInitialSolveProvenDualInfeasible() const ;
00815
00817
00818
00831
00832 inline int numberRowsAtContinuous() const
00833 { return numberRowsAtContinuous_;}
00834
00836 inline int getNumCols() const
00837 { return solver_->getNumCols();}
00838
00840 inline int getNumRows() const
00841 { return solver_->getNumRows();}
00842
00844 inline CoinBigIndex getNumElements() const
00845 { return solver_->getNumElements();}
00846
00848 inline int numberIntegers() const
00849 { return numberIntegers_;}
00850
00851 inline const int * integerVariable() const
00852 { return integerVariable_;}
00854 inline char integerType(int i) const
00855 { return integerInfo_[i];}
00857 inline const char * integerType() const
00858 { return integerInfo_;}
00859
00861 inline const double * getColLower() const
00862 { return solver_->getColLower();}
00863
00865 inline const double * getColUpper() const
00866 { return solver_->getColUpper();}
00867
00877 inline const char * getRowSense() const
00878 { return solver_->getRowSense();}
00879
00888 inline const double * getRightHandSide() const
00889 { return solver_->getRightHandSide();}
00890
00899 inline const double * getRowRange() const
00900 { return solver_->getRowRange();}
00901
00903 inline const double * getRowLower() const
00904 { return solver_->getRowLower();}
00905
00907 inline const double * getRowUpper() const
00908 { return solver_->getRowUpper();}
00909
00911 inline const double * getObjCoefficients() const
00912 { return solver_->getObjCoefficients();}
00913
00915 inline double getObjSense() const
00916 {
00917
00918 return dblParam_[CbcOptimizationDirection];}
00919
00921 inline bool isContinuous(int colIndex) const
00922 { return solver_->isContinuous(colIndex);}
00923
00925 inline bool isBinary(int colIndex) const
00926 { return solver_->isBinary(colIndex);}
00927
00932 inline bool isInteger(int colIndex) const
00933 { return solver_->isInteger(colIndex);}
00934
00936 inline bool isIntegerNonBinary(int colIndex) const
00937 { return solver_->isIntegerNonBinary(colIndex);}
00938
00940 inline bool isFreeBinary(int colIndex) const
00941 { return solver_->isFreeBinary(colIndex) ;}
00942
00944 inline const CoinPackedMatrix * getMatrixByRow() const
00945 { return solver_->getMatrixByRow();}
00946
00948 inline const CoinPackedMatrix * getMatrixByCol() const
00949 { return solver_->getMatrixByCol();}
00950
00952 inline double getInfinity() const
00953 { return solver_->getInfinity();}
00955 inline const double * getCbcColLower() const
00956 { return cbcColLower_;}
00958 inline const double * getCbcColUpper() const
00959 { return cbcColUpper_;}
00961 inline const double * getCbcRowLower() const
00962 { return cbcRowLower_;}
00964 inline const double * getCbcRowUpper() const
00965 { return cbcRowUpper_;}
00967 inline const double * getCbcColSolution() const
00968 { return cbcColSolution_;}
00970 inline const double * getCbcRowPrice() const
00971 { return cbcRowPrice_;}
00973 inline const double * getCbcReducedCost() const
00974 { return cbcReducedCost_;}
00976 inline const double * getCbcRowActivity() const
00977 { return cbcRowActivity_;}
00979
00980
00983
00984 inline double * continuousSolution() const
00985 { return continuousSolution_;}
00990 inline int * usedInSolution() const
00991 { return usedInSolution_;}
00993 void incrementUsed(const double * solution);
00995 void setBestSolution(CBC_Message how,
00996 double & objectiveValue, const double *solution,
00997 bool fixVariables=false);
00999 void setBestObjectiveValue( double objectiveValue);
01000
01007 double checkSolution(double cutoff, double * solution,
01008 bool fixVariables, double originalObjValue);
01015 bool feasibleSolution(int & numberIntegerInfeasibilities,
01016 int & numberObjectInfeasibilities) const;
01017
01023 inline double * currentSolution() const
01024 { return currentSolution_;}
01028 inline const double * testSolution() const
01029 { return testSolution_;}
01030 inline void setTestSolution(const double * solution)
01031 { testSolution_ = solution;}
01033 void reserveCurrentSolution(const double * solution=NULL);
01034
01036 inline const double * getColSolution() const
01037 { return solver_->getColSolution();}
01038
01040 inline const double * getRowPrice() const
01041 { return solver_->getRowPrice();}
01042
01044 inline const double * getReducedCost() const
01045 { return solver_->getReducedCost();}
01046
01048 inline const double * getRowActivity() const
01049 { return solver_->getRowActivity();}
01050
01052 inline double getCurrentObjValue() const
01053 { return dblParam_[CbcCurrentObjectiveValue]; }
01055 inline double getCurrentMinimizationObjValue() const
01056 { return dblParam_[CbcCurrentMinimizationObjectiveValue];}
01057
01059 inline double getMinimizationObjValue() const
01060 { return bestObjective_;}
01062 inline void setMinimizationObjValue(double value)
01063 { bestObjective_=value;}
01064
01066 inline double getObjValue() const
01067 { return bestObjective_ * solver_->getObjSense() ; }
01073 double getBestPossibleObjValue() const;
01075 inline void setObjValue(double value)
01076 { bestObjective_=value * solver_->getObjSense() ;}
01077
01084 inline double * bestSolution() const
01085 { return bestSolution_;}
01086 void setBestSolution(const double * solution,int numberColumns,double objectiveValue);
01087
01089 inline int getSolutionCount() const
01090 { return numberSolutions_;}
01091
01093 inline void setSolutionCount(int value)
01094 { numberSolutions_=value;}
01103 inline int phase() const
01104 { return phase_;}
01105
01107 inline int getNumberHeuristicSolutions() const { return numberHeuristicSolutions_;}
01109 inline void setNumberHeuristicSolutions(int value) { numberHeuristicSolutions_=value;}
01110
01112 inline void setObjSense(double s) { dblParam_[CbcOptimizationDirection]=s;
01113 solver_->setObjSense(s);}
01114
01116 inline double getContinuousObjective() const
01117 { return originalContinuousObjective_;}
01118 inline void setContinuousObjective(double value)
01119 { originalContinuousObjective_=value;}
01121 inline int getContinuousInfeasibilities() const
01122 { return continuousInfeasibilities_;}
01123 inline void setContinuousInfeasibilities(int value)
01124 { continuousInfeasibilities_=value;}
01126 inline double rootObjectiveAfterCuts() const
01127 { return continuousObjective_;}
01129 inline double sumChangeObjective() const
01130 { return sumChangeObjective1_;}
01133 inline int numberGlobalViolations() const
01134 { return numberGlobalViolations_;}
01135 inline void clearNumberGlobalViolations()
01136 { numberGlobalViolations_=0;}
01138 inline bool resolveAfterTakeOffCuts() const
01139 { return resolveAfterTakeOffCuts_;}
01140 inline void setResolveAfterTakeOffCuts(bool yesNo)
01141 { resolveAfterTakeOffCuts_=yesNo;}
01143 inline int getNumberThreads() const
01144 { return numberThreads_;}
01146 inline void setNumberThreads(int value)
01147 { numberThreads_=value;}
01149 inline int getThreadMode() const
01150 { return threadMode_;}
01157 inline void setThreadMode(int value)
01158 { threadMode_=value;}
01160
01163
01164 inline CbcCompareBase * nodeComparison() const
01165 { return nodeCompare_;}
01166 void setNodeComparison(CbcCompareBase * compare);
01167 void setNodeComparison(CbcCompareBase & compare);
01169
01172
01173 inline CbcFeasibilityBase * problemFeasibility() const
01174 { return problemFeasibility_;}
01175 void setProblemFeasibility(CbcFeasibilityBase * feasibility);
01176 void setProblemFeasibility(CbcFeasibilityBase & feasibility);
01178
01181
01182 inline CbcTree * tree() const
01183 { return tree_;}
01185 void passInTreeHandler(CbcTree & tree);
01189 void passInSubTreeModel(CbcModel & model);
01194 CbcModel * subTreeModel(OsiSolverInterface * solver=NULL) const;
01196 inline int numberStoppedSubTrees() const
01197 { return numberStoppedSubTrees_;}
01199 inline void incrementSubTreeStopped()
01200 { numberStoppedSubTrees_++;}
01206 inline int typePresolve() const
01207 { return presolve_;}
01208 inline void setTypePresolve(int value)
01209 { presolve_=value;}
01210
01212
01218
01220 inline CbcBranchDecision * branchingMethod() const
01221 { return branchingMethod_;}
01223 inline void setBranchingMethod(CbcBranchDecision * method)
01224 { delete branchingMethod_; branchingMethod_ = method->clone();}
01229 inline void setBranchingMethod(CbcBranchDecision & method)
01230 { delete branchingMethod_; branchingMethod_ = method.clone();}
01232 inline CbcCutModifier * cutModifier() const
01233 { return cutModifier_;}
01235 void setCutModifier(CbcCutModifier * modifier);
01240 void setCutModifier(CbcCutModifier & modifier);
01242
01245
01252 inline int stateOfSearch() const
01253 { return stateOfSearch_;}
01254 inline void setStateOfSearch(int state)
01255 { stateOfSearch_=state;}
01257 inline int searchStrategy() const
01258 { return searchStrategy_;}
01260 inline void setSearchStrategy(int value)
01261 { searchStrategy_ = value; }
01262
01264 inline int numberCutGenerators() const
01265 { return numberCutGenerators_;}
01267 inline CbcCutGenerator ** cutGenerators() const
01268 { return generator_;}
01270 inline CbcCutGenerator * cutGenerator(int i) const
01271 { return generator_[i];}
01273 inline CbcCutGenerator * virginCutGenerator(int i) const
01274 { return virginGenerator_[i];}
01283 void addCutGenerator(CglCutGenerator * generator,
01284 int howOften=1, const char * name=NULL,
01285 bool normal=true, bool atSolution=false,
01286 bool infeasible=false,int howOftenInSub=-100,
01287 int whatDepth=-1, int whatDepthInSub=-1);
01289
01294
01296 inline CbcStrategy * strategy() const
01297 { return strategy_;}
01299 void setStrategy(CbcStrategy & strategy);
01301 inline CbcModel * parentModel() const
01302 { return parentModel_;}
01304 inline void setParentModel(CbcModel & parentModel)
01305 { parentModel_ = &parentModel;}
01307
01308
01315 void addHeuristic(CbcHeuristic * generator, const char *name = NULL);
01317 inline CbcHeuristic * heuristic(int i) const
01318 { return heuristic_[i];}
01320 inline int numberHeuristics() const
01321 { return numberHeuristics_;}
01323 inline CbcHeuristic * lastHeuristic() const
01324 { return lastHeuristic_;}
01326 inline void setLastHeuristic(CbcHeuristic * last)
01327 { lastHeuristic_=last;}
01328
01347 void passInPriorities(const int * priorities, bool ifNotSimpleIntegers);
01348
01350 inline int priority(int sequence) const
01351 { return object_[sequence]->priority();}
01352
01357 void passInEventHandler(const CbcEventHandler *eventHandler) ;
01358
01360 inline CbcEventHandler* getEventHandler() const
01361 { return (eventHandler_) ; }
01362
01364
01374 void setApplicationData (void * appData);
01375
01377 void * getApplicationData() const;
01390 void passInSolverCharacteristics(OsiBabSolver * solverCharacteristics);
01392 inline const OsiBabSolver * solverCharacteristics() const
01393 { return solverCharacteristics_;}
01395
01396
01397
01400
01401 void passInMessageHandler(CoinMessageHandler * handler);
01403 void newLanguage(CoinMessages::Language language);
01404 inline void setLanguage(CoinMessages::Language language)
01405 {newLanguage(language);}
01407 inline CoinMessageHandler * messageHandler() const
01408 {return handler_;}
01410 inline CoinMessages & messages()
01411 {return messages_;}
01413 inline CoinMessages * messagesPointer()
01414 {return &messages_;}
01416 void setLogLevel(int value);
01418 inline int logLevel() const
01419 { return handler_->logLevel();}
01421
01423
01424
01435
01436 inline void setSpecialOptions(int value)
01437 { specialOptions_=value;}
01439 inline int specialOptions() const
01440 { return specialOptions_;}
01442 inline bool normalSolver() const
01443 { return (specialOptions_&16)==0;}
01445 inline bool ownObjects() const
01446 { return ownObjects_;}
01448 inline void * mutex()
01449 { return mutex_;}
01451
01452
01454
01455
01456 CbcModel();
01457
01459 CbcModel(const OsiSolverInterface &);
01460
01469 void assignSolver(OsiSolverInterface *&solver,bool deleteSolver=true);
01470
01482 inline void setModelOwnsSolver (bool ourSolver)
01483 { ourSolver_ = ourSolver ; }
01484
01490 inline bool modelOwnsSolver () { return (ourSolver_) ; }
01491
01495 CbcModel(const CbcModel & rhs, bool noTree=false);
01496
01498 CbcModel & operator=(const CbcModel& rhs);
01499
01501 ~CbcModel ();
01502
01504 inline OsiSolverInterface * solver() const
01505 { return solver_;}
01506
01508 inline OsiSolverInterface * continuousSolver() const
01509 { return continuousSolver_;}
01510
01512 inline void createContinuousSolver()
01513 { continuousSolver_ = solver_->clone();}
01515 inline void clearContinuousSolver()
01516 { delete continuousSolver_; continuousSolver_ = NULL;}
01517
01519 inline OsiSolverInterface * referenceSolver() const
01520 { return referenceSolver_;}
01521
01523 void saveReferenceSolver();
01524
01530 void resetToReferenceSolver();
01531
01533 void gutsOfDestructor();
01536 void gutsOfDestructor2();
01539 void resetModel();
01541 void moveInfo(const CbcModel & rhs);
01543
01545
01546
01547 int getNodeCount2() const
01548 { return numberNodes2_;}
01550 void setPointers(const OsiSolverInterface * solver);
01556 int reducedCostFix() ;
01558 int resolve(OsiSolverInterface * solver);
01559
01563 int chooseBranch(CbcNode * newNode, int numberPassesLeft,
01564 CbcNode * oldNode, OsiCuts & cuts,
01565 bool & resolved, CoinWarmStartBasis *lastws,
01566 const double * lowerBefore,const double * upperBefore,
01567 OsiSolverBranch * & branches);
01568 int chooseBranch(CbcNode * newNode, int numberPassesLeft, bool & resolved);
01569
01576 CoinWarmStartBasis *getEmptyBasis(int ns = 0, int na = 0) const ;
01577
01587 void takeOffCuts(OsiCuts &cuts,
01588 bool allowResolve,OsiCuts * saveCuts) ;
01589
01603 int addCuts(CbcNode * node, CoinWarmStartBasis *&lastws,bool canFix);
01604
01619 void addCuts1(CbcNode * node, CoinWarmStartBasis *&lastws);
01624 void setObjectiveValue(CbcNode * thisNode, const CbcNode * parentNode) const;
01625
01629 void convertToDynamic();
01631 void zapIntegerInformation(bool leaveObjects=true);
01633 int cliquePseudoCosts(int doStatistics);
01635 void pseudoShadow(double * down, double * up);
01641 void doHeuristicsAtRoot(int deleteHeuristicsAfterwards=0);
01643 inline const double * hotstartSolution() const
01644 { return hotstartSolution_;}
01646 inline const int * hotstartPriorities() const
01647 { return hotstartPriorities_;}
01648
01650 inline CbcCountRowCut ** addedCuts() const
01651 { return addedCuts_;}
01653 inline int currentNumberCuts() const
01654 { return currentNumberCuts_;}
01656 inline OsiCuts * globalCuts()
01657 { return &globalCuts_;}
01659 void setNextRowCut(const OsiRowCut & cut);
01661 inline CbcNode * currentNode() const
01662 { return currentNode_;}
01664 inline CglTreeProbingInfo * probingInfo() const
01665 { return probingInfo_;}
01667 inline void setNumberStrongIterations(int number)
01668 { numberStrongIterations_ = number;}
01670 inline int numberStrongIterations() const
01671 { return numberStrongIterations_;}
01673 void incrementStrongInfo(int numberTimes, int numberIterations,
01674 int numberFixed, bool ifInfeasible);
01676 void generateCpp( FILE * fp,int options);
01678 OsiBranchingInformation usefulInformation() const;
01685 inline void setBestSolutionBasis(const CoinWarmStartBasis & bestSolutionBasis)
01686 { bestSolutionBasis_ = bestSolutionBasis;}
01688
01689
01690
01691 private:
01693
01694
01696 OsiSolverInterface * solver_;
01697
01704 bool ourSolver_ ;
01705
01707 OsiSolverInterface * continuousSolver_;
01708
01710 OsiSolverInterface * referenceSolver_;
01711
01713 CoinMessageHandler * handler_;
01714
01720 bool defaultHandler_;
01721
01723 CoinMessages messages_;
01724
01726 int intParam_[CbcLastIntParam];
01727
01729 double dblParam_[CbcLastDblParam];
01730
01739 mutable CoinWarmStart *emptyWarmStart_ ;
01740
01742 double bestObjective_;
01744 double bestPossibleObjective_;
01746 double sumChangeObjective1_;
01748 double sumChangeObjective2_;
01749
01751 double * bestSolution_;
01752
01757 double * currentSolution_;
01761 mutable const double * testSolution_;
01768 CoinWarmStartBasis bestSolutionBasis_ ;
01770 OsiCuts globalCuts_;
01771
01773 double minimumDrop_;
01775 int numberSolutions_;
01782 int stateOfSearch_;
01784 double * hotstartSolution_;
01786 int * hotstartPriorities_;
01788 int numberHeuristicSolutions_;
01790 int numberNodes_;
01794 int numberNodes2_;
01796 int numberIterations_;
01798 int status_;
01809 int secondaryStatus_;
01811 int numberIntegers_;
01813 int numberRowsAtContinuous_;
01815 int maximumNumberCuts_;
01824 int phase_;
01825
01827 int currentNumberCuts_;
01828
01833 int maximumDepth_;
01839 CbcNodeInfo ** walkback_;
01840
01848 CbcCountRowCut ** addedCuts_;
01849
01853 OsiRowCut * nextRowCut_;
01854
01856 CbcNode * currentNode_;
01857
01859 int * integerVariable_;
01861 char * integerInfo_;
01863 double * continuousSolution_;
01865 int * usedInSolution_;
01872 int specialOptions_;
01874 CbcCompareBase * nodeCompare_;
01876 CbcFeasibilityBase * problemFeasibility_;
01878 CbcTree * tree_;
01880 CbcModel * subTreeModel_;
01882 int numberStoppedSubTrees_;
01884 CbcBranchDecision * branchingMethod_;
01886 CbcCutModifier * cutModifier_;
01888 CbcStrategy * strategy_;
01890 CbcModel * parentModel_;
01896
01897 const double * cbcColLower_;
01899 const double * cbcColUpper_;
01901 const double * cbcRowLower_;
01903 const double * cbcRowUpper_;
01905 const double * cbcColSolution_;
01907 const double * cbcRowPrice_;
01909 const double * cbcReducedCost_;
01911 const double * cbcRowActivity_;
01913 void * appData_;
01915 void * mutex_;
01917 int presolve_;
01921 int numberStrong_;
01927 int numberBeforeTrust_;
01931 int numberPenalties_;
01934 double penaltyScaleFactor_;
01936 int numberAnalyzeIterations_;
01938 double * analyzeResults_;
01940 int numberInfeasibleNodes_;
01947 int problemType_;
01949 int printFrequency_;
01951 int numberCutGenerators_;
01952
01953 CbcCutGenerator ** generator_;
01954
01955 CbcCutGenerator ** virginGenerator_;
01957 int numberHeuristics_;
01959 CbcHeuristic ** heuristic_;
01961 CbcHeuristic * lastHeuristic_;
01963 # ifdef CBC_ONLY_CLP
01964 ClpEventHandler *eventHandler_ ;
01965 # else
01966 CbcEventHandler *eventHandler_ ;
01967 # endif
01968
01970 int numberObjects_;
01971
01982 OsiObject ** object_;
01984 bool ownObjects_;
01985
01987 int * originalColumns_;
01989 int howOftenGlobalScan_;
01992 int numberGlobalViolations_;
01996 double continuousObjective_;
01999 double originalContinuousObjective_;
02001 int continuousInfeasibilities_;
02003 int maximumCutPassesAtRoot_;
02005 int maximumCutPasses_;
02007 int preferredWay_;
02009 int currentPassNumber_;
02011 int maximumWhich_;
02013 int * whichGenerator_;
02015 int maximumStatistics_;
02017 CbcStatistics ** statistics_;
02019 int maximumDepthActual_;
02021 double numberDJFixed_;
02023 CglTreeProbingInfo * probingInfo_;
02025 int numberFixedAtRoot_;
02027 int numberFixedNow_;
02029 bool stoppedOnGap_;
02031 bool eventHappened_;
02033 int numberLongStrong_;
02035 int numberOldActiveCuts_;
02037 int numberNewCuts_;
02039 int sizeMiniTree_;
02041 int searchStrategy_;
02043 int numberStrongIterations_;
02045 int strongInfo_[3];
02052 OsiBabSolver * solverCharacteristics_;
02054 bool resolveAfterTakeOffCuts_;
02055 #if NEW_UPDATE_OBJECT>1
02057 int numberUpdateItems_;
02059 int maximumNumberUpdateItems_;
02061 CbcObjectUpdateData * updateItems_;
02062 #endif
02063
02070 int numberThreads_;
02077 int threadMode_;
02079 };
02081 void getIntegerInformation(const OsiObject * object, double & originalLower,
02082 double & originalUpper) ;
02083
02084
02085 class OsiClpSolverInterface;
02086 int CbcMain (int argc, const char *argv[],OsiClpSolverInterface & solver,CbcModel ** babSolver);
02087 int CbcMain (int argc, const char *argv[],CbcModel & babSolver);
02088
02089 int callCbc(const char * input2, OsiClpSolverInterface& solver1);
02090 int callCbc(const char * input2);
02091 int callCbc(const std::string input2, OsiClpSolverInterface& solver1);
02092 int callCbc(const std::string input2) ;
02093
02094 void CbcMain0 (CbcModel & babSolver);
02095 int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver);
02096
02097 int callCbc(const char * input2, CbcModel & babSolver);
02098 int callCbc(const std::string input2, CbcModel & babSolver);
02099
02100 int callCbc1(const char * input2, CbcModel & babSolver);
02101 int callCbc1(const std::string input2, CbcModel & babSolver);
02102
02103 int callCbc1(const char * input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02104 int callCbc1(const std::string input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02105 int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02106 #endif