• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/tmp/buildd/coinor-cbc-2.5.0/Cbc/src/CbcModel.hpp

Go to the documentation of this file.
00001 /* $Id: CbcModel.hpp 1409 2009-12-21 16:59:56Z forrest $ */
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
00319 
00320     void addUpdateInformation(const CbcObjectUpdateData & data);
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     }
01736     inline void setMoreSpecialOptions(int value) {
01737         moreSpecialOptions_ = value;
01738     }
01740     inline int moreSpecialOptions() const {
01741         return moreSpecialOptions_;
01742     }
01744 #ifdef COIN_HAS_CLP
01745     void goToDantzig(int numberNodes, ClpDualRowPivot *& savePivotMethod);
01746 #endif
01747 
01748     inline bool ownObjects() const {
01749         return ownObjects_;
01750     }
01752     void checkModel();
01754     //---------------------------------------------------------------------------
01755 
01757 
01758 
01759     CbcModel();
01760 
01762     CbcModel(const OsiSolverInterface &);
01763 
01772     void assignSolver(OsiSolverInterface *&solver, bool deleteSolver = true);
01773 
01785     inline void setModelOwnsSolver (bool ourSolver) {
01786         ownership_ = ourSolver ? (ownership_ | 0x80000000) : (ownership_ & (~0x80000000)) ;
01787     }
01788 
01794     inline bool modelOwnsSolver () {
01795         return ((ownership_&0x80000000) != 0) ;
01796     }
01797 
01801     CbcModel(const CbcModel & rhs, bool cloneHandler = false);
01802 
01804     CbcModel & operator=(const CbcModel& rhs);
01805 
01807     ~CbcModel ();
01808 
01810     inline OsiSolverInterface * solver() const {
01811         return solver_;
01812     }
01813 
01815     inline OsiSolverInterface * swapSolver(OsiSolverInterface * solver) {
01816         OsiSolverInterface * returnSolver = solver_;
01817         solver_ = solver;
01818         return returnSolver;
01819     }
01820 
01822     inline OsiSolverInterface * continuousSolver() const {
01823         return continuousSolver_;
01824     }
01825 
01827     inline void createContinuousSolver() {
01828         continuousSolver_ = solver_->clone();
01829     }
01831     inline void clearContinuousSolver() {
01832         delete continuousSolver_;
01833         continuousSolver_ = NULL;
01834     }
01835 
01837     inline OsiSolverInterface * referenceSolver() const {
01838         return referenceSolver_;
01839     }
01840 
01842     void saveReferenceSolver();
01843 
01849     void resetToReferenceSolver();
01850 
01852     void gutsOfDestructor();
01855     void gutsOfDestructor2();
01858     void resetModel();
01864     void gutsOfCopy(const CbcModel & rhs, int mode = 0);
01866     void moveInfo(const CbcModel & rhs);
01868 
01870 
01871 
01872     CbcThread * masterThread() const {
01873         return masterThread_;
01874     }
01876     CbcNodeInfo ** walkback() const {
01877         return walkback_;
01878     }
01880     inline int getNumberThreads() const {
01881         return numberThreads_;
01882     }
01884     inline void setNumberThreads(int value) {
01885         numberThreads_ = value;
01886     }
01888     inline int getThreadMode() const {
01889         return threadMode_;
01890     }
01900     inline void setThreadMode(int value) {
01901         threadMode_ = value;
01902     }
01909     inline int parallelMode() const {
01910         if (!numberThreads_) {
01911             if ((threadMode_&1) == 0)
01912                 return 0;
01913             else
01914                 return -1;
01915             return 0;
01916         } else {
01917             if ((threadMode_&1) == 0)
01918                 return 1;
01919             else
01920                 return -2;
01921         }
01922     }
01925     bool isLocked() const;
01926 #ifdef CBC_THREAD
01927 
01931     void lockThread();
01935     void unlockThread();
01936 #else
01937     inline void lockThread() {}
01938     inline void unlockThread() {}
01939 #endif
01940 
01947     void setInfoInChild(int type, CbcThread * info);
01954     void moveToModel(CbcModel * baseModel, int mode);
01956     int splitModel(int numberModels, CbcModel ** model,
01957                    int numberNodes);
01959     void startSplitModel(int numberIterations);
01961     void mergeModels(int numberModel, CbcModel ** model,
01962                      int numberNodes);
01964 
01966 
01967 
01968     int getNodeCount2() const {
01969         return numberNodes2_;
01970     }
01972     void setPointers(const OsiSolverInterface * solver);
01978     int reducedCostFix() ;
01982     void synchronizeHandlers(int makeDefault);
01984     void saveExtraSolution(const double * solution, double objectiveValue);
01986     void saveBestSolution(const double * solution, double objectiveValue);
01988     void deleteSolutions();
01990     int resolve(OsiSolverInterface * solver);
01991 
01995     int chooseBranch(CbcNode * & newNode, int numberPassesLeft,
01996                      CbcNode * oldNode, OsiCuts & cuts,
01997                      bool & resolved, CoinWarmStartBasis *lastws,
01998                      const double * lowerBefore, const double * upperBefore,
01999                      OsiSolverBranch * & branches);
02000     int chooseBranch(CbcNode * newNode, int numberPassesLeft, bool & resolved);
02001 
02008     CoinWarmStartBasis *getEmptyBasis(int ns = 0, int na = 0) const ;
02009 
02021     int takeOffCuts(OsiCuts &cuts,
02022                     bool allowResolve, OsiCuts * saveCuts,
02023                     int numberNewCuts = 0, const OsiRowCut ** newCuts = NULL) ;
02024 
02038     int addCuts(CbcNode * node, CoinWarmStartBasis *&lastws, bool canFix);
02039 
02056     bool addCuts1(CbcNode * node, CoinWarmStartBasis *&lastws);
02060     void previousBounds (CbcNode * node, CbcNodeInfo * where, int iColumn,
02061                          double & lower, double & upper, int force);
02066     void setObjectiveValue(CbcNode * thisNode, const CbcNode * parentNode) const;
02067 
02071     void convertToDynamic();
02073     void synchronizeNumberBeforeTrust(int type = 0);
02075     void zapIntegerInformation(bool leaveObjects = true);
02077     int cliquePseudoCosts(int doStatistics);
02079     void pseudoShadow(int type);
02086     void fillPseudoCosts(double * downCosts, double * upCosts,
02087                          int * priority = NULL,
02088                          int * numberDown = NULL, int * numberUp = NULL,
02089                          int * numberDownInfeasible = NULL,
02090                          int * numberUpInfeasible = NULL) const;
02096     void doHeuristicsAtRoot(int deleteHeuristicsAfterwards = 0);
02098     void adjustHeuristics();
02100     inline const double * hotstartSolution() const {
02101         return hotstartSolution_;
02102     }
02104     inline const int * hotstartPriorities() const {
02105         return hotstartPriorities_;
02106     }
02107 
02109     inline CbcCountRowCut ** addedCuts() const {
02110         return addedCuts_;
02111     }
02113     inline int currentNumberCuts() const {
02114         return currentNumberCuts_;
02115     }
02117     inline OsiCuts * globalCuts() {
02118         return &globalCuts_;
02119     }
02121     void setNextRowCut(const OsiRowCut & cut);
02123     inline CbcNode * currentNode() const {
02124         return currentNode_;
02125     }
02127     inline CglTreeProbingInfo * probingInfo() const {
02128         return probingInfo_;
02129     }
02131     inline CoinThreadRandom * randomNumberGenerator() {
02132         return &randomNumberGenerator_;
02133     }
02135     inline void setNumberStrongIterations(int number) {
02136         numberStrongIterations_ = number;
02137     }
02139     inline int numberStrongIterations() const {
02140         return numberStrongIterations_;
02141     }
02143     inline int maximumNumberIterations() const {
02144         return maximumNumberIterations_;
02145     }
02147     inline void setMaximumNumberIterations(int value) {
02148         maximumNumberIterations_ = value;
02149     }
02150 # ifdef COIN_HAS_CLP
02151 
02152     inline void setFastNodeDepth(int value) {
02153         fastNodeDepth_ = value;
02154     }
02156     inline int fastNodeDepth() const {
02157         return fastNodeDepth_;
02158     }
02160     inline int continuousPriority() const {
02161         return continuousPriority_;
02162     }
02164     inline void setContinuousPriority(int value) {
02165         continuousPriority_ = value;
02166     }
02167     inline void incrementExtra(int nodes, int iterations) {
02168         numberExtraNodes_ += nodes;
02169         numberExtraIterations_ += iterations;
02170     }
02171 #endif
02172 
02173     inline int numberExtraIterations() const {
02174         return numberExtraIterations_;
02175     }
02177     void incrementStrongInfo(int numberTimes, int numberIterations,
02178                              int numberFixed, bool ifInfeasible);
02180     inline const int * strongInfo() const {
02181         return strongInfo_;
02182     }
02183 
02185     inline int * mutableStrongInfo() {
02186         return strongInfo_;
02187     }
02189     CglStored * storedRowCuts() const {
02190         return storedRowCuts_;
02191     }
02193     void setStoredRowCuts(CglStored * cuts) {
02194         storedRowCuts_ = cuts;
02195     }
02197     inline bool allDynamic () const {
02198         return ((ownership_&0x40000000) != 0) ;
02199     }
02201     void generateCpp( FILE * fp, int options);
02203     OsiBranchingInformation usefulInformation() const;
02210     inline void setBestSolutionBasis(const CoinWarmStartBasis & bestSolutionBasis) {
02211         bestSolutionBasis_ = bestSolutionBasis;
02212     }
02214     void redoWalkBack();
02216 
02217 //---------------------------------------------------------------------------
02218 
02219 private:
02221 
02222 
02224     OsiSolverInterface * solver_;
02225 
02231     unsigned int ownership_ ;
02232 
02234     OsiSolverInterface * continuousSolver_;
02235 
02237     OsiSolverInterface * referenceSolver_;
02238 
02240     CoinMessageHandler * handler_;
02241 
02247     bool defaultHandler_;
02248 
02250     CoinMessages messages_;
02251 
02253     int intParam_[CbcLastIntParam];
02254 
02256     double dblParam_[CbcLastDblParam];
02257 
02266     mutable CoinWarmStart *emptyWarmStart_ ;
02267 
02269     double bestObjective_;
02271     double bestPossibleObjective_;
02273     double sumChangeObjective1_;
02275     double sumChangeObjective2_;
02276 
02278     double * bestSolution_;
02280     double ** savedSolutions_;
02281 
02286     double * currentSolution_;
02290     mutable const double * testSolution_;
02297     CoinWarmStartBasis bestSolutionBasis_ ;
02299     OsiCuts globalCuts_;
02300 
02302     double minimumDrop_;
02304     int numberSolutions_;
02306     int numberSavedSolutions_;
02308     int maximumSavedSolutions_;
02315     int stateOfSearch_;
02317     int whenCuts_;
02319     double * hotstartSolution_;
02321     int * hotstartPriorities_;
02323     int numberHeuristicSolutions_;
02325     int numberNodes_;
02329     int numberNodes2_;
02331     int numberIterations_;
02333     int numberSolves_;
02335     int status_;
02346     int secondaryStatus_;
02348     int numberIntegers_;
02350     int numberRowsAtContinuous_;
02352     int maximumNumberCuts_;
02361     int phase_;
02362 
02364     int currentNumberCuts_;
02365 
02370     int maximumDepth_;
02376     CbcNodeInfo ** walkback_;
02377     CbcNodeInfo ** lastNodeInfo_;
02378     const OsiRowCut ** lastCut_;
02379     int lastDepth_;
02380     int lastNumberCuts2_;
02381     int maximumCuts_;
02382     int * lastNumberCuts_;
02383 
02391     CbcCountRowCut ** addedCuts_;
02392 
02396     OsiRowCut * nextRowCut_;
02397 
02399     CbcNode * currentNode_;
02400 
02402     int * integerVariable_;
02404     char * integerInfo_;
02406     double * continuousSolution_;
02408     int * usedInSolution_;
02432     int specialOptions_;
02436     int moreSpecialOptions_;
02438     CbcCompareBase * nodeCompare_;
02440     CbcFeasibilityBase * problemFeasibility_;
02442     CbcTree * tree_;
02444     CbcModel * subTreeModel_;
02446     int numberStoppedSubTrees_;
02448     CbcBranchDecision * branchingMethod_;
02450     CbcCutModifier * cutModifier_;
02452     CbcStrategy * strategy_;
02454     CbcModel * parentModel_;
02460 
02461     const double * cbcColLower_;
02463     const double * cbcColUpper_;
02465     const double * cbcRowLower_;
02467     const double * cbcRowUpper_;
02469     const double * cbcColSolution_;
02471     const double * cbcRowPrice_;
02473     const double * cbcReducedCost_;
02475     const double * cbcRowActivity_;
02477     void * appData_;
02479     int presolve_;
02483     int numberStrong_;
02489     int numberBeforeTrust_;
02493     int numberPenalties_;
02495     int stopNumberIterations_;
02498     double penaltyScaleFactor_;
02500     int numberAnalyzeIterations_;
02502     double * analyzeResults_;
02504     int numberInfeasibleNodes_;
02511     int problemType_;
02513     int printFrequency_;
02515     int numberCutGenerators_;
02516     // Cut generators
02517     CbcCutGenerator ** generator_;
02518     // Cut generators before any changes
02519     CbcCutGenerator ** virginGenerator_;
02521     int numberHeuristics_;
02523     CbcHeuristic ** heuristic_;
02525     CbcHeuristic * lastHeuristic_;
02526 # ifdef COIN_HAS_CLP
02527 
02528     int fastNodeDepth_;
02529 #endif
02530 
02531 # ifdef CBC_ONLY_CLP
02532     ClpEventHandler *eventHandler_ ;
02533 # else
02534     CbcEventHandler *eventHandler_ ;
02535 # endif
02536 
02538     int numberObjects_;
02539 
02550     OsiObject ** object_;
02552     bool ownObjects_;
02553 
02555     int * originalColumns_;
02557     int howOftenGlobalScan_;
02560     int numberGlobalViolations_;
02562     int numberExtraIterations_;
02564     int numberExtraNodes_;
02568     double continuousObjective_;
02571     double originalContinuousObjective_;
02573     int continuousInfeasibilities_;
02575     int maximumCutPassesAtRoot_;
02577     int maximumCutPasses_;
02579     int preferredWay_;
02581     int currentPassNumber_;
02583     int maximumWhich_;
02585     int maximumRows_;
02587     int currentDepth_;
02589     mutable CoinThreadRandom randomNumberGenerator_;
02591     CoinWarmStartBasis workingBasis_;
02593     int * whichGenerator_;
02595     int maximumStatistics_;
02597     CbcStatistics ** statistics_;
02599     int maximumDepthActual_;
02601     double numberDJFixed_;
02603     CglTreeProbingInfo * probingInfo_;
02605     int numberFixedAtRoot_;
02607     int numberFixedNow_;
02609     bool stoppedOnGap_;
02611     mutable bool eventHappened_;
02613     int numberLongStrong_;
02615     int numberOldActiveCuts_;
02617     int numberNewCuts_;
02619     int searchStrategy_;
02621     int numberStrongIterations_;
02624     int strongInfo_[7];
02631     OsiBabSolver * solverCharacteristics_;
02633     bool resolveAfterTakeOffCuts_;
02635     int maximumNumberIterations_;
02637     int continuousPriority_;
02639     int numberUpdateItems_;
02641     int maximumNumberUpdateItems_;
02643     CbcObjectUpdateData * updateItems_;
02645     CglStored * storedRowCuts_;
02653     int numberThreads_;
02661     int threadMode_;
02663     CbcBaseModel * master_;
02665     CbcThread * masterThread_;
02667 };
02669 void getIntegerInformation(const OsiObject * object, double & originalLower,
02670                            double & originalUpper) ;
02671 // So we can call from other programs
02672 // Real main program
02673 class OsiClpSolverInterface;
02674 int CbcMain (int argc, const char *argv[], OsiClpSolverInterface & solver, CbcModel ** babSolver);
02675 int CbcMain (int argc, const char *argv[], CbcModel & babSolver);
02676 // four ways of calling
02677 int callCbc(const char * input2, OsiClpSolverInterface& solver1);
02678 int callCbc(const char * input2);
02679 int callCbc(const std::string input2, OsiClpSolverInterface& solver1);
02680 int callCbc(const std::string input2) ;
02681 // When we want to load up CbcModel with options first
02682 void CbcMain0 (CbcModel & babSolver);
02683 int CbcMain1 (int argc, const char *argv[], CbcModel & babSolver);
02684 // two ways of calling
02685 int callCbc(const char * input2, CbcModel & babSolver);
02686 int callCbc(const std::string input2, CbcModel & babSolver);
02687 // And when CbcMain0 already called to initialize
02688 int callCbc1(const char * input2, CbcModel & babSolver);
02689 int callCbc1(const std::string input2, CbcModel & babSolver);
02690 // And when CbcMain0 already called to initialize (with call back) (see CbcMain1 for whereFrom)
02691 int callCbc1(const char * input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02692 int callCbc1(const std::string input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02693 int CbcMain1 (int argc, const char *argv[], CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
02694 // For uniform setting of cut and heuristic options
02695 void setCutAndHeuristicOptions(CbcModel & model);
02696 #endif
02697 

Generated on Tue Sep 7 2010 20:23:52 by  doxygen 1.7.1