/home/coin/SVN-release/Cbc-2.4.1/Cbc/src/CbcBranchDynamic.hpp

Go to the documentation of this file.
00001 /* $Id: CbcBranchDynamic.hpp 1271 2009-11-05 15:57:25Z forrest $ */
00002 // Copyright (C) 2005, International Business Machines
00003 // Corporation and others.  All Rights Reserved.
00004 #ifndef CbcBranchDynamic_H
00005 #define CbcBranchDynamic_H
00006 
00007 #include "CbcBranchActual.hpp"
00008 #include "CoinPackedMatrix.hpp"
00009 
00010 
00020 class CbcSimpleIntegerDynamicPseudoCost : public CbcSimpleInteger {
00021 
00022 public:
00023 
00024   // Default Constructor 
00025   CbcSimpleIntegerDynamicPseudoCost ();
00026 
00027   // Useful constructor - passed  model index
00028   CbcSimpleIntegerDynamicPseudoCost (CbcModel * model,  int iColumn, double breakEven=0.5);
00029   
00030   // Useful constructor - passed  model index and pseudo costs
00031   CbcSimpleIntegerDynamicPseudoCost (CbcModel * model, int iColumn, 
00032                               double downDynamicPseudoCost, double upDynamicPseudoCost);
00033   
00034   // Useful constructor - passed  model index and pseudo costs
00035   CbcSimpleIntegerDynamicPseudoCost (CbcModel * model,int dummy, int iColumn, 
00036                               double downDynamicPseudoCost, double upDynamicPseudoCost);
00037   
00038   // Copy constructor 
00039   CbcSimpleIntegerDynamicPseudoCost ( const CbcSimpleIntegerDynamicPseudoCost &);
00040    
00042   virtual CbcObject * clone() const;
00043 
00044   // Assignment operator 
00045   CbcSimpleIntegerDynamicPseudoCost & operator=( const CbcSimpleIntegerDynamicPseudoCost& rhs);
00046 
00047   // Destructor 
00048   virtual ~CbcSimpleIntegerDynamicPseudoCost ();
00049   
00051   virtual double infeasibility(const OsiBranchingInformation * info,
00052                                int &preferredWay) const;
00053 
00055   virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
00056 
00057 
00059   void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
00060 
00061 
00065   virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface * solver, 
00066                                                         const CbcNode * node,
00067                                                         const CbcBranchingObject * branchingObject);
00069   virtual void updateInformation(const CbcObjectUpdateData & data) ;
00071   void copySome(const CbcSimpleIntegerDynamicPseudoCost * otherObject);
00073   virtual void updateBefore(const OsiObject * rhs) ;
00075   virtual void updateAfter(const OsiObject * rhs, const OsiObject * baseObject) ;
00077   void updateAfterMini(int numberDown,int numberDownInfeasible,double sumDown, 
00078                        int numberUp,int numberUpInfeasible,double sumUp);
00079 
00080   using CbcSimpleInteger::solverBranch ;
00085   virtual OsiSolverBranch * solverBranch() const;
00086   
00088   inline double downDynamicPseudoCost() const
00089   { return downDynamicPseudoCost_;}
00091   void setDownDynamicPseudoCost(double value) ;
00093   void updateDownDynamicPseudoCost(double value);
00094 
00096   inline double upDynamicPseudoCost() const
00097   { return upDynamicPseudoCost_;}
00099   void setUpDynamicPseudoCost(double value);
00101   void updateUpDynamicPseudoCost(double value);
00102 
00104   inline double downShadowPrice() const
00105   { return downShadowPrice_;}
00107   inline void setDownShadowPrice(double value) 
00108   { downShadowPrice_ = value;}
00110   inline double upShadowPrice() const
00111   { return upShadowPrice_;}
00113   inline void setUpShadowPrice(double value)
00114   { upShadowPrice_ = value;}
00115 
00117   inline double upDownSeparator() const
00118   { return upDownSeparator_;}
00120   inline void setUpDownSeparator(double value)
00121   { upDownSeparator_=value;}
00122 
00124   inline double sumDownCost() const
00125   { return sumDownCost_;}
00127   inline void setSumDownCost(double value)
00128   { sumDownCost_=value;}
00130   inline void addToSumDownCost(double value)
00131   { sumDownCost_+=value;lastDownCost_=value;}
00132 
00134   inline double sumUpCost() const
00135   { return sumUpCost_;}
00137   inline void setSumUpCost(double value)
00138   { sumUpCost_=value;}
00140   inline void addToSumUpCost(double value)
00141   { sumUpCost_+=value;lastUpCost_=value;}
00142 
00144   inline double sumDownChange() const
00145   { return sumDownChange_;}
00147   inline void setSumDownChange(double value)
00148   { sumDownChange_=value;}
00150   inline void addToSumDownChange(double value)
00151   { sumDownChange_+=value;}
00152 
00154   inline double sumUpChange() const
00155   { return sumUpChange_;}
00157   inline void setSumUpChange(double value)
00158   { sumUpChange_=value;}
00160   inline void addToSumUpChange(double value)
00161   { sumUpChange_+=value;}
00162 
00164   inline double sumDownDecrease() const
00165   { return sumDownDecrease_;}
00167   inline void setSumDownDecrease(double value)
00168   { sumDownDecrease_=value;}
00170   inline void addToSumDownDecrease(double value)
00171   { sumDownDecrease_+=value;/*lastDownDecrease_ = (int) value;*/}
00172 
00174   inline double sumUpDecrease() const
00175   { return sumUpDecrease_;}
00177   inline void setSumUpDecrease(double value)
00178   { sumUpDecrease_=value;}
00180   inline void addToSumUpDecrease(double value)
00181   { sumUpDecrease_+=value;/*lastUpDecrease_ = (int) value;*/}
00182 
00184   inline int numberTimesDown() const
00185   { return numberTimesDown_;}
00187   inline void setNumberTimesDown(int value)
00188   { numberTimesDown_=value;}
00190   inline void incrementNumberTimesDown()
00191   { numberTimesDown_++;}
00192 
00194   inline int numberTimesUp() const
00195   { return numberTimesUp_;}
00197   inline void setNumberTimesUp(int value)
00198   { numberTimesUp_=value;}
00200   inline void incrementNumberTimesUp()
00201   { numberTimesUp_++;}
00202 
00204   inline int numberTimesDownInfeasible() const
00205   { return numberTimesDownInfeasible_;}
00207   inline void setNumberTimesDownInfeasible(int value)
00208   { numberTimesDownInfeasible_=value;}
00210   inline void incrementNumberTimesDownInfeasible()
00211   { numberTimesDownInfeasible_++;}
00212 
00214   inline int numberTimesUpInfeasible() const
00215   { return numberTimesUpInfeasible_;}
00217   inline void setNumberTimesUpInfeasible(int value)
00218   { numberTimesUpInfeasible_=value;}
00220   inline void incrementNumberTimesUpInfeasible()
00221   { numberTimesUpInfeasible_++;}
00222 
00224   inline int numberBeforeTrust() const
00225   { return numberBeforeTrust_;}
00227   inline void setNumberBeforeTrust(int value)
00228   { numberBeforeTrust_=value;}
00230   inline void incrementNumberBeforeTrust()
00231   { numberBeforeTrust_++;}
00232 
00234   virtual double upEstimate() const;
00236   virtual double downEstimate() const;
00237   
00239   inline int method() const
00240   { return method_;}
00242   inline void setMethod(int value)
00243   { method_=value;}
00244 
00246   void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown);
00248   void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp);
00250   void setProbingInformation(int fixedDown, int fixedUp);
00251 
00253   void print(int type=0, double value=0.0) const;
00255   bool same(const CbcSimpleIntegerDynamicPseudoCost * obj) const;
00256 protected:
00258 
00260   double downDynamicPseudoCost_;
00262   double upDynamicPseudoCost_;
00267   double upDownSeparator_;
00269   double sumDownCost_;
00271   double sumUpCost_;
00273   double sumDownChange_;
00275   double sumUpChange_;
00277   mutable double downShadowPrice_;
00279   mutable double upShadowPrice_;
00281   double sumDownDecrease_;
00283   double sumUpDecrease_;
00285   double lastDownCost_;
00287   double lastUpCost_;
00289   mutable int lastDownDecrease_;
00291   mutable int lastUpDecrease_;
00293   int numberTimesDown_;
00295   int numberTimesUp_;
00297   int numberTimesDownInfeasible_;
00299   int numberTimesUpInfeasible_;
00301   int numberBeforeTrust_;
00303   int numberTimesDownLocalFixed_;
00305   int numberTimesUpLocalFixed_;
00307   double numberTimesDownTotalFixed_;
00309   double numberTimesUpTotalFixed_;
00311   int numberTimesProbingTotal_;
00313 
00317   int method_;
00318 };
00319 
00320 
00331 class CbcDynamicPseudoCostBranchingObject : public CbcIntegerBranchingObject {
00332 
00333 public:
00334 
00336   CbcDynamicPseudoCostBranchingObject ();
00337 
00345   CbcDynamicPseudoCostBranchingObject (CbcModel *model, int variable,
00346                                        int way , double value, 
00347                                        CbcSimpleIntegerDynamicPseudoCost * object) ;
00348   
00356   CbcDynamicPseudoCostBranchingObject (CbcModel *model, int variable, int way,
00357                              double lowerValue, double upperValue) ;
00358   
00360   CbcDynamicPseudoCostBranchingObject ( const CbcDynamicPseudoCostBranchingObject &);
00361    
00363   CbcDynamicPseudoCostBranchingObject & operator= (const CbcDynamicPseudoCostBranchingObject& rhs);
00364 
00366   virtual CbcBranchingObject * clone() const;
00367 
00369   virtual ~CbcDynamicPseudoCostBranchingObject ();
00370 
00372   void fillPart (int variable,
00373              int way , double value, 
00374              CbcSimpleIntegerDynamicPseudoCost * object) ;
00375   
00376   using CbcBranchingObject::branch ;
00381   virtual double branch();
00382 
00387   virtual int fillStrongInfo( CbcStrongInfo & info);
00388 
00390   inline double changeInGuessed() const
00391   { return changeInGuessed_;}
00393   inline void setChangeInGuessed(double value)
00394   { changeInGuessed_=value;}
00396   inline CbcSimpleIntegerDynamicPseudoCost * object() const
00397   { return object_;}
00399   inline void setObject(CbcSimpleIntegerDynamicPseudoCost * object)
00400   { object_=object;}
00401 
00403   virtual int type() const { return 400; }
00404 
00405   // LL: compareOriginalObject and compareBranchingObject are inherited from
00406   // CbcIntegerBranchingObject thus need not be declared/defined here. After
00407   // all, this kind of branching object is simply using pseudocosts to make
00408   // decisions, but once the decisions are made they are the same kind as in
00409   // the underlying class.
00410 
00411 protected:
00413   double changeInGuessed_;
00415   CbcSimpleIntegerDynamicPseudoCost * object_;
00416 
00417 };
00424 class CbcBranchDynamicDecision : public CbcBranchDecision {
00425 public:
00426   // Default Constructor 
00427   CbcBranchDynamicDecision ();
00428 
00429   // Copy constructor 
00430   CbcBranchDynamicDecision ( const CbcBranchDynamicDecision &);
00431 
00432   virtual ~CbcBranchDynamicDecision();
00433 
00435   virtual CbcBranchDecision * clone() const;
00436 
00438   virtual void initialize(CbcModel * model);
00439 
00459   virtual int betterBranch(CbcBranchingObject * thisOne,
00460                             CbcBranchingObject * bestSoFar,
00461                             double changeUp, int numInfUp,
00462                             double changeDn, int numInfDn);
00464   virtual void setBestCriterion(double value);
00465   virtual double getBestCriterion() const;
00468   virtual int whichMethod() {return 3;}
00469 
00472   virtual void saveBranchingObject(OsiBranchingObject * object) ;
00475   virtual void updateInformation(OsiSolverInterface * solver,
00476                                  const CbcNode * node);
00477 
00478 
00479 private:
00480   
00482   CbcBranchDynamicDecision & operator=(const CbcBranchDynamicDecision& rhs);
00483 
00485 
00487   double bestCriterion_;
00488 
00490   double bestChangeUp_;
00491 
00493   int bestNumberUp_;
00494 
00496   double bestChangeDown_;
00497 
00499   int bestNumberDown_;
00500 
00502   CbcBranchingObject * bestObject_;
00503 };
00504 #endif

Generated on Thu Apr 8 03:02:02 2010 by  doxygen 1.4.7