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

Go to the documentation of this file.
00001 // Copyright (C) 2005, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #ifndef CbcBranchDynamic_H
00004 #define CbcBranchDynamic_H
00005 
00006 #include "CbcBranchActual.hpp"
00007 #include "CoinPackedMatrix.hpp"
00008 
00009 
00019 class CbcSimpleIntegerDynamicPseudoCost : public CbcSimpleInteger {
00020 
00021 public:
00022 
00023   // Default Constructor 
00024   CbcSimpleIntegerDynamicPseudoCost ();
00025 
00026   // Useful constructor - passed  model index
00027   CbcSimpleIntegerDynamicPseudoCost (CbcModel * model,  int iColumn, double breakEven=0.5);
00028   
00029   // Useful constructor - passed  model index and pseudo costs
00030   CbcSimpleIntegerDynamicPseudoCost (CbcModel * model, int iColumn, 
00031                               double downDynamicPseudoCost, double upDynamicPseudoCost);
00032   
00033   // Useful constructor - passed  model index and pseudo costs
00034   CbcSimpleIntegerDynamicPseudoCost (CbcModel * model, int dummy, int iColumn, 
00035                               double downDynamicPseudoCost, double upDynamicPseudoCost);
00036   
00037   // Copy constructor 
00038   CbcSimpleIntegerDynamicPseudoCost ( const CbcSimpleIntegerDynamicPseudoCost &);
00039    
00041   virtual CbcObject * clone() const;
00042 
00043   // Assignment operator 
00044   CbcSimpleIntegerDynamicPseudoCost & operator=( const CbcSimpleIntegerDynamicPseudoCost& rhs);
00045 
00046   // Destructor 
00047   ~CbcSimpleIntegerDynamicPseudoCost ();
00048   
00049   using CbcObject::infeasibility ;
00051   virtual double infeasibility(int & preferredWay) const;
00052 
00053   using CbcObject::createBranch ;
00055   virtual CbcBranchingObject * createBranch(int way) ;
00056 
00058   virtual double infeasibility(const OsiSolverInterface * solver, 
00059                                const OsiBranchingInformation * info, int & preferredWay) const;
00060 
00061 
00067   virtual CbcBranchingObject * createBranch(OsiSolverInterface * solver,
00068                                             const OsiBranchingInformation * info, int way) ;
00070   void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
00071 
00072 
00076   virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface * solver, 
00077                                                         const CbcNode * node,
00078                                                         const CbcBranchingObject * branchingObject);
00080   virtual void updateInformation(const CbcObjectUpdateData & data) ;
00082   void copySome(const CbcSimpleIntegerDynamicPseudoCost * otherObject);
00084   virtual void updateBefore(const OsiObject * rhs) ;
00086   virtual void updateAfter(const OsiObject * rhs, const OsiObject * baseObject) ;
00088   void updateAfterMini(int numberDown,int numberDownInfeasible,double sumDown, 
00089                        int numberUp,int numberUpInfeasible,double sumUp);
00090 
00091   using CbcSimpleInteger::solverBranch ;
00096   virtual OsiSolverBranch * solverBranch() const;
00097   
00099   inline double downDynamicPseudoCost() const
00100   { return downDynamicPseudoCost_;}
00102   inline void setDownDynamicPseudoCost(double value)
00103   { downDynamicPseudoCost_=value;}
00104 
00106   inline double upDynamicPseudoCost() const
00107   { return upDynamicPseudoCost_;}
00109   inline void setUpDynamicPseudoCost(double value)
00110   { upDynamicPseudoCost_=value;}
00111 
00113   inline double upDownSeparator() const
00114   { return upDownSeparator_;}
00116   inline void setUpDownSeparator(double value)
00117   { upDownSeparator_=value;}
00118 
00120   inline double sumDownCost() const
00121   { return sumDownCost_;}
00123   inline void setSumDownCost(double value)
00124   { sumDownCost_=value;}
00126   inline void addToSumDownCost(double value)
00127   { sumDownCost_+=value;lastDownCost_=value;sumDownCostSquared_ += value*value;}
00128 
00130   inline double sumUpCost() const
00131   { return sumUpCost_;}
00133   inline void setSumUpCost(double value)
00134   { sumUpCost_=value;}
00136   inline void addToSumUpCost(double value)
00137   { sumUpCost_+=value;lastUpCost_=value;sumUpCostSquared_ += value*value;}
00138 
00140   inline double sumDownChange() const
00141   { return sumDownChange_;}
00143   inline void setSumDownChange(double value)
00144   { sumDownChange_=value;}
00146   inline void addToSumDownChange(double value)
00147   { sumDownChange_+=value;}
00148 
00150   inline double sumUpChange() const
00151   { return sumUpChange_;}
00153   inline void setSumUpChange(double value)
00154   { sumUpChange_=value;}
00156   inline void addToSumUpChange(double value)
00157   { sumUpChange_+=value;}
00158 
00160   inline double sumDownDecrease() const
00161   { return sumDownDecrease_;}
00163   inline void setSumDownDecrease(double value)
00164   { sumDownDecrease_=value;}
00166   inline void addToSumDownDecrease(double value)
00167   { sumDownDecrease_+=value;/*lastDownDecrease_ = (int) value;*/}
00168 
00170   inline double sumUpDecrease() const
00171   { return sumUpDecrease_;}
00173   inline void setSumUpDecrease(double value)
00174   { sumUpDecrease_=value;}
00176   inline void addToSumUpDecrease(double value)
00177   { sumUpDecrease_+=value;/*lastUpDecrease_ = (int) value;*/}
00178 
00180   inline int numberTimesDown() const
00181   { return numberTimesDown_;}
00183   inline void setNumberTimesDown(int value)
00184   { numberTimesDown_=value;}
00186   inline void incrementNumberTimesDown()
00187   { numberTimesDown_++;}
00188 
00190   inline int numberTimesUp() const
00191   { return numberTimesUp_;}
00193   inline void setNumberTimesUp(int value)
00194   { numberTimesUp_=value;}
00196   inline void incrementNumberTimesUp()
00197   { numberTimesUp_++;}
00198 
00200   inline int numberTimesDownInfeasible() const
00201   { return numberTimesDownInfeasible_;}
00203   inline void setNumberTimesDownInfeasible(int value)
00204   { numberTimesDownInfeasible_=value;}
00206   inline void incrementNumberTimesDownInfeasible()
00207   { numberTimesDownInfeasible_++;}
00208 
00210   inline int numberTimesUpInfeasible() const
00211   { return numberTimesUpInfeasible_;}
00213   inline void setNumberTimesUpInfeasible(int value)
00214   { numberTimesUpInfeasible_=value;}
00216   inline void incrementNumberTimesUpInfeasible()
00217   { numberTimesUpInfeasible_++;}
00218 
00220   inline int numberBeforeTrust() const
00221   { return numberBeforeTrust_;}
00223   inline void setNumberBeforeTrust(int value)
00224   { numberBeforeTrust_=value;}
00225 
00227   virtual double upEstimate() const;
00229   virtual double downEstimate() const;
00230   
00232   inline int method() const
00233   { return method_;}
00235   inline void setMethod(int value)
00236   { method_=value;}
00237 
00239   void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown);
00241   void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp);
00243   void setProbingInformation(int fixedDown, int fixedUp);
00244 
00246   void print(int type=0, double value=0.0) const;
00248   bool same(const CbcSimpleIntegerDynamicPseudoCost * obj) const;
00249 protected:
00251 
00253   double downDynamicPseudoCost_;
00255   double upDynamicPseudoCost_;
00260   double upDownSeparator_;
00262   double sumDownCost_;
00264   double sumUpCost_;
00266   double sumDownChange_;
00268   double sumUpChange_;
00270   mutable double sumDownCostSquared_;
00272   mutable double sumUpCostSquared_;
00274   double sumDownDecrease_;
00276   double sumUpDecrease_;
00278   double lastDownCost_;
00280   double lastUpCost_;
00282   mutable int lastDownDecrease_;
00284   mutable int lastUpDecrease_;
00286   int numberTimesDown_;
00288   int numberTimesUp_;
00290   int numberTimesDownInfeasible_;
00292   int numberTimesUpInfeasible_;
00294   int numberBeforeTrust_;
00296   int numberTimesDownLocalFixed_;
00298   int numberTimesUpLocalFixed_;
00300   double numberTimesDownTotalFixed_;
00302   double numberTimesUpTotalFixed_;
00304   int numberTimesProbingTotal_;
00306 #define CBC_INSTRUMENT
00307 #ifdef CBC_INSTRUMENT
00308   mutable int numberTimesInfeasible_;
00309 #endif
00310 
00314   int method_;
00315 };
00316 
00317 
00328 class CbcDynamicPseudoCostBranchingObject : public CbcIntegerBranchingObject {
00329 
00330 public:
00331 
00333   CbcDynamicPseudoCostBranchingObject ();
00334 
00342   CbcDynamicPseudoCostBranchingObject (CbcModel *model, int variable,
00343                                        int way , double value, 
00344                                        CbcSimpleIntegerDynamicPseudoCost * object) ;
00345   
00353   CbcDynamicPseudoCostBranchingObject (CbcModel *model, int variable, int way,
00354                              double lowerValue, double upperValue) ;
00355   
00357   CbcDynamicPseudoCostBranchingObject ( const CbcDynamicPseudoCostBranchingObject &);
00358    
00360   CbcDynamicPseudoCostBranchingObject & operator= (const CbcDynamicPseudoCostBranchingObject& rhs);
00361 
00363   virtual CbcBranchingObject * clone() const;
00364 
00366   virtual ~CbcDynamicPseudoCostBranchingObject ();
00367 
00369   void fillPart (int variable,
00370              int way , double value, 
00371              CbcSimpleIntegerDynamicPseudoCost * object) ;
00372   
00373   using CbcBranchingObject::branch ;
00378   virtual double branch();
00379 
00384   virtual int fillStrongInfo( CbcStrongInfo & info);
00385 
00387   inline double changeInGuessed() const
00388   { return changeInGuessed_;}
00390   inline void setChangeInGuessed(double value)
00391   { changeInGuessed_=value;}
00393   inline CbcSimpleIntegerDynamicPseudoCost * object() const
00394   { return object_;}
00396   inline void setObject(CbcSimpleIntegerDynamicPseudoCost * object)
00397   { object_=object;}
00398 
00400   virtual int type() const { return 400; }
00401 
00402   // LL: compareOriginalObject and compareBranchingObject are inherited from
00403   // CbcIntegerBranchingObject thus need not be declared/defined here. After
00404   // all, this kind of branching object is simply using pseudocosts to make
00405   // decisions, but once the decisions are made they are the same kind as in
00406   // the underlying class.
00407 
00408 protected:
00410   double changeInGuessed_;
00412   CbcSimpleIntegerDynamicPseudoCost * object_;
00413 
00414 };
00421 class CbcBranchDynamicDecision : public CbcBranchDecision {
00422 public:
00423   // Default Constructor 
00424   CbcBranchDynamicDecision ();
00425 
00426   // Copy constructor 
00427   CbcBranchDynamicDecision ( const CbcBranchDynamicDecision &);
00428 
00429   virtual ~CbcBranchDynamicDecision();
00430 
00432   virtual CbcBranchDecision * clone() const;
00433 
00435   virtual void initialize(CbcModel * model);
00436 
00456   virtual int betterBranch(CbcBranchingObject * thisOne,
00457                             CbcBranchingObject * bestSoFar,
00458                             double changeUp, int numInfUp,
00459                             double changeDn, int numInfDn);
00461   virtual void setBestCriterion(double value);
00462   virtual double getBestCriterion() const;
00465   virtual int whichMethod() {return 3;}
00466 
00469   virtual void saveBranchingObject(OsiBranchingObject * object) ;
00472   virtual void updateInformation(OsiSolverInterface * solver,
00473                                  const CbcNode * node);
00474 
00475 
00476 private:
00477   
00479   CbcBranchDynamicDecision & operator=(const CbcBranchDynamicDecision& rhs);
00480 
00482 
00484   double bestCriterion_;
00485 
00487   double bestChangeUp_;
00488 
00490   int bestNumberUp_;
00491 
00493   double bestChangeDown_;
00494 
00496   int bestNumberDown_;
00497 
00499   CbcBranchingObject * bestObject_;
00500 };
00501 #endif

Generated on Thu Sep 18 03:00:39 2008 by  doxygen 1.4.7