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;
00285 #if 0
00286 int whileIterating(bool & locked, threadId, threadInfo,condition_mutex,condition_main,
00287 timeWaiting,threadModel,threadStats,totalTime,cutoff,
00288 eventHandler,saveCompare,lastDepth,lastUnsatisfied,createdNode);
00289 #else
00290 int whileIterating(int numberIterations);
00291 #endif
00292 #ifdef CBC_THREAD
00293
00297 void lockThread();
00301 void unlockThread();
00302 #else
00303 inline void lockThread() {}
00304 inline void unlockThread() {}
00305 #endif
00306 private:
00313 void moveToModel(CbcModel * baseModel,int mode);
00314 public:
00328 int resolve(CbcNodeInfo * parent, int whereFrom);
00330 void makeGlobalCuts(int numberRows,const int * which);
00332 void makeGlobalCut(const OsiRowCut * cut);
00334 void makeGlobalCut(const OsiRowCut & cut);
00336
00339
00351 CbcModel * findCliques(bool makeEquality, int atLeastThisMany,
00352 int lessThanThis, int defaultValue=1000);
00353
00362 CbcModel * integerPresolve(bool weak=false);
00363
00368 bool integerPresolveThisModel(OsiSolverInterface * originalSolver,bool weak=false);
00369
00370
00372 void originalModel(CbcModel * presolvedModel,bool weak);
00373
00394 bool tightenVubs(int type,bool allowMultipleBinary=false,
00395 double useCutoff=1.0e50);
00396
00402 bool tightenVubs(int numberVubs, const int * which,
00403 double useCutoff=1.0e50);
00407 void analyzeObjective();
00408
00409
00411
00417
00419 inline int numberObjects() const { return numberObjects_;}
00421 inline void setNumberObjects(int number)
00422 { numberObjects_=number;}
00423
00425 inline OsiObject ** objects() const { return object_;}
00426
00428 const inline OsiObject * object(int which) const { return object_[which];}
00430 inline OsiObject * modifiableObject(int which) const { return object_[which];}
00431
00433 void deleteObjects(bool findIntegers=true);
00434
00439 void addObjects(int numberObjects, OsiObject ** objects);
00440
00445 void addObjects(int numberObjects, CbcObject ** objects);
00446
00448 void synchronizeModel() ;
00449
00459 void findIntegers(bool startAgain,int type=0);
00460
00462
00463
00464
00474
00475 inline bool setIntParam(CbcIntParam key, int value) {
00476 intParam_[key] = value;
00477 return true;
00478 }
00480 inline bool setDblParam(CbcDblParam key, double value) {
00481 dblParam_[key] = value;
00482 return true;
00483 }
00485 inline int getIntParam(CbcIntParam key) const {
00486 return intParam_[key];
00487 }
00489 inline double getDblParam(CbcDblParam key) const {
00490 return dblParam_[key];
00491 }
00497 void setCutoff(double value) ;
00498
00500 inline double getCutoff() const
00501 {
00502
00503
00504 return dblParam_[CbcCurrentCutoff];
00505 }
00506
00508 inline bool setMaximumNodes( int value)
00509 { return setIntParam(CbcMaxNumNode,value); }
00510
00512 inline int getMaximumNodes() const
00513 { return getIntParam(CbcMaxNumNode); }
00514
00519 inline bool setMaximumSolutions( int value) {
00520 return setIntParam(CbcMaxNumSol,value);
00521 }
00526 inline int getMaximumSolutions() const {
00527 return getIntParam(CbcMaxNumSol);
00528 }
00530 inline bool setPrintingMode( int value)
00531 { return setIntParam(CbcPrinting,value); }
00532
00534 inline int getPrintingMode() const
00535 { return getIntParam(CbcPrinting); }
00536
00541 inline bool setMaximumSeconds( double value) {
00542 return setDblParam(CbcMaximumSeconds,value);
00543 }
00548 inline double getMaximumSeconds() const {
00549 return getDblParam(CbcMaximumSeconds);
00550 }
00552 double getCurrentSeconds() const ;
00553
00557 inline bool setIntegerTolerance( double value) {
00558 return setDblParam(CbcIntegerTolerance,value);
00559 }
00563 inline double getIntegerTolerance() const {
00564 return getDblParam(CbcIntegerTolerance);
00565 }
00566
00571 inline bool setInfeasibilityWeight( double value) {
00572 return setDblParam(CbcInfeasibilityWeight,value);
00573 }
00578 inline double getInfeasibilityWeight() const {
00579 return getDblParam(CbcInfeasibilityWeight);
00580 }
00581
00585 inline bool setAllowableGap( double value) {
00586 return setDblParam(CbcAllowableGap,value);
00587 }
00591 inline double getAllowableGap() const {
00592 return getDblParam(CbcAllowableGap);
00593 }
00594
00598 inline bool setAllowableFractionGap( double value) {
00599 return setDblParam(CbcAllowableFractionGap,value);
00600 }
00604 inline double getAllowableFractionGap() const {
00605 return getDblParam(CbcAllowableFractionGap);
00606 }
00610 inline bool setAllowablePercentageGap( double value) {
00611 return setDblParam(CbcAllowableFractionGap,value*0.01);
00612 }
00616 inline double getAllowablePercentageGap() const {
00617 return 100.0*getDblParam(CbcAllowableFractionGap);
00618 }
00623 inline bool setCutoffIncrement( double value) {
00624 return setDblParam(CbcCutoffIncrement,value);
00625 }
00630 inline double getCutoffIncrement() const {
00631 return getDblParam(CbcCutoffIncrement);
00632 }
00633
00638 void setHotstartSolution(const double * solution, const int * priorities=NULL) ;
00639
00641 inline void setMinimumDrop(double value)
00642 {minimumDrop_=value;}
00644 inline double getMinimumDrop() const
00645 { return minimumDrop_;}
00646
00649 inline void setMaximumCutPassesAtRoot(int value)
00650 {maximumCutPassesAtRoot_=value;}
00652 inline int getMaximumCutPassesAtRoot() const
00653 { return maximumCutPassesAtRoot_;}
00654
00657 inline void setMaximumCutPasses(int value)
00658 {maximumCutPasses_=value;}
00660 inline int getMaximumCutPasses() const
00661 { return maximumCutPasses_;}
00664 inline int getCurrentPassNumber() const
00665 { return currentPassNumber_;}
00666
00672 void setNumberStrong(int number);
00676 inline int numberStrong() const
00677 { return numberStrong_;}
00680 inline void setPreferredWay(int value)
00681 {preferredWay_=value;}
00683 inline int getPreferredWay() const
00684 { return preferredWay_;}
00688 inline void setSizeMiniTree(int value)
00689 { sizeMiniTree_=value;}
00690 inline int sizeMiniTree() const
00691 { return sizeMiniTree_;}
00692
00698 void setNumberBeforeTrust(int number);
00701 inline int numberBeforeTrust() const
00702 { return numberBeforeTrust_;}
00708 void setNumberPenalties(int number);
00711 inline int numberPenalties() const
00712 { return numberPenalties_;}
00714 inline void setNumberAnalyzeIterations(int number)
00715 { numberAnalyzeIterations_=number;}
00716 inline int numberAnalyzeIterations() const
00717 { return numberAnalyzeIterations_;}
00720 inline double penaltyScaleFactor() const
00721 { return penaltyScaleFactor_;}
00724 void setPenaltyScaleFactor(double value);
00732 void inline setProblemType(int number)
00733 { problemType_=number;}
00734 inline int problemType() const
00735 { return problemType_;}
00736
00738 void setHowOftenGlobalScan(int number);
00740 inline int howOftenGlobalScan() const
00741 { return howOftenGlobalScan_;}
00743 inline int * originalColumns() const
00744 { return originalColumns_;}
00746 void setOriginalColumns(const int * originalColumns) ;
00747
00755 inline void setPrintFrequency(int number)
00756 { printFrequency_=number;}
00758 inline int printFrequency() const
00759 { return printFrequency_;}
00761
00762
00764
00765
00766 bool isAbandoned() const;
00768 bool isProvenOptimal() const;
00770 bool isProvenInfeasible() const;
00772 bool isContinuousUnbounded() const;
00774 bool isProvenDualInfeasible() const;
00776 bool isNodeLimitReached() const;
00778 bool isSecondsLimitReached() const;
00780 bool isSolutionLimitReached() const;
00782 inline int getIterationCount() const
00783 { return numberIterations_;}
00785 inline int getNodeCount() const
00786 { return numberNodes_;}
00796 inline int status() const
00797 { return status_;}
00798 inline void setProblemStatus(int value)
00799 { status_=value;}
00811 inline int secondaryStatus() const
00812 { return secondaryStatus_;}
00813 inline void setSecondaryStatus(int value)
00814 { secondaryStatus_=value;}
00816 bool isInitialSolveAbandoned() const ;
00818 bool isInitialSolveProvenOptimal() const ;
00820 bool isInitialSolveProvenPrimalInfeasible() const ;
00822 bool isInitialSolveProvenDualInfeasible() const ;
00823
00825
00826
00839
00840 inline int numberRowsAtContinuous() const
00841 { return numberRowsAtContinuous_;}
00842
00844 inline int getNumCols() const
00845 { return solver_->getNumCols();}
00846
00848 inline int getNumRows() const
00849 { return solver_->getNumRows();}
00850
00852 inline CoinBigIndex getNumElements() const
00853 { return solver_->getNumElements();}
00854
00856 inline int numberIntegers() const
00857 { return numberIntegers_;}
00858
00859 inline const int * integerVariable() const
00860 { return integerVariable_;}
00862 inline char integerType(int i) const
00863 { return integerInfo_[i];}
00865 inline const char * integerType() const
00866 { return integerInfo_;}
00867
00869 inline const double * getColLower() const
00870 { return solver_->getColLower();}
00871
00873 inline const double * getColUpper() const
00874 { return solver_->getColUpper();}
00875
00885 inline const char * getRowSense() const
00886 { return solver_->getRowSense();}
00887
00896 inline const double * getRightHandSide() const
00897 { return solver_->getRightHandSide();}
00898
00907 inline const double * getRowRange() const
00908 { return solver_->getRowRange();}
00909
00911 inline const double * getRowLower() const
00912 { return solver_->getRowLower();}
00913
00915 inline const double * getRowUpper() const
00916 { return solver_->getRowUpper();}
00917
00919 inline const double * getObjCoefficients() const
00920 { return solver_->getObjCoefficients();}
00921
00923 inline double getObjSense() const
00924 {
00925
00926 return dblParam_[CbcOptimizationDirection];}
00927
00929 inline bool isContinuous(int colIndex) const
00930 { return solver_->isContinuous(colIndex);}
00931
00933 inline bool isBinary(int colIndex) const
00934 { return solver_->isBinary(colIndex);}
00935
00940 inline bool isInteger(int colIndex) const
00941 { return solver_->isInteger(colIndex);}
00942
00944 inline bool isIntegerNonBinary(int colIndex) const
00945 { return solver_->isIntegerNonBinary(colIndex);}
00946
00948 inline bool isFreeBinary(int colIndex) const
00949 { return solver_->isFreeBinary(colIndex) ;}
00950
00952 inline const CoinPackedMatrix * getMatrixByRow() const
00953 { return solver_->getMatrixByRow();}
00954
00956 inline const CoinPackedMatrix * getMatrixByCol() const
00957 { return solver_->getMatrixByCol();}
00958
00960 inline double getInfinity() const
00961 { return solver_->getInfinity();}
00963 inline const double * getCbcColLower() const
00964 { return cbcColLower_;}
00966 inline const double * getCbcColUpper() const
00967 { return cbcColUpper_;}
00969 inline const double * getCbcRowLower() const
00970 { return cbcRowLower_;}
00972 inline const double * getCbcRowUpper() const
00973 { return cbcRowUpper_;}
00975 inline const double * getCbcColSolution() const
00976 { return cbcColSolution_;}
00978 inline const double * getCbcRowPrice() const
00979 { return cbcRowPrice_;}
00981 inline const double * getCbcReducedCost() const
00982 { return cbcReducedCost_;}
00984 inline const double * getCbcRowActivity() const
00985 { return cbcRowActivity_;}
00987
00988
00991
00992 inline double * continuousSolution() const
00993 { return continuousSolution_;}
00998 inline int * usedInSolution() const
00999 { return usedInSolution_;}
01001 void incrementUsed(const double * solution);
01003 void setBestSolution(CBC_Message how,
01004 double & objectiveValue, const double *solution,
01005 bool fixVariables=false);
01007 void setBestObjectiveValue( double objectiveValue);
01008
01015 double checkSolution(double cutoff, double * solution,
01016 bool fixVariables, double originalObjValue);
01023 bool feasibleSolution(int & numberIntegerInfeasibilities,
01024 int & numberObjectInfeasibilities) const;
01025
01031 inline double * currentSolution() const
01032 { return currentSolution_;}
01036 inline const double * testSolution() const
01037 { return testSolution_;}
01038 inline void setTestSolution(const double * solution)
01039 { testSolution_ = solution;}
01041 void reserveCurrentSolution(const double * solution=NULL);
01042
01044 inline const double * getColSolution() const
01045 { return solver_->getColSolution();}
01046
01048 inline const double * getRowPrice() const
01049 { return solver_->getRowPrice();}
01050
01052 inline const double * getReducedCost() const
01053 { return solver_->getReducedCost();}
01054
01056 inline const double * getRowActivity() const
01057 { return solver_->getRowActivity();}
01058
01060 inline double getCurrentObjValue() const
01061 { return dblParam_[CbcCurrentObjectiveValue]; }
01063 inline double getCurrentMinimizationObjValue() const
01064 { return dblParam_[CbcCurrentMinimizationObjectiveValue];}
01065
01067 inline double getMinimizationObjValue() const
01068 { return bestObjective_;}
01070 inline void setMinimizationObjValue(double value)
01071 { bestObjective_=value;}
01072
01074 inline double getObjValue() const
01075 { return bestObjective_ * solver_->getObjSense() ; }
01081 double getBestPossibleObjValue() const;
01083 inline void setObjValue(double value)
01084 { bestObjective_=value * solver_->getObjSense() ;}
01085
01092 inline double * bestSolution() const
01093 { return bestSolution_;}
01094 void setBestSolution(const double * solution,int numberColumns,double objectiveValue);
01095
01097 inline int getSolutionCount() const
01098 { return numberSolutions_;}
01099
01101 inline void setSolutionCount(int value)
01102 { numberSolutions_=value;}
01111 inline int phase() const
01112 { return phase_;}
01113
01115 inline int getNumberHeuristicSolutions() const { return numberHeuristicSolutions_;}
01117 inline void setNumberHeuristicSolutions(int value) { numberHeuristicSolutions_=value;}
01118
01120 inline void setObjSense(double s) { dblParam_[CbcOptimizationDirection]=s;
01121 solver_->setObjSense(s);}
01122
01124 inline double getContinuousObjective() const
01125 { return originalContinuousObjective_;}
01126 inline void setContinuousObjective(double value)
01127 { originalContinuousObjective_=value;}
01129 inline int getContinuousInfeasibilities() const
01130 { return continuousInfeasibilities_;}
01131 inline void setContinuousInfeasibilities(int value)
01132 { continuousInfeasibilities_=value;}
01134 inline double rootObjectiveAfterCuts() const
01135 { return continuousObjective_;}
01137 inline double sumChangeObjective() const
01138 { return sumChangeObjective1_;}
01141 inline int numberGlobalViolations() const
01142 { return numberGlobalViolations_;}
01143 inline void clearNumberGlobalViolations()
01144 { numberGlobalViolations_=0;}
01146 inline bool resolveAfterTakeOffCuts() const
01147 { return resolveAfterTakeOffCuts_;}
01148 inline void setResolveAfterTakeOffCuts(bool yesNo)
01149 { resolveAfterTakeOffCuts_=yesNo;}
01151 inline int maximumRows() const
01152 { return maximumRows_;}
01154 inline CoinWarmStartBasis & workingBasis()
01155 { return workingBasis_;}
01157 inline int getNumberThreads() const
01158 { return numberThreads_;}
01160 inline void setNumberThreads(int value)
01161 { numberThreads_=value;}
01163 inline int getThreadMode() const
01164 { return threadMode_;}
01171 inline void setThreadMode(int value)
01172 { threadMode_=value;}
01174 inline int getStopNumberIterations() const
01175 { return stopNumberIterations_;}
01177 inline void setStopNumberIterations(int value)
01178 { stopNumberIterations_=value;}
01180
01183
01184 inline CbcCompareBase * nodeComparison() const
01185 { return nodeCompare_;}
01186 void setNodeComparison(CbcCompareBase * compare);
01187 void setNodeComparison(CbcCompareBase & compare);
01189
01192
01193 inline CbcFeasibilityBase * problemFeasibility() const
01194 { return problemFeasibility_;}
01195 void setProblemFeasibility(CbcFeasibilityBase * feasibility);
01196 void setProblemFeasibility(CbcFeasibilityBase & feasibility);
01198
01201
01202 inline CbcTree * tree() const
01203 { return tree_;}
01205 void passInTreeHandler(CbcTree & tree);
01209 void passInSubTreeModel(CbcModel & model);
01214 CbcModel * subTreeModel(OsiSolverInterface * solver=NULL) const;
01216 inline int numberStoppedSubTrees() const
01217 { return numberStoppedSubTrees_;}
01219 inline void incrementSubTreeStopped()
01220 { numberStoppedSubTrees_++;}
01226 inline int typePresolve() const
01227 { return presolve_;}
01228 inline void setTypePresolve(int value)
01229 { presolve_=value;}
01230
01232
01238
01240 inline CbcBranchDecision * branchingMethod() const
01241 { return branchingMethod_;}
01243 inline void setBranchingMethod(CbcBranchDecision * method)
01244 { delete branchingMethod_; branchingMethod_ = method->clone();}
01249 inline void setBranchingMethod(CbcBranchDecision & method)
01250 { delete branchingMethod_; branchingMethod_ = method.clone();}
01252 inline CbcCutModifier * cutModifier() const
01253 { return cutModifier_;}
01255 void setCutModifier(CbcCutModifier * modifier);
01260 void setCutModifier(CbcCutModifier & modifier);
01262
01265
01272 inline int stateOfSearch() const
01273 { return stateOfSearch_;}
01274 inline void setStateOfSearch(int state)
01275 { stateOfSearch_=state;}
01277 inline int searchStrategy() const
01278 { return searchStrategy_;}
01280 inline void setSearchStrategy(int value)
01281 { searchStrategy_ = value; }
01282
01284 inline int numberCutGenerators() const
01285 { return numberCutGenerators_;}
01287 inline CbcCutGenerator ** cutGenerators() const
01288 { return generator_;}
01290 inline CbcCutGenerator * cutGenerator(int i) const
01291 { return generator_[i];}
01293 inline CbcCutGenerator * virginCutGenerator(int i) const
01294 { return virginGenerator_[i];}
01303 void addCutGenerator(CglCutGenerator * generator,
01304 int howOften=1, const char * name=NULL,
01305 bool normal=true, bool atSolution=false,
01306 bool infeasible=false,int howOftenInSub=-100,
01307 int whatDepth=-1, int whatDepthInSub=-1);
01309
01314
01316 inline CbcStrategy * strategy() const
01317 { return strategy_;}
01319 void setStrategy(CbcStrategy & strategy);
01321 inline CbcModel * parentModel() const
01322 { return parentModel_;}
01324 inline void setParentModel(CbcModel & parentModel)
01325 { parentModel_ = &parentModel;}
01327
01328
01335 void addHeuristic(CbcHeuristic * generator, const char *name = NULL);
01337 inline CbcHeuristic * heuristic(int i) const
01338 { return heuristic_[i];}
01340 inline int numberHeuristics() const
01341 { return numberHeuristics_;}
01343 inline CbcHeuristic * lastHeuristic() const
01344 { return lastHeuristic_;}
01346 inline void setLastHeuristic(CbcHeuristic * last)
01347 { lastHeuristic_=last;}
01348
01367 void passInPriorities(const int * priorities, bool ifNotSimpleIntegers);
01368
01370 inline int priority(int sequence) const
01371 { return object_[sequence]->priority();}
01372
01377 void passInEventHandler(const CbcEventHandler *eventHandler) ;
01378
01380 inline CbcEventHandler* getEventHandler() const
01381 { return (eventHandler_) ; }
01382
01384
01394 void setApplicationData (void * appData);
01395
01397 void * getApplicationData() const;
01410 void passInSolverCharacteristics(OsiBabSolver * solverCharacteristics);
01412 inline const OsiBabSolver * solverCharacteristics() const
01413 { return solverCharacteristics_;}
01415
01416
01417
01420
01421 void passInMessageHandler(CoinMessageHandler * handler);
01423 void newLanguage(CoinMessages::Language language);
01424 inline void setLanguage(CoinMessages::Language language)
01425 {newLanguage(language);}
01427 inline CoinMessageHandler * messageHandler() const
01428 {return handler_;}
01430 inline CoinMessages & messages()
01431 {return messages_;}
01433 inline CoinMessages * messagesPointer()
01434 {return &messages_;}
01436 void setLogLevel(int value);
01438 inline int logLevel() const
01439 { return handler_->logLevel();}
01441
01443
01444
01455
01456 inline void setSpecialOptions(int value)
01457 { specialOptions_=value;}
01459 inline int specialOptions() const
01460 { return specialOptions_;}
01462 inline bool normalSolver() const
01463 { return (specialOptions_&16)==0;}
01465 inline bool ownObjects() const
01466 { return ownObjects_;}
01468 inline void * mutex()
01469 { return mutex_;}
01471 int splitModel(int numberModels, CbcModel ** model,
01472 int numberNodes);
01474 void startSplitModel(int numberIterations);
01476 void mergeModels(int numberModel, CbcModel ** model,
01477 int numberNodes);
01479
01480
01482
01483
01484 CbcModel();
01485
01487 CbcModel(const OsiSolverInterface &);
01488
01497 void assignSolver(OsiSolverInterface *&solver,bool deleteSolver=true);
01498
01510 inline void setModelOwnsSolver (bool ourSolver)
01511 { ownership_ = ourSolver ? (ownership_ |0x80000000) : (ownership_ & (~0x80000000)) ; }
01512
01518 inline bool modelOwnsSolver () { return ((ownership_&0x80000000)!=0) ; }
01519
01523 CbcModel(const CbcModel & rhs, bool noTree=false);
01524
01526 CbcModel & operator=(const CbcModel& rhs);
01527
01529 ~CbcModel ();
01530
01532 inline OsiSolverInterface * solver() const
01533 { return solver_;}
01534
01536 inline OsiSolverInterface * swapSolver(OsiSolverInterface * solver)
01537 { OsiSolverInterface * returnSolver = solver_; solver_ = solver; return returnSolver;}
01538
01540 inline OsiSolverInterface * continuousSolver() const
01541 { return continuousSolver_;}
01542
01544 inline void createContinuousSolver()
01545 { continuousSolver_ = solver_->clone();}
01547 inline void clearContinuousSolver()
01548 { delete continuousSolver_; continuousSolver_ = NULL;}
01549
01551 inline OsiSolverInterface * referenceSolver() const
01552 { return referenceSolver_;}
01553
01555 void saveReferenceSolver();
01556
01562 void resetToReferenceSolver();
01563
01565 void gutsOfDestructor();
01568 void gutsOfDestructor2();
01571 void resetModel();
01573 void moveInfo(const CbcModel & rhs);
01575
01577
01578
01579 int getNodeCount2() const
01580 { return numberNodes2_;}
01582 void setPointers(const OsiSolverInterface * solver);
01588 int reducedCostFix() ;
01590 int resolve(OsiSolverInterface * solver);
01591
01595 int chooseBranch(CbcNode * newNode, int numberPassesLeft,
01596 CbcNode * oldNode, OsiCuts & cuts,
01597 bool & resolved, CoinWarmStartBasis *lastws,
01598 const double * lowerBefore,const double * upperBefore,
01599 OsiSolverBranch * & branches);
01600 int chooseBranch(CbcNode * newNode, int numberPassesLeft, bool & resolved);
01601
01608 CoinWarmStartBasis *getEmptyBasis(int ns = 0, int na = 0) const ;
01609
01619 void takeOffCuts(OsiCuts &cuts,
01620 bool allowResolve,OsiCuts * saveCuts) ;
01621
01635 int addCuts(CbcNode * node, CoinWarmStartBasis *&lastws,bool canFix);
01636
01651 void addCuts1(CbcNode * node, CoinWarmStartBasis *&lastws);
01655 void previousBounds (CbcNode * node, CbcNodeInfo * where,int iColumn,
01656 double & lower, double & upper,int force);
01661 void setObjectiveValue(CbcNode * thisNode, const CbcNode * parentNode) const;
01662
01666 void convertToDynamic();
01668 void zapIntegerInformation(bool leaveObjects=true);
01670 int cliquePseudoCosts(int doStatistics);
01672 void pseudoShadow(double * down, double * up);
01679 void fillPseudoCosts(double * downCosts, double * upCosts) const;
01685 void doHeuristicsAtRoot(int deleteHeuristicsAfterwards=0);
01687 inline const double * hotstartSolution() const
01688 { return hotstartSolution_;}
01690 inline const int * hotstartPriorities() const
01691 { return hotstartPriorities_;}
01692
01694 inline CbcCountRowCut ** addedCuts() const
01695 { return addedCuts_;}
01697 inline int currentNumberCuts() const
01698 { return currentNumberCuts_;}
01700 inline OsiCuts * globalCuts()
01701 { return &globalCuts_;}
01703 void setNextRowCut(const OsiRowCut & cut);
01705 inline CbcNode * currentNode() const
01706 { return currentNode_;}
01708 inline CglTreeProbingInfo * probingInfo() const
01709 { return probingInfo_;}
01711 inline void setNumberStrongIterations(int number)
01712 { numberStrongIterations_ = number;}
01714 inline int numberStrongIterations() const
01715 { return numberStrongIterations_;}
01717 void incrementStrongInfo(int numberTimes, int numberIterations,
01718 int numberFixed, bool ifInfeasible);
01720 inline bool allDynamic () const { return ((ownership_&0x40000000)!=0) ; }
01722 void generateCpp( FILE * fp,int options);
01724 OsiBranchingInformation usefulInformation() const;
01731 inline void setBestSolutionBasis(const CoinWarmStartBasis & bestSolutionBasis)
01732 { bestSolutionBasis_ = bestSolutionBasis;}
01734
01735
01736
01737 private:
01739
01740
01742 OsiSolverInterface * solver_;
01743
01749 unsigned int ownership_ ;
01750
01752 OsiSolverInterface * continuousSolver_;
01753
01755 OsiSolverInterface * referenceSolver_;
01756
01758 CoinMessageHandler * handler_;
01759
01765 bool defaultHandler_;
01766
01768 CoinMessages messages_;
01769
01771 int intParam_[CbcLastIntParam];
01772
01774 double dblParam_[CbcLastDblParam];
01775
01784 mutable CoinWarmStart *emptyWarmStart_ ;
01785
01787 double bestObjective_;
01789 double bestPossibleObjective_;
01791 double sumChangeObjective1_;
01793 double sumChangeObjective2_;
01794
01796 double * bestSolution_;
01797
01802 double * currentSolution_;
01806 mutable const double * testSolution_;
01813 CoinWarmStartBasis bestSolutionBasis_ ;
01815 OsiCuts globalCuts_;
01816
01818 double minimumDrop_;
01820 int numberSolutions_;
01827 int stateOfSearch_;
01829 double * hotstartSolution_;
01831 int * hotstartPriorities_;
01833 int numberHeuristicSolutions_;
01835 int numberNodes_;
01839 int numberNodes2_;
01841 int numberIterations_;
01843 int status_;
01854 int secondaryStatus_;
01856 int numberIntegers_;
01858 int numberRowsAtContinuous_;
01860 int maximumNumberCuts_;
01869 int phase_;
01870
01872 int currentNumberCuts_;
01873
01878 int maximumDepth_;
01884 CbcNodeInfo ** walkback_;
01885
01893 CbcCountRowCut ** addedCuts_;
01894
01898 OsiRowCut * nextRowCut_;
01899
01901 CbcNode * currentNode_;
01902
01904 int * integerVariable_;
01906 char * integerInfo_;
01908 double * continuousSolution_;
01910 int * usedInSolution_;
01917 int specialOptions_;
01919 CbcCompareBase * nodeCompare_;
01921 CbcFeasibilityBase * problemFeasibility_;
01923 CbcTree * tree_;
01925 CbcModel * subTreeModel_;
01927 int numberStoppedSubTrees_;
01929 CbcBranchDecision * branchingMethod_;
01931 CbcCutModifier * cutModifier_;
01933 CbcStrategy * strategy_;
01935 CbcModel * parentModel_;
01941
01942 const double * cbcColLower_;
01944 const double * cbcColUpper_;
01946 const double * cbcRowLower_;
01948 const double * cbcRowUpper_;
01950 const double * cbcColSolution_;
01952 const double * cbcRowPrice_;
01954 const double * cbcReducedCost_;
01956 const double * cbcRowActivity_;
01958 void * appData_;
01960 void * mutex_;
01962 int presolve_;
01966 int numberStrong_;
01972 int numberBeforeTrust_;
01976 int numberPenalties_;
01978 int stopNumberIterations_;
01981 double penaltyScaleFactor_;
01983 int numberAnalyzeIterations_;
01985 double * analyzeResults_;
01987 int numberInfeasibleNodes_;
01994 int problemType_;
01996 int printFrequency_;
01998 int numberCutGenerators_;
01999
02000 CbcCutGenerator ** generator_;
02001
02002 CbcCutGenerator ** virginGenerator_;
02004 int numberHeuristics_;
02006 CbcHeuristic ** heuristic_;
02008 CbcHeuristic * lastHeuristic_;
02010 # ifdef CBC_ONLY_CLP
02011 ClpEventHandler *eventHandler_ ;
02012 # else
02013 CbcEventHandler *eventHandler_ ;
02014 # endif
02015
02017 int numberObjects_;
02018
02029 OsiObject ** object_;
02031 bool ownObjects_;
02032
02034 int * originalColumns_;
02036 int howOftenGlobalScan_;
02039 int numberGlobalViolations_;
02043 double continuousObjective_;
02046 double originalContinuousObjective_;
02048 int continuousInfeasibilities_;
02050 int maximumCutPassesAtRoot_;
02052 int maximumCutPasses_;
02054 int preferredWay_;
02056 int currentPassNumber_;
02058 int maximumWhich_;
02060 int maximumRows_;
02062 CoinWarmStartBasis workingBasis_;
02064 int * whichGenerator_;
02066 int maximumStatistics_;
02068 CbcStatistics ** statistics_;
02070 int maximumDepthActual_;
02072 double numberDJFixed_;
02074 CglTreeProbingInfo * probingInfo_;
02076 int numberFixedAtRoot_;
02078 int numberFixedNow_;
02080 bool stoppedOnGap_;
02082 bool eventHappened_;
02084 int numberLongStrong_;
02086 int numberOldActiveCuts_;
02088 int numberNewCuts_;
02090 int sizeMiniTree_;
02092 int searchStrategy_;
02094 int numberStrongIterations_;
02096 int strongInfo_[3];
02103 OsiBabSolver * solverCharacteristics_;
02105 bool resolveAfterTakeOffCuts_;
02106 #if NEW_UPDATE_OBJECT>1
02108 int numberUpdateItems_;
02110 int maximumNumberUpdateItems_;
02112 CbcObjectUpdateData * updateItems_;
02113 #endif
02114
02121 int numberThreads_;
02128 int threadMode_;
02130 };
02132 void getIntegerInformation(const OsiObject * object, double & originalLower,
02133 double & originalUpper) ;
02134
02135
02136 class OsiClpSolverInterface;
02137 int CbcMain (int argc, const char *argv[],OsiClpSolverInterface & solver,CbcModel ** babSolver);
02138 int CbcMain (int argc, const char *argv[],CbcModel & babSolver);
02139
02140 int callCbc(const char * input2, OsiClpSolverInterface& solver1);
02141 int callCbc(const char * input2);
02142 int callCbc(const std::string input2, OsiClpSolverInterface& solver1);
02143 int callCbc(const std::string input2) ;
02144
02145 void CbcMain0 (CbcModel & babSolver);
02146 int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver);
02147
02148 int callCbc(const char * input2, CbcModel & babSolver);
02149 int callCbc(const std::string input2, CbcModel & babSolver);
02150
02151 int callCbc1(const char * input2, CbcModel & babSolver);
02152 int callCbc1(const std::string input2, CbcModel & babSolver);
02153
02154 int callCbc1(const char * input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02155 int callCbc1(const std::string input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02156 int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02157
02158 void setCutAndHeuristicOptions(CbcModel & model);
02159 #endif