00001
00002
00003
00004 #ifndef CbcModel_H
00005 #define CbcModel_H
00006 #include <string>
00007 #include <vector>
00008 #include "CoinFinite.hpp"
00009 #include "CoinMessageHandler.hpp"
00010 #include "OsiSolverInterface.hpp"
00011 #include "OsiBranchingObject.hpp"
00012 #include "OsiCuts.hpp"
00013 #include "CoinWarmStartBasis.hpp"
00014 #include "CbcCompareBase.hpp"
00015 #include "CbcMessage.hpp"
00016 #include "CbcEventHandler.hpp"
00017
00018
00019
00020 class CbcCutGenerator;
00021 class OsiRowCut;
00022 class OsiBabSolver;
00023 class OsiRowCutDebugger;
00024 class CglCutGenerator;
00025 class CbcCutModifier;
00026 class CglTreeProbingInfo;
00027 class CbcHeuristic;
00028 class OsiObject;
00029 class CbcTree;
00030 class CbcStrategy;
00031 class CbcFeasibilityBase;
00032 class CbcStatistics;
00033 class CbcEventHandler ;
00034 class CglPreProcess;
00035 # ifdef COIN_HAS_CLP
00036 class ClpNodeStuff;
00037 #endif
00038
00039
00040
00041
00094 class CbcModel {
00095
00096 public:
00097
00098 enum CbcIntParam {
00100 CbcMaxNumNode=0,
00102 CbcMaxNumSol,
00112 CbcFathomDiscipline,
00116 CbcPrinting,
00119 CbcNumberBranches,
00121 CbcLastIntParam
00122 };
00123
00124 enum CbcDblParam {
00127 CbcIntegerTolerance=0,
00130 CbcInfeasibilityWeight,
00133 CbcCutoffIncrement,
00140 CbcAllowableGap,
00147 CbcAllowableFractionGap,
00150 CbcMaximumSeconds,
00152 CbcCurrentCutoff,
00154 CbcOptimizationDirection,
00156 CbcCurrentObjectiveValue,
00158 CbcCurrentMinimizationObjectiveValue,
00161 CbcStartSeconds,
00169 CbcHeuristicGap,
00177 CbcHeuristicFractionGap,
00179 CbcSmallestChange,
00181 CbcSumChange,
00183 CbcLargestChange,
00185 CbcSmallChange,
00187 CbcLastDblParam
00188 };
00189
00190
00191
00192 public:
00194
00195
00199 void initialSolve();
00200
00211 void branchAndBound(int doStatistics=0);
00212 private:
00213
00221 bool solveWithCuts(OsiCuts & cuts, int numberTries,CbcNode * node);
00228 CbcNode ** solveOneNode(int whichSolver,CbcNode * node,
00229 int & numberNodesOutput, int & status) ;
00231 void resizeWhichGenerator(int numberNow, int numberAfter);
00232 public:
00233 #ifdef CBC_KEEP_DEPRECATED
00234
00239 CbcModel * cleanModel(const double * lower, const double * upper);
00256 int subBranchAndBound(CbcModel * model2,
00257 CbcModel * presolvedModel,
00258 int maximumNodes);
00274 int subBranchAndBound(const double * lower, const double * upper,
00275 int maximumNodes);
00276
00283 OsiSolverInterface * strengthenedModel();
00293 CglPreProcess * preProcess( int makeEquality=0, int numberPasses=5,
00294 int tuning=5);
00297 void postProcess(CglPreProcess * process);
00298 #endif
00299
00300 void addUpdateInformation(const CbcObjectUpdateData & data);
00307 int doOneNode(CbcModel * baseModel, CbcNode * & node, CbcNode * & newNode);
00308
00310 bool isLocked() const;
00311 #ifdef CBC_THREAD
00312
00316 void lockThread();
00320 void unlockThread();
00321 #else
00322 inline void lockThread() {}
00323 inline void unlockThread() {}
00324 #endif
00325 private:
00332 void moveToModel(CbcModel * baseModel,int mode);
00333 public:
00347 int resolve(CbcNodeInfo * parent, int whereFrom,
00348 double * saveSolution=NULL,
00349 double * saveLower=NULL,
00350 double * saveUpper=NULL);
00352 void makeGlobalCuts(int numberRows,const int * which);
00354 void makeGlobalCut(const OsiRowCut * cut);
00356 void makeGlobalCut(const OsiRowCut & cut);
00358 void makeGlobalCut(const OsiColCut * cut);
00360 void makeGlobalCut(const OsiColCut & cut);
00362
00365
00377 CbcModel * findCliques(bool makeEquality, int atLeastThisMany,
00378 int lessThanThis, int defaultValue=1000);
00379
00388 CbcModel * integerPresolve(bool weak=false);
00389
00394 bool integerPresolveThisModel(OsiSolverInterface * originalSolver,bool weak=false);
00395
00396
00398 void originalModel(CbcModel * presolvedModel,bool weak);
00399
00420 bool tightenVubs(int type,bool allowMultipleBinary=false,
00421 double useCutoff=1.0e50);
00422
00428 bool tightenVubs(int numberVubs, const int * which,
00429 double useCutoff=1.0e50);
00433 void analyzeObjective();
00434
00435
00437
00443
00445 inline int numberObjects() const { return numberObjects_;}
00447 inline void setNumberObjects(int number)
00448 { numberObjects_=number;}
00449
00451 inline OsiObject ** objects() const { return object_;}
00452
00454 const inline OsiObject * object(int which) const { return object_[which];}
00456 inline OsiObject * modifiableObject(int which) const { return object_[which];}
00457
00458 void setOptionalInteger(int index);
00459
00461 void deleteObjects(bool findIntegers=true);
00462
00467 void addObjects(int numberObjects, OsiObject ** objects);
00468
00473 void addObjects(int numberObjects, CbcObject ** objects);
00474
00476 void synchronizeModel() ;
00477
00487 void findIntegers(bool startAgain,int type=0);
00488
00490
00491
00492
00502
00503 inline bool setIntParam(CbcIntParam key, int value) {
00504 intParam_[key] = value;
00505 return true;
00506 }
00508 inline bool setDblParam(CbcDblParam key, double value) {
00509 dblParam_[key] = value;
00510 return true;
00511 }
00513 inline int getIntParam(CbcIntParam key) const {
00514 return intParam_[key];
00515 }
00517 inline double getDblParam(CbcDblParam key) const {
00518 return dblParam_[key];
00519 }
00525 void setCutoff(double value) ;
00526
00528 inline double getCutoff() const
00529 {
00530
00531
00532 return dblParam_[CbcCurrentCutoff];
00533 }
00534
00536 inline bool setMaximumNodes( int value)
00537 { return setIntParam(CbcMaxNumNode,value); }
00538
00540 inline int getMaximumNodes() const
00541 { return getIntParam(CbcMaxNumNode); }
00542
00547 inline bool setMaximumSolutions( int value) {
00548 return setIntParam(CbcMaxNumSol,value);
00549 }
00554 inline int getMaximumSolutions() const {
00555 return getIntParam(CbcMaxNumSol);
00556 }
00558 inline bool setPrintingMode( int value)
00559 { return setIntParam(CbcPrinting,value); }
00560
00562 inline int getPrintingMode() const
00563 { return getIntParam(CbcPrinting); }
00564
00569 inline bool setMaximumSeconds( double value) {
00570 return setDblParam(CbcMaximumSeconds,value);
00571 }
00576 inline double getMaximumSeconds() const {
00577 return getDblParam(CbcMaximumSeconds);
00578 }
00580 double getCurrentSeconds() const ;
00581
00583 bool maximumSecondsReached() const ;
00584
00588 inline bool setIntegerTolerance( double value) {
00589 return setDblParam(CbcIntegerTolerance,value);
00590 }
00594 inline double getIntegerTolerance() const {
00595 return getDblParam(CbcIntegerTolerance);
00596 }
00597
00602 inline bool setInfeasibilityWeight( double value) {
00603 return setDblParam(CbcInfeasibilityWeight,value);
00604 }
00609 inline double getInfeasibilityWeight() const {
00610 return getDblParam(CbcInfeasibilityWeight);
00611 }
00612
00616 inline bool setAllowableGap( double value) {
00617 return setDblParam(CbcAllowableGap,value);
00618 }
00622 inline double getAllowableGap() const {
00623 return getDblParam(CbcAllowableGap);
00624 }
00625
00629 inline bool setAllowableFractionGap( double value) {
00630 return setDblParam(CbcAllowableFractionGap,value);
00631 }
00635 inline double getAllowableFractionGap() const {
00636 return getDblParam(CbcAllowableFractionGap);
00637 }
00641 inline bool setAllowablePercentageGap( double value) {
00642 return setDblParam(CbcAllowableFractionGap,value*0.01);
00643 }
00647 inline double getAllowablePercentageGap() const {
00648 return 100.0*getDblParam(CbcAllowableFractionGap);
00649 }
00653 inline bool setHeuristicGap( double value) {
00654 return setDblParam(CbcHeuristicGap,value);
00655 }
00659 inline double getHeuristicGap() const {
00660 return getDblParam(CbcHeuristicGap);
00661 }
00662
00666 inline bool setHeuristicFractionGap( double value) {
00667 return setDblParam(CbcHeuristicFractionGap,value);
00668 }
00672 inline double getHeuristicFractionGap() const {
00673 return getDblParam(CbcHeuristicFractionGap);
00674 }
00679 inline bool setCutoffIncrement( double value) {
00680 return setDblParam(CbcCutoffIncrement,value);
00681 }
00686 inline double getCutoffIncrement() const {
00687 return getDblParam(CbcCutoffIncrement);
00688 }
00689
00694 void setHotstartSolution(const double * solution, const int * priorities=NULL) ;
00695
00697 inline void setMinimumDrop(double value)
00698 {minimumDrop_=value;}
00700 inline double getMinimumDrop() const
00701 { return minimumDrop_;}
00702
00705 inline void setMaximumCutPassesAtRoot(int value)
00706 {maximumCutPassesAtRoot_=value;}
00708 inline int getMaximumCutPassesAtRoot() const
00709 { return maximumCutPassesAtRoot_;}
00710
00713 inline void setMaximumCutPasses(int value)
00714 {maximumCutPasses_=value;}
00716 inline int getMaximumCutPasses() const
00717 { return maximumCutPasses_;}
00720 inline int getCurrentPassNumber() const
00721 { return currentPassNumber_;}
00722
00728 void setNumberStrong(int number);
00732 inline int numberStrong() const
00733 { return numberStrong_;}
00736 inline void setPreferredWay(int value)
00737 {preferredWay_=value;}
00739 inline int getPreferredWay() const
00740 { return preferredWay_;}
00742 inline int whenCuts() const
00743 { return whenCuts_;}
00745 inline void setWhenCuts(int value)
00746 { whenCuts_ = value;}
00752 bool doCutsNow(int allowForTopOfTree) const;
00753
00759 void setNumberBeforeTrust(int number);
00762 inline int numberBeforeTrust() const
00763 { return numberBeforeTrust_;}
00769 void setNumberPenalties(int number);
00772 inline int numberPenalties() const
00773 { return numberPenalties_;}
00775 inline void setNumberAnalyzeIterations(int number)
00776 { numberAnalyzeIterations_=number;}
00777 inline int numberAnalyzeIterations() const
00778 { return numberAnalyzeIterations_;}
00781 inline double penaltyScaleFactor() const
00782 { return penaltyScaleFactor_;}
00785 void setPenaltyScaleFactor(double value);
00793 void inline setProblemType(int number)
00794 { problemType_=number;}
00795 inline int problemType() const
00796 { return problemType_;}
00798 inline int currentDepth() const
00799 { return currentDepth_;}
00800
00802 void setHowOftenGlobalScan(int number);
00804 inline int howOftenGlobalScan() const
00805 { return howOftenGlobalScan_;}
00807 inline int * originalColumns() const
00808 { return originalColumns_;}
00810 void setOriginalColumns(const int * originalColumns) ;
00811
00819 inline void setPrintFrequency(int number)
00820 { printFrequency_=number;}
00822 inline int printFrequency() const
00823 { return printFrequency_;}
00825
00826
00828
00829
00830 bool isAbandoned() const;
00832 bool isProvenOptimal() const;
00834 bool isProvenInfeasible() const;
00836 bool isContinuousUnbounded() const;
00838 bool isProvenDualInfeasible() const;
00840 bool isNodeLimitReached() const;
00842 bool isSecondsLimitReached() const;
00844 bool isSolutionLimitReached() const;
00846 inline int getIterationCount() const
00847 { return numberIterations_;}
00849 inline void incrementIterationCount(int value)
00850 { numberIterations_ += value;}
00852 inline int getNodeCount() const
00853 { return numberNodes_;}
00855 inline void incrementNodeCount(int value)
00856 { numberNodes_ += value;}
00866 inline int status() const
00867 { return status_;}
00868 inline void setProblemStatus(int value)
00869 { status_=value;}
00881 inline int secondaryStatus() const
00882 { return secondaryStatus_;}
00883 inline void setSecondaryStatus(int value)
00884 { secondaryStatus_=value;}
00886 bool isInitialSolveAbandoned() const ;
00888 bool isInitialSolveProvenOptimal() const ;
00890 bool isInitialSolveProvenPrimalInfeasible() const ;
00892 bool isInitialSolveProvenDualInfeasible() const ;
00893
00895
00896
00909
00910 inline int numberRowsAtContinuous() const
00911 { return numberRowsAtContinuous_;}
00912
00914 inline int getNumCols() const
00915 { return solver_->getNumCols();}
00916
00918 inline int getNumRows() const
00919 { return solver_->getNumRows();}
00920
00922 inline CoinBigIndex getNumElements() const
00923 { return solver_->getNumElements();}
00924
00926 inline int numberIntegers() const
00927 { return numberIntegers_;}
00928
00929 inline const int * integerVariable() const
00930 { return integerVariable_;}
00932 inline char integerType(int i) const
00933 { assert (integerInfo_); assert (integerInfo_[i]==0||integerInfo_[i]==1);return integerInfo_[i];}
00935 inline const char * integerType() const
00936 { return integerInfo_;}
00937
00939 inline const double * getColLower() const
00940 { return solver_->getColLower();}
00941
00943 inline const double * getColUpper() const
00944 { return solver_->getColUpper();}
00945
00955 inline const char * getRowSense() const
00956 { return solver_->getRowSense();}
00957
00966 inline const double * getRightHandSide() const
00967 { return solver_->getRightHandSide();}
00968
00977 inline const double * getRowRange() const
00978 { return solver_->getRowRange();}
00979
00981 inline const double * getRowLower() const
00982 { return solver_->getRowLower();}
00983
00985 inline const double * getRowUpper() const
00986 { return solver_->getRowUpper();}
00987
00989 inline const double * getObjCoefficients() const
00990 { return solver_->getObjCoefficients();}
00991
00993 inline double getObjSense() const
00994 {
00995
00996 return dblParam_[CbcOptimizationDirection];}
00997
00999 inline bool isContinuous(int colIndex) const
01000 { return solver_->isContinuous(colIndex);}
01001
01003 inline bool isBinary(int colIndex) const
01004 { return solver_->isBinary(colIndex);}
01005
01010 inline bool isInteger(int colIndex) const
01011 { return solver_->isInteger(colIndex);}
01012
01014 inline bool isIntegerNonBinary(int colIndex) const
01015 { return solver_->isIntegerNonBinary(colIndex);}
01016
01018 inline bool isFreeBinary(int colIndex) const
01019 { return solver_->isFreeBinary(colIndex) ;}
01020
01022 inline const CoinPackedMatrix * getMatrixByRow() const
01023 { return solver_->getMatrixByRow();}
01024
01026 inline const CoinPackedMatrix * getMatrixByCol() const
01027 { return solver_->getMatrixByCol();}
01028
01030 inline double getInfinity() const
01031 { return solver_->getInfinity();}
01033 inline const double * getCbcColLower() const
01034 { return cbcColLower_;}
01036 inline const double * getCbcColUpper() const
01037 { return cbcColUpper_;}
01039 inline const double * getCbcRowLower() const
01040 { return cbcRowLower_;}
01042 inline const double * getCbcRowUpper() const
01043 { return cbcRowUpper_;}
01045 inline const double * getCbcColSolution() const
01046 { return cbcColSolution_;}
01048 inline const double * getCbcRowPrice() const
01049 { return cbcRowPrice_;}
01051 inline const double * getCbcReducedCost() const
01052 { return cbcReducedCost_;}
01054 inline const double * getCbcRowActivity() const
01055 { return cbcRowActivity_;}
01057
01058
01061
01062 inline double * continuousSolution() const
01063 { return continuousSolution_;}
01068 inline int * usedInSolution() const
01069 { return usedInSolution_;}
01071 void incrementUsed(const double * solution);
01073 void setBestSolution(CBC_Message how,
01074 double & objectiveValue, const double *solution,
01075 int fixVariables=0);
01077 void setBestObjectiveValue( double objectiveValue);
01079 CbcEventHandler::CbcAction dealWithEventHandler(CbcEventHandler::CbcEvent event,
01080 double objValue,
01081 const double * solution);
01082
01089 double checkSolution(double cutoff, double * solution,
01090 int fixVariables, double originalObjValue);
01097 bool feasibleSolution(int & numberIntegerInfeasibilities,
01098 int & numberObjectInfeasibilities) const;
01099
01105 inline double * currentSolution() const
01106 { return currentSolution_;}
01110 inline const double * testSolution() const
01111 { return testSolution_;}
01112 inline void setTestSolution(const double * solution)
01113 { testSolution_ = solution;}
01115 void reserveCurrentSolution(const double * solution=NULL);
01116
01118 inline const double * getColSolution() const
01119 { return solver_->getColSolution();}
01120
01122 inline const double * getRowPrice() const
01123 { return solver_->getRowPrice();}
01124
01126 inline const double * getReducedCost() const
01127 { return solver_->getReducedCost();}
01128
01130 inline const double * getRowActivity() const
01131 { return solver_->getRowActivity();}
01132
01134 inline double getCurrentObjValue() const
01135 { return dblParam_[CbcCurrentObjectiveValue]; }
01137 inline double getCurrentMinimizationObjValue() const
01138 { return dblParam_[CbcCurrentMinimizationObjectiveValue];}
01139
01141 inline double getMinimizationObjValue() const
01142 { return bestObjective_;}
01144 inline void setMinimizationObjValue(double value)
01145 { bestObjective_=value;}
01146
01148 inline double getObjValue() const
01149 { return bestObjective_ * solver_->getObjSense() ; }
01155 double getBestPossibleObjValue() const;
01157 inline void setObjValue(double value)
01158 { bestObjective_=value * solver_->getObjSense() ;}
01160 inline double getSolverObjValue() const
01161 { return solver_->getObjValue() * solver_->getObjSense() ;}
01162
01169 inline double * bestSolution() const
01170 { return bestSolution_;}
01177 void setBestSolution(const double * solution,int numberColumns,
01178 double objectiveValue,bool check=false);
01179
01181 inline int getSolutionCount() const
01182 { return numberSolutions_;}
01183
01185 inline void setSolutionCount(int value)
01186 { numberSolutions_=value;}
01188 int numberSavedSolutions() const;
01190 inline int maximumSavedSolutions() const
01191 { return maximumSavedSolutions_;}
01193 void setMaximumSavedSolutions(int value);
01195 const double * savedSolution(int which) const;
01197 double savedSolutionObjective(int which) const;
01198
01207 inline int phase() const
01208 { return phase_;}
01209
01211 inline int getNumberHeuristicSolutions() const { return numberHeuristicSolutions_;}
01213 inline void setNumberHeuristicSolutions(int value) { numberHeuristicSolutions_=value;}
01214
01216 inline void setObjSense(double s) { dblParam_[CbcOptimizationDirection]=s;
01217 solver_->setObjSense(s);}
01218
01220 inline double getContinuousObjective() const
01221 { return originalContinuousObjective_;}
01222 inline void setContinuousObjective(double value)
01223 { originalContinuousObjective_=value;}
01225 inline int getContinuousInfeasibilities() const
01226 { return continuousInfeasibilities_;}
01227 inline void setContinuousInfeasibilities(int value)
01228 { continuousInfeasibilities_=value;}
01230 inline double rootObjectiveAfterCuts() const
01231 { return continuousObjective_;}
01233 inline double sumChangeObjective() const
01234 { return sumChangeObjective1_;}
01237 inline int numberGlobalViolations() const
01238 { return numberGlobalViolations_;}
01239 inline void clearNumberGlobalViolations()
01240 { numberGlobalViolations_=0;}
01242 inline bool resolveAfterTakeOffCuts() const
01243 { return resolveAfterTakeOffCuts_;}
01244 inline void setResolveAfterTakeOffCuts(bool yesNo)
01245 { resolveAfterTakeOffCuts_=yesNo;}
01247 inline int maximumRows() const
01248 { return maximumRows_;}
01250 inline CoinWarmStartBasis & workingBasis()
01251 { return workingBasis_;}
01253 inline int getNumberThreads() const
01254 { return numberThreads_;}
01256 inline void setNumberThreads(int value)
01257 { numberThreads_=value;}
01259 inline int getThreadMode() const
01260 { return threadMode_;}
01270 inline void setThreadMode(int value)
01271 { threadMode_=value;}
01278 inline int parallelMode() const
01279 { if (!numberThreads_) {
01280 if ((threadMode_&1)==0)
01281 return 0;
01282 else
01283 return -1;
01284 return 0;
01285 } else {
01286 if ((threadMode_&1)==0)
01287 return 1;
01288 else
01289 return -2;
01290 }
01291 }
01293 inline int getStopNumberIterations() const
01294 { return stopNumberIterations_;}
01296 inline void setStopNumberIterations(int value)
01297 { stopNumberIterations_=value;}
01299
01302
01303 inline CbcCompareBase * nodeComparison() const
01304 { return nodeCompare_;}
01305 void setNodeComparison(CbcCompareBase * compare);
01306 void setNodeComparison(CbcCompareBase & compare);
01308
01311
01312 inline CbcFeasibilityBase * problemFeasibility() const
01313 { return problemFeasibility_;}
01314 void setProblemFeasibility(CbcFeasibilityBase * feasibility);
01315 void setProblemFeasibility(CbcFeasibilityBase & feasibility);
01317
01320
01321 inline CbcTree * tree() const
01322 { return tree_;}
01324 void passInTreeHandler(CbcTree & tree);
01328 void passInSubTreeModel(CbcModel & model);
01333 CbcModel * subTreeModel(OsiSolverInterface * solver=NULL) const;
01335 inline int numberStoppedSubTrees() const
01336 { return numberStoppedSubTrees_;}
01338 inline void incrementSubTreeStopped()
01339 { numberStoppedSubTrees_++;}
01345 inline int typePresolve() const
01346 { return presolve_;}
01347 inline void setTypePresolve(int value)
01348 { presolve_=value;}
01349
01351
01357
01359 inline CbcBranchDecision * branchingMethod() const
01360 { return branchingMethod_;}
01362 inline void setBranchingMethod(CbcBranchDecision * method)
01363 { delete branchingMethod_; branchingMethod_ = method->clone();}
01368 inline void setBranchingMethod(CbcBranchDecision & method)
01369 { delete branchingMethod_; branchingMethod_ = method.clone();}
01371 inline CbcCutModifier * cutModifier() const
01372 { return cutModifier_;}
01374 void setCutModifier(CbcCutModifier * modifier);
01379 void setCutModifier(CbcCutModifier & modifier);
01381
01384
01391 inline int stateOfSearch() const
01392 { return stateOfSearch_;}
01393 inline void setStateOfSearch(int state)
01394 { stateOfSearch_=state;}
01396 inline int searchStrategy() const
01397 { return searchStrategy_;}
01399 inline void setSearchStrategy(int value)
01400 { searchStrategy_ = value; }
01401
01403 inline int numberCutGenerators() const
01404 { return numberCutGenerators_;}
01406 inline CbcCutGenerator ** cutGenerators() const
01407 { return generator_;}
01409 inline CbcCutGenerator * cutGenerator(int i) const
01410 { return generator_[i];}
01412 inline CbcCutGenerator * virginCutGenerator(int i) const
01413 { return virginGenerator_[i];}
01422 void addCutGenerator(CglCutGenerator * generator,
01423 int howOften=1, const char * name=NULL,
01424 bool normal=true, bool atSolution=false,
01425 bool infeasible=false,int howOftenInSub=-100,
01426 int whatDepth=-1, int whatDepthInSub=-1);
01428
01433
01435 inline CbcStrategy * strategy() const
01436 { return strategy_;}
01438 void setStrategy(CbcStrategy & strategy);
01440 inline CbcModel * parentModel() const
01441 { return parentModel_;}
01443 inline void setParentModel(CbcModel & parentModel)
01444 { parentModel_ = &parentModel;}
01446
01447
01454 void addHeuristic(CbcHeuristic * generator, const char *name = NULL,
01455 int before=-1);
01457 inline CbcHeuristic * heuristic(int i) const
01458 { return heuristic_[i];}
01460 inline int numberHeuristics() const
01461 { return numberHeuristics_;}
01463 inline CbcHeuristic * lastHeuristic() const
01464 { return lastHeuristic_;}
01466 inline void setLastHeuristic(CbcHeuristic * last)
01467 { lastHeuristic_=last;}
01468
01487 void passInPriorities(const int * priorities, bool ifNotSimpleIntegers);
01488
01490 inline int priority(int sequence) const
01491 { return object_[sequence]->priority();}
01492
01497 void passInEventHandler(const CbcEventHandler *eventHandler) ;
01498
01500 inline CbcEventHandler* getEventHandler() const
01501 { return (eventHandler_) ; }
01502
01504
01514 void setApplicationData (void * appData);
01515
01517 void * getApplicationData() const;
01530 void passInSolverCharacteristics(OsiBabSolver * solverCharacteristics);
01532 inline const OsiBabSolver * solverCharacteristics() const
01533 { return solverCharacteristics_;}
01535
01536
01537
01540
01541 void passInMessageHandler(CoinMessageHandler * handler);
01543 void newLanguage(CoinMessages::Language language);
01544 inline void setLanguage(CoinMessages::Language language)
01545 {newLanguage(language);}
01547 inline CoinMessageHandler * messageHandler() const
01548 {return handler_;}
01550 inline CoinMessages & messages()
01551 {return messages_;}
01553 inline CoinMessages * messagesPointer()
01554 {return &messages_;}
01556 void setLogLevel(int value);
01558 inline int logLevel() const
01559 { return handler_->logLevel();}
01561
01563
01564
01586 inline void setSpecialOptions(int value)
01587 { specialOptions_=value;}
01589 inline int specialOptions() const
01590 { return specialOptions_;}
01592 inline bool normalSolver() const
01593 { return (specialOptions_&16)==0;}
01601 inline void setMoreSpecialOptions(int value)
01602 { moreSpecialOptions_=value;}
01604 inline int moreSpecialOptions() const
01605 { return moreSpecialOptions_;}
01607 inline bool ownObjects() const
01608 { return ownObjects_;}
01610 void checkModel();
01612 inline void * mutex()
01613 { return mutex_;}
01615 int splitModel(int numberModels, CbcModel ** model,
01616 int numberNodes);
01618 void startSplitModel(int numberIterations);
01620 void mergeModels(int numberModel, CbcModel ** model,
01621 int numberNodes);
01623
01624
01626
01627
01628 CbcModel();
01629
01631 CbcModel(const OsiSolverInterface &);
01632
01641 void assignSolver(OsiSolverInterface *&solver,bool deleteSolver=true);
01642
01654 inline void setModelOwnsSolver (bool ourSolver)
01655 { ownership_ = ourSolver ? (ownership_ |0x80000000) : (ownership_ & (~0x80000000)) ; }
01656
01662 inline bool modelOwnsSolver () { return ((ownership_&0x80000000)!=0) ; }
01663
01667 CbcModel(const CbcModel & rhs, bool cloneHandler=false);
01668
01670 CbcModel & operator=(const CbcModel& rhs);
01671
01673 ~CbcModel ();
01674
01676 inline OsiSolverInterface * solver() const
01677 { return solver_;}
01678
01680 inline OsiSolverInterface * swapSolver(OsiSolverInterface * solver)
01681 { OsiSolverInterface * returnSolver = solver_; solver_ = solver; return returnSolver;}
01682
01684 inline OsiSolverInterface * continuousSolver() const
01685 { return continuousSolver_;}
01686
01688 inline void createContinuousSolver()
01689 { continuousSolver_ = solver_->clone();}
01691 inline void clearContinuousSolver()
01692 { delete continuousSolver_; continuousSolver_ = NULL;}
01693
01695 inline OsiSolverInterface * referenceSolver() const
01696 { return referenceSolver_;}
01697
01699 void saveReferenceSolver();
01700
01706 void resetToReferenceSolver();
01707
01709 void gutsOfDestructor();
01712 void gutsOfDestructor2();
01715 void resetModel();
01721 void gutsOfCopy(const CbcModel & rhs,int mode=0);
01723 void moveInfo(const CbcModel & rhs);
01725
01727
01728
01729 int getNodeCount2() const
01730 { return numberNodes2_;}
01732 void setPointers(const OsiSolverInterface * solver);
01738 int reducedCostFix() ;
01742 void synchronizeHandlers(int makeDefault);
01744 void saveExtraSolution(const double * solution, double objectiveValue);
01746 void saveBestSolution(const double * solution, double objectiveValue);
01748 void deleteSolutions();
01750 int resolve(OsiSolverInterface * solver);
01751
01755 int chooseBranch(CbcNode * & newNode, int numberPassesLeft,
01756 CbcNode * oldNode, OsiCuts & cuts,
01757 bool & resolved, CoinWarmStartBasis *lastws,
01758 const double * lowerBefore,const double * upperBefore,
01759 OsiSolverBranch * & branches);
01760 int chooseBranch(CbcNode * newNode, int numberPassesLeft, bool & resolved);
01761
01768 CoinWarmStartBasis *getEmptyBasis(int ns = 0, int na = 0) const ;
01769
01781 int takeOffCuts(OsiCuts &cuts,
01782 bool allowResolve,OsiCuts * saveCuts,
01783 int numberNewCuts=0, const OsiRowCut ** newCuts=NULL) ;
01784
01798 int addCuts(CbcNode * node, CoinWarmStartBasis *&lastws,bool canFix);
01799
01816 bool addCuts1(CbcNode * node, CoinWarmStartBasis *&lastws);
01820 void previousBounds (CbcNode * node, CbcNodeInfo * where,int iColumn,
01821 double & lower, double & upper,int force);
01826 void setObjectiveValue(CbcNode * thisNode, const CbcNode * parentNode) const;
01827
01831 void convertToDynamic();
01833 void synchronizeNumberBeforeTrust(int type=0);
01835 void zapIntegerInformation(bool leaveObjects=true);
01837 int cliquePseudoCosts(int doStatistics);
01839 void pseudoShadow(int type);
01846 void fillPseudoCosts(double * downCosts, double * upCosts,
01847 int * priority=NULL,
01848 int * numberDown=NULL, int * numberUp=NULL,
01849 int * numberDownInfeasible=NULL,
01850 int * numberUpInfeasible=NULL) const;
01856 void doHeuristicsAtRoot(int deleteHeuristicsAfterwards=0);
01858 void adjustHeuristics();
01860 inline const double * hotstartSolution() const
01861 { return hotstartSolution_;}
01863 inline const int * hotstartPriorities() const
01864 { return hotstartPriorities_;}
01865
01867 inline CbcCountRowCut ** addedCuts() const
01868 { return addedCuts_;}
01870 inline int currentNumberCuts() const
01871 { return currentNumberCuts_;}
01873 inline OsiCuts * globalCuts()
01874 { return &globalCuts_;}
01876 void setNextRowCut(const OsiRowCut & cut);
01878 inline CbcNode * currentNode() const
01879 { return currentNode_;}
01881 inline CglTreeProbingInfo * probingInfo() const
01882 { return probingInfo_;}
01884 inline CoinThreadRandom * randomNumberGenerator()
01885 { return &randomNumberGenerator_;}
01887 inline void setNumberStrongIterations(int number)
01888 { numberStrongIterations_ = number;}
01890 inline int numberStrongIterations() const
01891 { return numberStrongIterations_;}
01893 inline int maximumNumberIterations() const
01894 { return maximumNumberIterations_;}
01896 inline void setMaximumNumberIterations(int value)
01897 { maximumNumberIterations_ = value;}
01898 # ifdef COIN_HAS_CLP
01899
01900 inline void setFastNodeDepth(int value)
01901 { fastNodeDepth_ = value;}
01903 inline int fastNodeDepth() const
01904 { return fastNodeDepth_;}
01906 inline int continuousPriority() const
01907 { return continuousPriority_;}
01909 inline void setContinuousPriority(int value)
01910 { continuousPriority_=value;}
01911 inline void incrementExtra(int nodes, int iterations)
01912 { numberExtraNodes_ += nodes; numberExtraIterations_ += iterations;}
01913 #endif
01914
01915 inline int numberExtraIterations() const
01916 { return numberExtraIterations_;}
01918 void incrementStrongInfo(int numberTimes, int numberIterations,
01919 int numberFixed, bool ifInfeasible);
01921 inline const int * strongInfo() const
01922 { return strongInfo_;}
01923
01925 inline int * mutableStrongInfo()
01926 { return strongInfo_;}
01927
01929 inline bool allDynamic () const { return ((ownership_&0x40000000)!=0) ; }
01931 void generateCpp( FILE * fp,int options);
01933 OsiBranchingInformation usefulInformation() const;
01940 inline void setBestSolutionBasis(const CoinWarmStartBasis & bestSolutionBasis)
01941 { bestSolutionBasis_ = bestSolutionBasis;}
01943 void redoWalkBack();
01945
01946
01947
01948 private:
01950
01951
01953 OsiSolverInterface * solver_;
01954
01960 unsigned int ownership_ ;
01961
01963 OsiSolverInterface * continuousSolver_;
01964
01966 OsiSolverInterface * referenceSolver_;
01967
01969 CoinMessageHandler * handler_;
01970
01976 bool defaultHandler_;
01977
01979 CoinMessages messages_;
01980
01982 int intParam_[CbcLastIntParam];
01983
01985 double dblParam_[CbcLastDblParam];
01986
01995 mutable CoinWarmStart *emptyWarmStart_ ;
01996
01998 double bestObjective_;
02000 double bestPossibleObjective_;
02002 double sumChangeObjective1_;
02004 double sumChangeObjective2_;
02005
02007 double * bestSolution_;
02009 double ** savedSolutions_;
02010
02015 double * currentSolution_;
02019 mutable const double * testSolution_;
02026 CoinWarmStartBasis bestSolutionBasis_ ;
02028 OsiCuts globalCuts_;
02029
02031 double minimumDrop_;
02033 int numberSolutions_;
02035 int numberSavedSolutions_;
02037 int maximumSavedSolutions_;
02044 int stateOfSearch_;
02046 int whenCuts_;
02048 double * hotstartSolution_;
02050 int * hotstartPriorities_;
02052 int numberHeuristicSolutions_;
02054 int numberNodes_;
02058 int numberNodes2_;
02060 int numberIterations_;
02062 int numberSolves_;
02064 int status_;
02075 int secondaryStatus_;
02077 int numberIntegers_;
02079 int numberRowsAtContinuous_;
02081 int maximumNumberCuts_;
02090 int phase_;
02091
02093 int currentNumberCuts_;
02094
02099 int maximumDepth_;
02105 CbcNodeInfo ** walkback_;
02106 CbcNodeInfo ** lastNodeInfo_;
02107 const OsiRowCut ** lastCut_;
02108 int lastDepth_;
02109 int lastNumberCuts2_;
02110 int maximumCuts_;
02111 int * lastNumberCuts_;
02112
02120 CbcCountRowCut ** addedCuts_;
02121
02125 OsiRowCut * nextRowCut_;
02126
02128 CbcNode * currentNode_;
02129
02131 int * integerVariable_;
02133 char * integerInfo_;
02135 double * continuousSolution_;
02137 int * usedInSolution_;
02159 int specialOptions_;
02163 int moreSpecialOptions_;
02165 CbcCompareBase * nodeCompare_;
02167 CbcFeasibilityBase * problemFeasibility_;
02169 CbcTree * tree_;
02171 CbcModel * subTreeModel_;
02173 int numberStoppedSubTrees_;
02175 CbcBranchDecision * branchingMethod_;
02177 CbcCutModifier * cutModifier_;
02179 CbcStrategy * strategy_;
02181 CbcModel * parentModel_;
02187
02188 const double * cbcColLower_;
02190 const double * cbcColUpper_;
02192 const double * cbcRowLower_;
02194 const double * cbcRowUpper_;
02196 const double * cbcColSolution_;
02198 const double * cbcRowPrice_;
02200 const double * cbcReducedCost_;
02202 const double * cbcRowActivity_;
02204 void * appData_;
02206 void * mutex_;
02208 int presolve_;
02212 int numberStrong_;
02218 int numberBeforeTrust_;
02222 int numberPenalties_;
02224 int stopNumberIterations_;
02227 double penaltyScaleFactor_;
02229 int numberAnalyzeIterations_;
02231 double * analyzeResults_;
02233 int numberInfeasibleNodes_;
02240 int problemType_;
02242 int printFrequency_;
02244 int numberCutGenerators_;
02245
02246 CbcCutGenerator ** generator_;
02247
02248 CbcCutGenerator ** virginGenerator_;
02250 int numberHeuristics_;
02252 CbcHeuristic ** heuristic_;
02254 CbcHeuristic * lastHeuristic_;
02255 # ifdef COIN_HAS_CLP
02256
02257 int fastNodeDepth_;
02258 #endif
02259
02260 # ifdef CBC_ONLY_CLP
02261 ClpEventHandler *eventHandler_ ;
02262 # else
02263 CbcEventHandler *eventHandler_ ;
02264 # endif
02265
02267 int numberObjects_;
02268
02279 OsiObject ** object_;
02281 bool ownObjects_;
02282
02284 int * originalColumns_;
02286 int howOftenGlobalScan_;
02289 int numberGlobalViolations_;
02291 int numberExtraIterations_;
02293 int numberExtraNodes_;
02297 double continuousObjective_;
02300 double originalContinuousObjective_;
02302 int continuousInfeasibilities_;
02304 int maximumCutPassesAtRoot_;
02306 int maximumCutPasses_;
02308 int preferredWay_;
02310 int currentPassNumber_;
02312 int maximumWhich_;
02314 int maximumRows_;
02316 int currentDepth_;
02318 mutable CoinThreadRandom randomNumberGenerator_;
02320 CoinWarmStartBasis workingBasis_;
02322 int * whichGenerator_;
02324 int maximumStatistics_;
02326 CbcStatistics ** statistics_;
02328 int maximumDepthActual_;
02330 double numberDJFixed_;
02332 CglTreeProbingInfo * probingInfo_;
02334 int numberFixedAtRoot_;
02336 int numberFixedNow_;
02338 bool stoppedOnGap_;
02340 mutable bool eventHappened_;
02342 int numberLongStrong_;
02344 int numberOldActiveCuts_;
02346 int numberNewCuts_;
02348 int searchStrategy_;
02350 int numberStrongIterations_;
02353 int strongInfo_[7];
02360 OsiBabSolver * solverCharacteristics_;
02362 bool resolveAfterTakeOffCuts_;
02364 int maximumNumberIterations_;
02366 int continuousPriority_;
02368 int numberUpdateItems_;
02370 int maximumNumberUpdateItems_;
02372 CbcObjectUpdateData * updateItems_;
02380 int numberThreads_;
02388 int threadMode_;
02390 };
02392 void getIntegerInformation(const OsiObject * object, double & originalLower,
02393 double & originalUpper) ;
02394
02395
02396 class OsiClpSolverInterface;
02397 int CbcMain (int argc, const char *argv[],OsiClpSolverInterface & solver,CbcModel ** babSolver);
02398 int CbcMain (int argc, const char *argv[],CbcModel & babSolver);
02399
02400 int callCbc(const char * input2, OsiClpSolverInterface& solver1);
02401 int callCbc(const char * input2);
02402 int callCbc(const std::string input2, OsiClpSolverInterface& solver1);
02403 int callCbc(const std::string input2) ;
02404
02405 void CbcMain0 (CbcModel & babSolver);
02406 int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver);
02407
02408 int callCbc(const char * input2, CbcModel & babSolver);
02409 int callCbc(const std::string input2, CbcModel & babSolver);
02410
02411 int callCbc1(const char * input2, CbcModel & babSolver);
02412 int callCbc1(const std::string input2, CbcModel & babSolver);
02413
02414 int callCbc1(const char * input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02415 int callCbc1(const std::string input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02416 int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02417
02418 void setCutAndHeuristicOptions(CbcModel & model);
02419 #endif