CbcModel.hpp

Go to the documentation of this file.
00001 /* $Id: CbcModel.hpp 1627 2011-03-26 15:13:57Z tkr $ */
00002 // Copyright (C) 2002, International Business Machines
00003 // Corporation and others.  All Rights Reserved.
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 #include "ClpDualRowPivot.hpp"
00018 
00019 //class OsiSolverInterface;
00020 
00021 class CbcCutGenerator;
00022 class CbcBaseModel;
00023 class OsiRowCut;
00024 class OsiBabSolver;
00025 class OsiRowCutDebugger;
00026 class CglCutGenerator;
00027 class CglStored;
00028 class CbcCutModifier;
00029 class CglTreeProbingInfo;
00030 class CbcHeuristic;
00031 class OsiObject;
00032 class CbcThread;
00033 class CbcTree;
00034 class CbcStrategy;
00035 class CbcFeasibilityBase;
00036 class CbcStatistics;
00037 class CbcEventHandler ;
00038 class CglPreProcess;
00039 # ifdef COIN_HAS_CLP
00040 class ClpNodeStuff;
00041 #endif
00042 // #define CBC_CHECK_BASIS 1
00043 
00044 //#############################################################################
00045 
00098 class CbcModel  {
00099 
00100 public:
00101 
00102     enum CbcIntParam {
00104         CbcMaxNumNode = 0,
00106         CbcMaxNumSol,
00116         CbcFathomDiscipline,
00120         CbcPrinting,
00123         CbcNumberBranches,
00125         CbcLastIntParam
00126     };
00127 
00128     enum CbcDblParam {
00131         CbcIntegerTolerance = 0,
00134         CbcInfeasibilityWeight,
00137         CbcCutoffIncrement,
00144         CbcAllowableGap,
00151         CbcAllowableFractionGap,
00154         CbcMaximumSeconds,
00156         CbcCurrentCutoff,
00158         CbcOptimizationDirection,
00160         CbcCurrentObjectiveValue,
00162         CbcCurrentMinimizationObjectiveValue,
00165         CbcStartSeconds,
00173         CbcHeuristicGap,
00181         CbcHeuristicFractionGap,
00183         CbcSmallestChange,
00185         CbcSumChange,
00187         CbcLargestChange,
00189         CbcSmallChange,
00191         CbcLastDblParam
00192     };
00193 
00194     //---------------------------------------------------------------------------
00195 
00196 public:
00198 
00199 
00203     void initialSolve();
00204 
00215     void branchAndBound(int doStatistics = 0);
00216 private:
00217 
00225     bool solveWithCuts(OsiCuts & cuts, int numberTries, CbcNode * node);
00233     int serialCuts(OsiCuts & cuts, CbcNode * node, OsiCuts & slackCuts, int lastNumberCuts);
00241     int parallelCuts(CbcBaseModel * master, OsiCuts & cuts, CbcNode * node, OsiCuts & slackCuts, int lastNumberCuts);
00248     CbcNode ** solveOneNode(int whichSolver, CbcNode * node,
00249                             int & numberNodesOutput, int & status) ;
00251     void resizeWhichGenerator(int numberNow, int numberAfter);
00252 public:
00253 #ifdef CBC_KEEP_DEPRECATED
00254     // See if anyone is using these any more!!
00259     CbcModel *  cleanModel(const double * lower, const double * upper);
00276     int subBranchAndBound(CbcModel * model2,
00277                           CbcModel * presolvedModel,
00278                           int maximumNodes);
00294     int subBranchAndBound(const double * lower, const double * upper,
00295                           int maximumNodes);
00296 
00303     OsiSolverInterface *  strengthenedModel();
00313     CglPreProcess * preProcess( int makeEquality = 0, int numberPasses = 5,
00314                                 int tuning = 5);
00317     void postProcess(CglPreProcess * process);
00318 #endif
00320     void addUpdateInformation(const CbcObjectUpdateData & data);
00321 
00327     int doOneNode(CbcModel * baseModel, CbcNode * & node, CbcNode * & newNode);
00328 
00329 public:
00343     int resolve(CbcNodeInfo * parent, int whereFrom,
00344                 double * saveSolution = NULL,
00345                 double * saveLower = NULL,
00346                 double * saveUpper = NULL);
00348     void makeGlobalCuts(int numberRows, const int * which);
00350     void makeGlobalCut(const OsiRowCut * cut);
00352     void makeGlobalCut(const OsiRowCut & cut);
00354     void makeGlobalCut(const OsiColCut * cut);
00356     void makeGlobalCut(const OsiColCut & cut);
00358 
00361 
00373     CbcModel * findCliques(bool makeEquality, int atLeastThisMany,
00374                            int lessThanThis, int defaultValue = 1000);
00375 
00384     CbcModel * integerPresolve(bool weak = false);
00385 
00390     bool integerPresolveThisModel(OsiSolverInterface * originalSolver, bool weak = false);
00391 
00392 
00394     void originalModel(CbcModel * presolvedModel, bool weak);
00395 
00416     bool tightenVubs(int type, bool allowMultipleBinary = false,
00417                      double useCutoff = 1.0e50);
00418 
00424     bool tightenVubs(int numberVubs, const int * which,
00425                      double useCutoff = 1.0e50);
00429     void analyzeObjective();
00430 
00434     void AddIntegers();
00435 
00439     void saveModel(OsiSolverInterface * saveSolver, double * checkCutoffForRestart, bool * feasible);
00440 
00442 
00448 
00450     inline int numberObjects() const {
00451         return numberObjects_;
00452     }
00454     inline void setNumberObjects(int number) {
00455         numberObjects_ = number;
00456     }
00457 
00459     inline OsiObject ** objects() const {
00460         return object_;
00461     }
00462 
00464     const inline OsiObject * object(int which) const {
00465         return object_[which];
00466     }
00468     inline OsiObject * modifiableObject(int which) const {
00469         return object_[which];
00470     }
00471 
00472     void setOptionalInteger(int index);
00473 
00475     void deleteObjects(bool findIntegers = true);
00476 
00481     void addObjects(int numberObjects, OsiObject ** objects);
00482 
00487     void addObjects(int numberObjects, CbcObject ** objects);
00488 
00490     void synchronizeModel() ;
00491 
00501     void findIntegers(bool startAgain, int type = 0);
00502 
00504 
00505     //---------------------------------------------------------------------------
00506 
00516 
00517     inline bool setIntParam(CbcIntParam key, int value) {
00518         intParam_[key] = value;
00519         return true;
00520     }
00522     inline bool setDblParam(CbcDblParam key, double value) {
00523         dblParam_[key] = value;
00524         return true;
00525     }
00527     inline int getIntParam(CbcIntParam key) const {
00528         return intParam_[key];
00529     }
00531     inline double getDblParam(CbcDblParam key) const {
00532         return dblParam_[key];
00533     }
00539     void setCutoff(double value) ;
00540 
00542     inline double getCutoff() const { //double value ;
00543         //solver_->getDblParam(OsiDualObjectiveLimit,value) ;
00544         //assert( dblParam_[CbcCurrentCutoff]== value * solver_->getObjSense());
00545         return dblParam_[CbcCurrentCutoff];
00546     }
00547 
00549     inline bool setMaximumNodes( int value) {
00550         return setIntParam(CbcMaxNumNode, value);
00551     }
00552 
00554     inline int getMaximumNodes() const {
00555         return getIntParam(CbcMaxNumNode);
00556     }
00557 
00562     inline bool setMaximumSolutions( int value) {
00563         return setIntParam(CbcMaxNumSol, value);
00564     }
00569     inline int getMaximumSolutions() const {
00570         return getIntParam(CbcMaxNumSol);
00571     }
00573     inline bool setPrintingMode( int value) {
00574         return setIntParam(CbcPrinting, value);
00575     }
00576 
00578     inline int getPrintingMode() const {
00579         return getIntParam(CbcPrinting);
00580     }
00581 
00586     inline bool setMaximumSeconds( double value) {
00587         return setDblParam(CbcMaximumSeconds, value);
00588     }
00593     inline double getMaximumSeconds() const {
00594         return getDblParam(CbcMaximumSeconds);
00595     }
00597     double getCurrentSeconds() const ;
00598 
00600     bool maximumSecondsReached() const ;
00601 
00605     inline bool setIntegerTolerance( double value) {
00606         return setDblParam(CbcIntegerTolerance, value);
00607     }
00611     inline double getIntegerTolerance() const {
00612         return getDblParam(CbcIntegerTolerance);
00613     }
00614 
00619     inline bool setInfeasibilityWeight( double value) {
00620         return setDblParam(CbcInfeasibilityWeight, value);
00621     }
00626     inline double getInfeasibilityWeight() const {
00627         return getDblParam(CbcInfeasibilityWeight);
00628     }
00629 
00633     inline bool setAllowableGap( double value) {
00634         return setDblParam(CbcAllowableGap, value);
00635     }
00639     inline double getAllowableGap() const {
00640         return getDblParam(CbcAllowableGap);
00641     }
00642 
00646     inline bool setAllowableFractionGap( double value) {
00647         return setDblParam(CbcAllowableFractionGap, value);
00648     }
00652     inline double getAllowableFractionGap() const {
00653         return getDblParam(CbcAllowableFractionGap);
00654     }
00658     inline bool setAllowablePercentageGap( double value) {
00659         return setDblParam(CbcAllowableFractionGap, value*0.01);
00660     }
00664     inline double getAllowablePercentageGap() const {
00665         return 100.0*getDblParam(CbcAllowableFractionGap);
00666     }
00670     inline bool setHeuristicGap( double value) {
00671         return setDblParam(CbcHeuristicGap, value);
00672     }
00676     inline double getHeuristicGap() const {
00677         return getDblParam(CbcHeuristicGap);
00678     }
00679 
00683     inline bool setHeuristicFractionGap( double value) {
00684         return setDblParam(CbcHeuristicFractionGap, value);
00685     }
00689     inline double getHeuristicFractionGap() const {
00690         return getDblParam(CbcHeuristicFractionGap);
00691     }
00696     inline bool setCutoffIncrement( double value) {
00697         return setDblParam(CbcCutoffIncrement, value);
00698     }
00703     inline double getCutoffIncrement() const {
00704         return getDblParam(CbcCutoffIncrement);
00705     }
00706 
00711     void setHotstartSolution(const double * solution, const int * priorities = NULL) ;
00712 
00714     inline void setMinimumDrop(double value) {
00715         minimumDrop_ = value;
00716     }
00718     inline double getMinimumDrop() const {
00719         return minimumDrop_;
00720     }
00721 
00724     inline void setMaximumCutPassesAtRoot(int value) {
00725         maximumCutPassesAtRoot_ = value;
00726     }
00728     inline int getMaximumCutPassesAtRoot() const {
00729         return maximumCutPassesAtRoot_;
00730     }
00731 
00734     inline void setMaximumCutPasses(int value) {
00735         maximumCutPasses_ = value;
00736     }
00738     inline int getMaximumCutPasses() const {
00739         return maximumCutPasses_;
00740     }
00743     inline int getCurrentPassNumber() const {
00744         return currentPassNumber_;
00745     }
00746 
00752     void setNumberStrong(int number);
00756     inline int numberStrong() const {
00757         return numberStrong_;
00758     }
00761     inline void setPreferredWay(int value) {
00762         preferredWay_ = value;
00763     }
00765     inline int getPreferredWay() const {
00766         return preferredWay_;
00767     }
00769     inline int whenCuts() const {
00770         return whenCuts_;
00771     }
00773     inline void setWhenCuts(int value) {
00774         whenCuts_ = value;
00775     }
00781     bool doCutsNow(int allowForTopOfTree) const;
00782 
00788     void setNumberBeforeTrust(int number);
00791     inline int numberBeforeTrust() const {
00792         return numberBeforeTrust_;
00793     }
00799     void setNumberPenalties(int number);
00802     inline int numberPenalties() const {
00803         return numberPenalties_;
00804     }
00806     inline void setNumberAnalyzeIterations(int number) {
00807         numberAnalyzeIterations_ = number;
00808     }
00809     inline int numberAnalyzeIterations() const {
00810         return numberAnalyzeIterations_;
00811     }
00814     inline double penaltyScaleFactor() const {
00815         return penaltyScaleFactor_;
00816     }
00819     void setPenaltyScaleFactor(double value);
00827     void inline setProblemType(int number) {
00828         problemType_ = number;
00829     }
00830     inline int problemType() const {
00831         return problemType_;
00832     }
00834     inline int currentDepth() const {
00835         return currentDepth_;
00836     }
00837 
00839     void setHowOftenGlobalScan(int number);
00841     inline int howOftenGlobalScan() const {
00842         return howOftenGlobalScan_;
00843     }
00845     inline int * originalColumns() const {
00846         return originalColumns_;
00847     }
00849     void setOriginalColumns(const int * originalColumns) ;
00850 
00858     inline void setPrintFrequency(int number) {
00859         printFrequency_ = number;
00860     }
00862     inline int printFrequency() const {
00863         return printFrequency_;
00864     }
00866 
00867     //---------------------------------------------------------------------------
00869 
00870 
00871     bool isAbandoned() const;
00873     bool isProvenOptimal() const;
00875     bool isProvenInfeasible() const;
00877     bool isContinuousUnbounded() const;
00879     bool isProvenDualInfeasible() const;
00881     bool isNodeLimitReached() const;
00883     bool isSecondsLimitReached() const;
00885     bool isSolutionLimitReached() const;
00887     inline int getIterationCount() const {
00888         return numberIterations_;
00889     }
00891     inline void incrementIterationCount(int value) {
00892         numberIterations_ += value;
00893     }
00895     inline int getNodeCount() const {
00896         return numberNodes_;
00897     }
00899     inline void incrementNodeCount(int value) {
00900         numberNodes_ += value;
00901     }
00911     inline int status() const {
00912         return status_;
00913     }
00914     inline void setProblemStatus(int value) {
00915         status_ = value;
00916     }
00928     inline int secondaryStatus() const {
00929         return secondaryStatus_;
00930     }
00931     inline void setSecondaryStatus(int value) {
00932         secondaryStatus_ = value;
00933     }
00935     bool isInitialSolveAbandoned() const ;
00937     bool isInitialSolveProvenOptimal() const ;
00939     bool isInitialSolveProvenPrimalInfeasible() const ;
00941     bool isInitialSolveProvenDualInfeasible() const ;
00942 
00944 
00945     //---------------------------------------------------------------------------
00958 
00959     inline int numberRowsAtContinuous() const {
00960         return numberRowsAtContinuous_;
00961     }
00962 
00964     inline int getNumCols() const {
00965         return solver_->getNumCols();
00966     }
00967 
00969     inline int getNumRows() const {
00970         return solver_->getNumRows();
00971     }
00972 
00974     inline CoinBigIndex getNumElements() const {
00975         return solver_->getNumElements();
00976     }
00977 
00979     inline int numberIntegers() const {
00980         return numberIntegers_;
00981     }
00982     // Integer variables
00983     inline const int * integerVariable() const {
00984         return integerVariable_;
00985     }
00987     inline char integerType(int i) const {
00988         assert (integerInfo_);
00989         assert (integerInfo_[i] == 0 || integerInfo_[i] == 1);
00990         return integerInfo_[i];
00991     }
00993     inline const char * integerType() const {
00994         return integerInfo_;
00995     }
00996 
00998     inline const double * getColLower() const {
00999         return solver_->getColLower();
01000     }
01001 
01003     inline const double * getColUpper() const {
01004         return solver_->getColUpper();
01005     }
01006 
01016     inline const char * getRowSense() const {
01017         return solver_->getRowSense();
01018     }
01019 
01028     inline const double * getRightHandSide() const {
01029         return solver_->getRightHandSide();
01030     }
01031 
01040     inline const double * getRowRange() const {
01041         return solver_->getRowRange();
01042     }
01043 
01045     inline const double * getRowLower() const {
01046         return solver_->getRowLower();
01047     }
01048 
01050     inline const double * getRowUpper() const {
01051         return solver_->getRowUpper();
01052     }
01053 
01055     inline const double * getObjCoefficients() const {
01056         return solver_->getObjCoefficients();
01057     }
01058 
01060     inline double getObjSense() const {
01061         //assert (dblParam_[CbcOptimizationDirection]== solver_->getObjSense());
01062         return dblParam_[CbcOptimizationDirection];
01063     }
01064 
01066     inline bool isContinuous(int colIndex) const {
01067         return solver_->isContinuous(colIndex);
01068     }
01069 
01071     inline bool isBinary(int colIndex) const {
01072         return solver_->isBinary(colIndex);
01073     }
01074 
01079     inline bool isInteger(int colIndex) const {
01080         return solver_->isInteger(colIndex);
01081     }
01082 
01084     inline bool isIntegerNonBinary(int colIndex) const {
01085         return solver_->isIntegerNonBinary(colIndex);
01086     }
01087 
01089     inline bool isFreeBinary(int colIndex) const {
01090         return solver_->isFreeBinary(colIndex) ;
01091     }
01092 
01094     inline const CoinPackedMatrix * getMatrixByRow() const {
01095         return solver_->getMatrixByRow();
01096     }
01097 
01099     inline const CoinPackedMatrix * getMatrixByCol() const {
01100         return solver_->getMatrixByCol();
01101     }
01102 
01104     inline double getInfinity() const {
01105         return solver_->getInfinity();
01106     }
01108     inline const double * getCbcColLower() const {
01109         return cbcColLower_;
01110     }
01112     inline const double * getCbcColUpper() const {
01113         return cbcColUpper_;
01114     }
01116     inline const double * getCbcRowLower() const {
01117         return cbcRowLower_;
01118     }
01120     inline const double * getCbcRowUpper() const {
01121         return cbcRowUpper_;
01122     }
01124     inline const double * getCbcColSolution() const {
01125         return cbcColSolution_;
01126     }
01128     inline const double * getCbcRowPrice() const {
01129         return cbcRowPrice_;
01130     }
01132     inline const double * getCbcReducedCost() const {
01133         return cbcReducedCost_;
01134     }
01136     inline const double * getCbcRowActivity() const {
01137         return cbcRowActivity_;
01138     }
01140 
01141 
01144 
01145     inline double * continuousSolution() const {
01146         return continuousSolution_;
01147     }
01152     inline int * usedInSolution() const {
01153         return usedInSolution_;
01154     }
01156     void incrementUsed(const double * solution);
01158     void setBestSolution(CBC_Message how,
01159                          double & objectiveValue, const double *solution,
01160                          int fixVariables = 0);
01162     void setBestObjectiveValue( double objectiveValue);
01164     CbcEventHandler::CbcAction dealWithEventHandler(CbcEventHandler::CbcEvent event,
01165             double objValue,
01166             const double * solution);
01167 
01174     double checkSolution(double cutoff, double * solution,
01175                          int fixVariables, double originalObjValue);
01182     bool feasibleSolution(int & numberIntegerInfeasibilities,
01183                           int & numberObjectInfeasibilities) const;
01184 
01190     inline double * currentSolution() const {
01191         return currentSolution_;
01192     }
01196     inline const double * testSolution() const {
01197         return testSolution_;
01198     }
01199     inline void setTestSolution(const double * solution) {
01200         testSolution_ = solution;
01201     }
01203     void reserveCurrentSolution(const double * solution = NULL);
01204 
01206     inline const double * getColSolution() const {
01207         return solver_->getColSolution();
01208     }
01209 
01211     inline const double * getRowPrice() const {
01212         return solver_->getRowPrice();
01213     }
01214 
01216     inline const double * getReducedCost() const {
01217         return solver_->getReducedCost();
01218     }
01219 
01221     inline const double * getRowActivity() const {
01222         return solver_->getRowActivity();
01223     }
01224 
01226     inline double getCurrentObjValue() const {
01227         return dblParam_[CbcCurrentObjectiveValue];
01228     }
01230     inline double getCurrentMinimizationObjValue() const {
01231         return dblParam_[CbcCurrentMinimizationObjectiveValue];
01232     }
01233 
01235     inline double getMinimizationObjValue() const {
01236         return bestObjective_;
01237     }
01239     inline void setMinimizationObjValue(double value) {
01240         bestObjective_ = value;
01241     }
01242 
01244     inline double getObjValue() const {
01245         return bestObjective_ * solver_->getObjSense() ;
01246     }
01252     double getBestPossibleObjValue() const;
01254     inline void setObjValue(double value) {
01255         bestObjective_ = value * solver_->getObjSense() ;
01256     }
01258     inline double getSolverObjValue() const {
01259         return solver_->getObjValue() * solver_->getObjSense() ;
01260     }
01261 
01268     inline double * bestSolution() const {
01269         return bestSolution_;
01270     }
01277     void setBestSolution(const double * solution, int numberColumns,
01278                          double objectiveValue, bool check = false);
01279 
01281     inline int getSolutionCount() const {
01282         return numberSolutions_;
01283     }
01284 
01286     inline void setSolutionCount(int value) {
01287         numberSolutions_ = value;
01288     }
01290     int numberSavedSolutions() const;
01292     inline int maximumSavedSolutions() const {
01293         return maximumSavedSolutions_;
01294     }
01296     void setMaximumSavedSolutions(int value);
01298     const double * savedSolution(int which) const;
01300     double savedSolutionObjective(int which) const;
01301 
01310     inline int phase() const {
01311         return phase_;
01312     }
01313 
01315     inline int getNumberHeuristicSolutions() const {
01316         return numberHeuristicSolutions_;
01317     }
01319     inline void setNumberHeuristicSolutions(int value) {
01320         numberHeuristicSolutions_ = value;
01321     }
01322 
01324     inline void setObjSense(double s) {
01325         dblParam_[CbcOptimizationDirection] = s;
01326         solver_->setObjSense(s);
01327     }
01328 
01330     inline double getContinuousObjective() const {
01331         return originalContinuousObjective_;
01332     }
01333     inline void setContinuousObjective(double value) {
01334         originalContinuousObjective_ = value;
01335     }
01337     inline int getContinuousInfeasibilities() const {
01338         return continuousInfeasibilities_;
01339     }
01340     inline void setContinuousInfeasibilities(int value) {
01341         continuousInfeasibilities_ = value;
01342     }
01344     inline double rootObjectiveAfterCuts() const {
01345         return continuousObjective_;
01346     }
01348     inline double sumChangeObjective() const {
01349         return sumChangeObjective1_;
01350     }
01353     inline int numberGlobalViolations() const {
01354         return numberGlobalViolations_;
01355     }
01356     inline void clearNumberGlobalViolations() {
01357         numberGlobalViolations_ = 0;
01358     }
01360     inline bool resolveAfterTakeOffCuts() const {
01361         return resolveAfterTakeOffCuts_;
01362     }
01363     inline void setResolveAfterTakeOffCuts(bool yesNo) {
01364         resolveAfterTakeOffCuts_ = yesNo;
01365     }
01367     inline int maximumRows() const {
01368         return maximumRows_;
01369     }
01371     inline CoinWarmStartBasis & workingBasis() {
01372         return workingBasis_;
01373     }
01375     inline int getStopNumberIterations() const {
01376         return stopNumberIterations_;
01377     }
01379     inline void setStopNumberIterations(int value) {
01380         stopNumberIterations_ = value;
01381     }
01383 
01386     // Comparison functions (which may be overridden by inheritance)
01387     inline CbcCompareBase * nodeComparison() const {
01388         return nodeCompare_;
01389     }
01390     void setNodeComparison(CbcCompareBase * compare);
01391     void setNodeComparison(CbcCompareBase & compare);
01393 
01396     // Feasibility functions (which may be overridden by inheritance)
01397     inline CbcFeasibilityBase * problemFeasibility() const {
01398         return problemFeasibility_;
01399     }
01400     void setProblemFeasibility(CbcFeasibilityBase * feasibility);
01401     void setProblemFeasibility(CbcFeasibilityBase & feasibility);
01403 
01406 
01407     inline CbcTree * tree() const {
01408         return tree_;
01409     }
01411     void passInTreeHandler(CbcTree & tree);
01415     void passInSubTreeModel(CbcModel & model);
01420     CbcModel * subTreeModel(OsiSolverInterface * solver = NULL) const;
01422     inline int numberStoppedSubTrees() const {
01423         return numberStoppedSubTrees_;
01424     }
01426     inline void incrementSubTreeStopped() {
01427         numberStoppedSubTrees_++;
01428     }
01434     inline int typePresolve() const {
01435         return presolve_;
01436     }
01437     inline void setTypePresolve(int value) {
01438         presolve_ = value;
01439     }
01440 
01442 
01448 
01450     inline CbcBranchDecision * branchingMethod() const {
01451         return branchingMethod_;
01452     }
01454     inline void setBranchingMethod(CbcBranchDecision * method) {
01455         delete branchingMethod_;
01456         branchingMethod_ = method->clone();
01457     }
01462     inline void setBranchingMethod(CbcBranchDecision & method) {
01463         delete branchingMethod_;
01464         branchingMethod_ = method.clone();
01465     }
01467     inline CbcCutModifier * cutModifier() const {
01468         return cutModifier_;
01469     }
01471     void setCutModifier(CbcCutModifier * modifier);
01476     void setCutModifier(CbcCutModifier & modifier);
01478 
01481 
01488     inline int stateOfSearch() const {
01489         return stateOfSearch_;
01490     }
01491     inline void setStateOfSearch(int state) {
01492         stateOfSearch_ = state;
01493     }
01495     inline int searchStrategy() const {
01496         return searchStrategy_;
01497     }
01499     inline void setSearchStrategy(int value) {
01500         searchStrategy_ = value;
01501     }
01502 
01504     inline int numberCutGenerators() const {
01505         return numberCutGenerators_;
01506     }
01508     inline CbcCutGenerator ** cutGenerators() const {
01509         return generator_;
01510     }
01512     inline CbcCutGenerator * cutGenerator(int i) const {
01513         return generator_[i];
01514     }
01516     inline CbcCutGenerator * virginCutGenerator(int i) const {
01517         return virginGenerator_[i];
01518     }
01527     void addCutGenerator(CglCutGenerator * generator,
01528                          int howOften = 1, const char * name = NULL,
01529                          bool normal = true, bool atSolution = false,
01530                          bool infeasible = false, int howOftenInSub = -100,
01531                          int whatDepth = -1, int whatDepthInSub = -1);
01533 
01538 
01540     inline CbcStrategy * strategy() const {
01541         return strategy_;
01542     }
01544     void setStrategy(CbcStrategy & strategy);
01546     inline void setStrategy(CbcStrategy * strategy) {
01547         strategy_ = strategy;
01548     }
01550     inline CbcModel * parentModel() const {
01551         return parentModel_;
01552     }
01554     inline void setParentModel(CbcModel & parentModel) {
01555         parentModel_ = &parentModel;
01556     }
01558 
01559 
01566     void addHeuristic(CbcHeuristic * generator, const char *name = NULL,
01567                       int before = -1);
01569     inline CbcHeuristic * heuristic(int i) const {
01570         return heuristic_[i];
01571     }
01573     inline int numberHeuristics() const {
01574         return numberHeuristics_;
01575     }
01577     inline CbcHeuristic * lastHeuristic() const {
01578         return lastHeuristic_;
01579     }
01581     inline void setLastHeuristic(CbcHeuristic * last) {
01582         lastHeuristic_ = last;
01583     }
01584 
01603     void passInPriorities(const int * priorities, bool ifNotSimpleIntegers);
01604 
01606     inline int priority(int sequence) const {
01607         return object_[sequence]->priority();
01608     }
01609 
01614     void passInEventHandler(const CbcEventHandler *eventHandler) ;
01615 
01617     inline CbcEventHandler* getEventHandler() const {
01618         return (eventHandler_) ;
01619     }
01620 
01622 
01632     void setApplicationData (void * appData);
01633 
01635     void * getApplicationData() const;
01648     void passInSolverCharacteristics(OsiBabSolver * solverCharacteristics);
01650     inline const OsiBabSolver * solverCharacteristics() const {
01651         return solverCharacteristics_;
01652     }
01654 
01655     //---------------------------------------------------------------------------
01656 
01659 
01660     void passInMessageHandler(CoinMessageHandler * handler);
01662     void newLanguage(CoinMessages::Language language);
01663     inline void setLanguage(CoinMessages::Language language) {
01664         newLanguage(language);
01665     }
01667     inline CoinMessageHandler * messageHandler() const {
01668         return handler_;
01669     }
01671     inline CoinMessages & messages() {
01672         return messages_;
01673     }
01675     inline CoinMessages * messagesPointer() {
01676         return &messages_;
01677     }
01679     void setLogLevel(int value);
01681     inline int logLevel() const {
01682         return handler_->logLevel();
01683     }
01689     inline void setDefaultHandler(bool yesNo) {
01690         defaultHandler_ = yesNo;
01691     }
01693     //---------------------------------------------------------------------------
01695 
01696 
01718     inline void setSpecialOptions(int value) {
01719         specialOptions_ = value;
01720     }
01722     inline int specialOptions() const {
01723         return specialOptions_;
01724     }
01726     inline bool normalSolver() const {
01727         return (specialOptions_&16) == 0;
01728     }
01737     inline void setMoreSpecialOptions(int value) {
01738         moreSpecialOptions_ = value;
01739     }
01741     inline int moreSpecialOptions() const {
01742         return moreSpecialOptions_;
01743     }
01745     inline void setUseElapsedTime(bool yesNo) {
01746         if (yesNo)
01747           moreSpecialOptions_ |= 131072;
01748         else
01749           moreSpecialOptions_ &= ~131072;
01750     }
01752     inline bool useElapsedTime() const {
01753         return (moreSpecialOptions_&131072)!=0;
01754     }
01756 #ifdef COIN_HAS_CLP
01757     void goToDantzig(int numberNodes, ClpDualRowPivot *& savePivotMethod);
01758 #endif
01760     inline bool ownObjects() const {
01761         return ownObjects_;
01762     }
01764     void checkModel();
01766     //---------------------------------------------------------------------------
01767 
01769 
01770 
01771     CbcModel();
01772 
01774     CbcModel(const OsiSolverInterface &);
01775 
01784     void assignSolver(OsiSolverInterface *&solver, bool deleteSolver = true);
01785 
01797     inline void setModelOwnsSolver (bool ourSolver) {
01798         ownership_ = ourSolver ? (ownership_ | 0x80000000) : (ownership_ & (~0x80000000)) ;
01799     }
01800 
01806     inline bool modelOwnsSolver () {
01807         return ((ownership_&0x80000000) != 0) ;
01808     }
01809 
01813     CbcModel(const CbcModel & rhs, bool cloneHandler = false);
01814 
01816     CbcModel & operator=(const CbcModel& rhs);
01817 
01819     ~CbcModel ();
01820 
01822     inline OsiSolverInterface * solver() const {
01823         return solver_;
01824     }
01825 
01827     inline OsiSolverInterface * swapSolver(OsiSolverInterface * solver) {
01828         OsiSolverInterface * returnSolver = solver_;
01829         solver_ = solver;
01830         return returnSolver;
01831     }
01832 
01834     inline OsiSolverInterface * continuousSolver() const {
01835         return continuousSolver_;
01836     }
01837 
01839     inline void createContinuousSolver() {
01840         continuousSolver_ = solver_->clone();
01841     }
01843     inline void clearContinuousSolver() {
01844         delete continuousSolver_;
01845         continuousSolver_ = NULL;
01846     }
01847 
01849     inline OsiSolverInterface * referenceSolver() const {
01850         return referenceSolver_;
01851     }
01852 
01854     void saveReferenceSolver();
01855 
01861     void resetToReferenceSolver();
01862 
01864     void gutsOfDestructor();
01867     void gutsOfDestructor2();
01870     void resetModel();
01876     void gutsOfCopy(const CbcModel & rhs, int mode = 0);
01878     void moveInfo(const CbcModel & rhs);
01880 
01882 
01883 
01884     CbcThread * masterThread() const {
01885         return masterThread_;
01886     }
01888     CbcNodeInfo ** walkback() const {
01889         return walkback_;
01890     }
01892     inline int getNumberThreads() const {
01893         return numberThreads_;
01894     }
01896     inline void setNumberThreads(int value) {
01897         numberThreads_ = value;
01898     }
01900     inline int getThreadMode() const {
01901         return threadMode_;
01902     }
01912     inline void setThreadMode(int value) {
01913         threadMode_ = value;
01914     }
01921     inline int parallelMode() const {
01922         if (!numberThreads_) {
01923             if ((threadMode_&1) == 0)
01924                 return 0;
01925             else
01926                 return -1;
01927             return 0;
01928         } else {
01929             if ((threadMode_&1) == 0)
01930                 return 1;
01931             else
01932                 return -2;
01933         }
01934     }
01937     bool isLocked() const;
01938 #ifdef CBC_THREAD
01939 
01943     void lockThread();
01947     void unlockThread();
01948 #else
01949     inline void lockThread() {}
01950     inline void unlockThread() {}
01951 #endif
01952 
01959     void setInfoInChild(int type, CbcThread * info);
01966     void moveToModel(CbcModel * baseModel, int mode);
01968     int splitModel(int numberModels, CbcModel ** model,
01969                    int numberNodes);
01971     void startSplitModel(int numberIterations);
01973     void mergeModels(int numberModel, CbcModel ** model,
01974                      int numberNodes);
01976 
01978 
01979 
01980     int getNodeCount2() const {
01981         return numberNodes2_;
01982     }
01984     void setPointers(const OsiSolverInterface * solver);
01990     int reducedCostFix() ;
01994     void synchronizeHandlers(int makeDefault);
01996     void saveExtraSolution(const double * solution, double objectiveValue);
01998     void saveBestSolution(const double * solution, double objectiveValue);
02000     void deleteSolutions();
02002     int resolve(OsiSolverInterface * solver);
02003 
02007     int chooseBranch(CbcNode * & newNode, int numberPassesLeft,
02008                      CbcNode * oldNode, OsiCuts & cuts,
02009                      bool & resolved, CoinWarmStartBasis *lastws,
02010                      const double * lowerBefore, const double * upperBefore,
02011                      OsiSolverBranch * & branches);
02012     int chooseBranch(CbcNode * newNode, int numberPassesLeft, bool & resolved);
02013 
02020     CoinWarmStartBasis *getEmptyBasis(int ns = 0, int na = 0) const ;
02021 
02033     int takeOffCuts(OsiCuts &cuts,
02034                     bool allowResolve, OsiCuts * saveCuts,
02035                     int numberNewCuts = 0, const OsiRowCut ** newCuts = NULL) ;
02036 
02050     int addCuts(CbcNode * node, CoinWarmStartBasis *&lastws, bool canFix);
02051 
02068     bool addCuts1(CbcNode * node, CoinWarmStartBasis *&lastws);
02072     void previousBounds (CbcNode * node, CbcNodeInfo * where, int iColumn,
02073                          double & lower, double & upper, int force);
02078     void setObjectiveValue(CbcNode * thisNode, const CbcNode * parentNode) const;
02079 
02083     void convertToDynamic();
02085     void synchronizeNumberBeforeTrust(int type = 0);
02087     void zapIntegerInformation(bool leaveObjects = true);
02089     int cliquePseudoCosts(int doStatistics);
02091     void pseudoShadow(int type);
02098     void fillPseudoCosts(double * downCosts, double * upCosts,
02099                          int * priority = NULL,
02100                          int * numberDown = NULL, int * numberUp = NULL,
02101                          int * numberDownInfeasible = NULL,
02102                          int * numberUpInfeasible = NULL) const;
02108     void doHeuristicsAtRoot(int deleteHeuristicsAfterwards = 0);
02110     void adjustHeuristics();
02112     inline const double * hotstartSolution() const {
02113         return hotstartSolution_;
02114     }
02116     inline const int * hotstartPriorities() const {
02117         return hotstartPriorities_;
02118     }
02119 
02121     inline CbcCountRowCut ** addedCuts() const {
02122         return addedCuts_;
02123     }
02125     inline int currentNumberCuts() const {
02126         return currentNumberCuts_;
02127     }
02129     inline OsiCuts * globalCuts() {
02130         return &globalCuts_;
02131     }
02133     void setNextRowCut(const OsiRowCut & cut);
02135     inline CbcNode * currentNode() const {
02136         return currentNode_;
02137     }
02139     inline CglTreeProbingInfo * probingInfo() const {
02140         return probingInfo_;
02141     }
02143     inline CoinThreadRandom * randomNumberGenerator() {
02144         return &randomNumberGenerator_;
02145     }
02147     inline void setNumberStrongIterations(int number) {
02148         numberStrongIterations_ = number;
02149     }
02151     inline int numberStrongIterations() const {
02152         return numberStrongIterations_;
02153     }
02155     inline int maximumNumberIterations() const {
02156         return maximumNumberIterations_;
02157     }
02159     inline void setMaximumNumberIterations(int value) {
02160         maximumNumberIterations_ = value;
02161     }
02162 # ifdef COIN_HAS_CLP
02164     inline void setFastNodeDepth(int value) {
02165         fastNodeDepth_ = value;
02166     }
02168     inline int fastNodeDepth() const {
02169         return fastNodeDepth_;
02170     }
02172     inline int continuousPriority() const {
02173         return continuousPriority_;
02174     }
02176     inline void setContinuousPriority(int value) {
02177         continuousPriority_ = value;
02178     }
02179     inline void incrementExtra(int nodes, int iterations) {
02180         numberExtraNodes_ += nodes;
02181         numberExtraIterations_ += iterations;
02182     }
02183 #endif
02185     inline int numberExtraIterations() const {
02186         return numberExtraIterations_;
02187     }
02189     void incrementStrongInfo(int numberTimes, int numberIterations,
02190                              int numberFixed, bool ifInfeasible);
02192     inline const int * strongInfo() const {
02193         return strongInfo_;
02194     }
02195 
02197     inline int * mutableStrongInfo() {
02198         return strongInfo_;
02199     }
02201     CglStored * storedRowCuts() const {
02202         return storedRowCuts_;
02203     }
02205     void setStoredRowCuts(CglStored * cuts) {
02206         storedRowCuts_ = cuts;
02207     }
02209     inline bool allDynamic () const {
02210         return ((ownership_&0x40000000) != 0) ;
02211     }
02213     void generateCpp( FILE * fp, int options);
02215     OsiBranchingInformation usefulInformation() const;
02222     inline void setBestSolutionBasis(const CoinWarmStartBasis & bestSolutionBasis) {
02223         bestSolutionBasis_ = bestSolutionBasis;
02224     }
02226     void redoWalkBack();
02228 
02229 //---------------------------------------------------------------------------
02230 
02231 private:
02233 
02234 
02236     OsiSolverInterface * solver_;
02237 
02243     unsigned int ownership_ ;
02244 
02246     OsiSolverInterface * continuousSolver_;
02247 
02249     OsiSolverInterface * referenceSolver_;
02250 
02252     CoinMessageHandler * handler_;
02253 
02259     bool defaultHandler_;
02260 
02262     CoinMessages messages_;
02263 
02265     int intParam_[CbcLastIntParam];
02266 
02268     double dblParam_[CbcLastDblParam];
02269 
02278     mutable CoinWarmStart *emptyWarmStart_ ;
02279 
02281     double bestObjective_;
02283     double bestPossibleObjective_;
02285     double sumChangeObjective1_;
02287     double sumChangeObjective2_;
02288 
02290     double * bestSolution_;
02292     double ** savedSolutions_;
02293 
02298     double * currentSolution_;
02302     mutable const double * testSolution_;
02309     CoinWarmStartBasis bestSolutionBasis_ ;
02311     OsiCuts globalCuts_;
02312 
02314     double minimumDrop_;
02316     int numberSolutions_;
02318     int numberSavedSolutions_;
02320     int maximumSavedSolutions_;
02327     int stateOfSearch_;
02329     int whenCuts_;
02331     double * hotstartSolution_;
02333     int * hotstartPriorities_;
02335     int numberHeuristicSolutions_;
02337     int numberNodes_;
02341     int numberNodes2_;
02343     int numberIterations_;
02345     int numberSolves_;
02347     int status_;
02358     int secondaryStatus_;
02360     int numberIntegers_;
02362     int numberRowsAtContinuous_;
02364     int maximumNumberCuts_;
02373     int phase_;
02374 
02376     int currentNumberCuts_;
02377 
02382     int maximumDepth_;
02388     CbcNodeInfo ** walkback_;
02389     CbcNodeInfo ** lastNodeInfo_;
02390     const OsiRowCut ** lastCut_;
02391     int lastDepth_;
02392     int lastNumberCuts2_;
02393     int maximumCuts_;
02394     int * lastNumberCuts_;
02395 
02403     CbcCountRowCut ** addedCuts_;
02404 
02408     OsiRowCut * nextRowCut_;
02409 
02411     CbcNode * currentNode_;
02412 
02414     int * integerVariable_;
02416     char * integerInfo_;
02418     double * continuousSolution_;
02420     int * usedInSolution_;
02444     int specialOptions_;
02455     int moreSpecialOptions_;
02457     CbcCompareBase * nodeCompare_;
02459     CbcFeasibilityBase * problemFeasibility_;
02461     CbcTree * tree_;
02463     CbcModel * subTreeModel_;
02465     int numberStoppedSubTrees_;
02467     CbcBranchDecision * branchingMethod_;
02469     CbcCutModifier * cutModifier_;
02471     CbcStrategy * strategy_;
02473     CbcModel * parentModel_;
02479 
02480     const double * cbcColLower_;
02482     const double * cbcColUpper_;
02484     const double * cbcRowLower_;
02486     const double * cbcRowUpper_;
02488     const double * cbcColSolution_;
02490     const double * cbcRowPrice_;
02492     const double * cbcReducedCost_;
02494     const double * cbcRowActivity_;
02496     void * appData_;
02498     int presolve_;
02502     int numberStrong_;
02508     int numberBeforeTrust_;
02512     int numberPenalties_;
02514     int stopNumberIterations_;
02517     double penaltyScaleFactor_;
02519     int numberAnalyzeIterations_;
02521     double * analyzeResults_;
02523     int numberInfeasibleNodes_;
02530     int problemType_;
02532     int printFrequency_;
02534     int numberCutGenerators_;
02535     // Cut generators
02536     CbcCutGenerator ** generator_;
02537     // Cut generators before any changes
02538     CbcCutGenerator ** virginGenerator_;
02540     int numberHeuristics_;
02542     CbcHeuristic ** heuristic_;
02544     CbcHeuristic * lastHeuristic_;
02545 # ifdef COIN_HAS_CLP
02547     int fastNodeDepth_;
02548 #endif
02549 
02550 # ifdef CBC_ONLY_CLP
02551     ClpEventHandler *eventHandler_ ;
02552 # else
02553     CbcEventHandler *eventHandler_ ;
02554 # endif
02555 
02557     int numberObjects_;
02558 
02569     OsiObject ** object_;
02571     bool ownObjects_;
02572 
02574     int * originalColumns_;
02576     int howOftenGlobalScan_;
02579     int numberGlobalViolations_;
02581     int numberExtraIterations_;
02583     int numberExtraNodes_;
02587     double continuousObjective_;
02590     double originalContinuousObjective_;
02592     int continuousInfeasibilities_;
02594     int maximumCutPassesAtRoot_;
02596     int maximumCutPasses_;
02598     int preferredWay_;
02600     int currentPassNumber_;
02602     int maximumWhich_;
02604     int maximumRows_;
02606     int currentDepth_;
02608     mutable CoinThreadRandom randomNumberGenerator_;
02610     CoinWarmStartBasis workingBasis_;
02612     int * whichGenerator_;
02614     int maximumStatistics_;
02616     CbcStatistics ** statistics_;
02618     int maximumDepthActual_;
02620     double numberDJFixed_;
02622     CglTreeProbingInfo * probingInfo_;
02624     int numberFixedAtRoot_;
02626     int numberFixedNow_;
02628     bool stoppedOnGap_;
02630     mutable bool eventHappened_;
02632     int numberLongStrong_;
02634     int numberOldActiveCuts_;
02636     int numberNewCuts_;
02638     int searchStrategy_;
02640     int numberStrongIterations_;
02643     int strongInfo_[7];
02650     OsiBabSolver * solverCharacteristics_;
02652     bool resolveAfterTakeOffCuts_;
02654     int maximumNumberIterations_;
02656     int continuousPriority_;
02658     int numberUpdateItems_;
02660     int maximumNumberUpdateItems_;
02662     CbcObjectUpdateData * updateItems_;
02664     CglStored * storedRowCuts_;
02672     int numberThreads_;
02680     int threadMode_;
02682     CbcBaseModel * master_;
02684     CbcThread * masterThread_;
02686 };
02688 void getIntegerInformation(const OsiObject * object, double & originalLower,
02689                            double & originalUpper) ;
02690 // So we can call from other programs
02691 // Real main program
02692 class OsiClpSolverInterface;
02693 int CbcMain (int argc, const char *argv[], OsiClpSolverInterface & solver, CbcModel ** babSolver);
02694 int CbcMain (int argc, const char *argv[], CbcModel & babSolver);
02695 // four ways of calling
02696 int callCbc(const char * input2, OsiClpSolverInterface& solver1);
02697 int callCbc(const char * input2);
02698 int callCbc(const std::string input2, OsiClpSolverInterface& solver1);
02699 int callCbc(const std::string input2) ;
02700 // When we want to load up CbcModel with options first
02701 void CbcMain0 (CbcModel & babSolver);
02702 int CbcMain1 (int argc, const char *argv[], CbcModel & babSolver);
02703 // two ways of calling
02704 int callCbc(const char * input2, CbcModel & babSolver);
02705 int callCbc(const std::string input2, CbcModel & babSolver);
02706 // And when CbcMain0 already called to initialize
02707 int callCbc1(const char * input2, CbcModel & babSolver);
02708 int callCbc1(const std::string input2, CbcModel & babSolver);
02709 // And when CbcMain0 already called to initialize (with call back) (see CbcMain1 for whereFrom)
02710 int callCbc1(const char * input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02711 int callCbc1(const std::string input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02712 int CbcMain1 (int argc, const char *argv[], CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02713 // For uniform setting of cut and heuristic options
02714 void setCutAndHeuristicOptions(CbcModel & model);
02715 #endif
02716 

Generated on Tue Jun 14 23:14:02 2011 for Cbc by  doxygen 1.4.7