/home/coin/SVN-release/Cbc-2.3.2/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   virtual ~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   void setDownDynamicPseudoCost(double value) ;
00103 
00105   inline double upDynamicPseudoCost() const
00106   { return upDynamicPseudoCost_;}
00108   void setUpDynamicPseudoCost(double value);
00109 
00111   inline double upDownSeparator() const
00112   { return upDownSeparator_;}
00114   inline void setUpDownSeparator(double value)
00115   { upDownSeparator_=value;}
00116 
00118   inline double sumDownCost() const
00119   { return sumDownCost_;}
00121   inline void setSumDownCost(double value)
00122   { sumDownCost_=value;}
00124   inline void addToSumDownCost(double value)
00125   { sumDownCost_+=value;lastDownCost_=value;sumDownCostSquared_ += value*value;}
00126 
00128   inline double sumUpCost() const
00129   { return sumUpCost_;}
00131   inline void setSumUpCost(double value)
00132   { sumUpCost_=value;}
00134   inline void addToSumUpCost(double value)
00135   { sumUpCost_+=value;lastUpCost_=value;sumUpCostSquared_ += value*value;}
00136 
00138   inline double sumDownChange() const
00139   { return sumDownChange_;}
00141   inline void setSumDownChange(double value)
00142   { sumDownChange_=value;}
00144   inline void addToSumDownChange(double value)
00145   { sumDownChange_+=value;}
00146 
00148   inline double sumUpChange() const
00149   { return sumUpChange_;}
00151   inline void setSumUpChange(double value)
00152   { sumUpChange_=value;}
00154   inline void addToSumUpChange(double value)
00155   { sumUpChange_+=value;}
00156 
00158   inline double sumDownDecrease() const
00159   { return sumDownDecrease_;}
00161   inline void setSumDownDecrease(double value)
00162   { sumDownDecrease_=value;}
00164   inline void addToSumDownDecrease(double value)
00165   { sumDownDecrease_+=value;/*lastDownDecrease_ = (int) value;*/}
00166 
00168   inline double sumUpDecrease() const
00169   { return sumUpDecrease_;}
00171   inline void setSumUpDecrease(double value)
00172   { sumUpDecrease_=value;}
00174   inline void addToSumUpDecrease(double value)
00175   { sumUpDecrease_+=value;/*lastUpDecrease_ = (int) value;*/}
00176 
00178   inline int numberTimesDown() const
00179   { return numberTimesDown_;}
00181   inline void setNumberTimesDown(int value)
00182   { numberTimesDown_=value;}
00184   inline void incrementNumberTimesDown()
00185   { numberTimesDown_++;}
00186 
00188   inline int numberTimesUp() const
00189   { return numberTimesUp_;}
00191   inline void setNumberTimesUp(int value)
00192   { numberTimesUp_=value;}
00194   inline void incrementNumberTimesUp()
00195   { numberTimesUp_++;}
00196 
00198   inline int numberTimesDownInfeasible() const
00199   { return numberTimesDownInfeasible_;}
00201   inline void setNumberTimesDownInfeasible(int value)
00202   { numberTimesDownInfeasible_=value;}
00204   inline void incrementNumberTimesDownInfeasible()
00205   { numberTimesDownInfeasible_++;}
00206 
00208   inline int numberTimesUpInfeasible() const
00209   { return numberTimesUpInfeasible_;}
00211   inline void setNumberTimesUpInfeasible(int value)
00212   { numberTimesUpInfeasible_=value;}
00214   inline void incrementNumberTimesUpInfeasible()
00215   { numberTimesUpInfeasible_++;}
00216 
00218   inline int numberBeforeTrust() const
00219   { return numberBeforeTrust_;}
00221   inline void setNumberBeforeTrust(int value)
00222   { numberBeforeTrust_=value;}
00224   inline void incrementNumberBeforeTrust()
00225   { numberBeforeTrust_++;}
00226 
00228   virtual double upEstimate() const;
00230   virtual double downEstimate() const;
00231   
00233   inline int method() const
00234   { return method_;}
00236   inline void setMethod(int value)
00237   { method_=value;}
00238 
00240   void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown);
00242   void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp);
00244   void setProbingInformation(int fixedDown, int fixedUp);
00245 
00247   void print(int type=0, double value=0.0) const;
00249   bool same(const CbcSimpleIntegerDynamicPseudoCost * obj) const;
00250 protected:
00252 
00254   double downDynamicPseudoCost_;
00256   double upDynamicPseudoCost_;
00261   double upDownSeparator_;
00263   double sumDownCost_;
00265   double sumUpCost_;
00267   double sumDownChange_;
00269   double sumUpChange_;
00271   mutable double sumDownCostSquared_;
00273   mutable double sumUpCostSquared_;
00275   double sumDownDecrease_;
00277   double sumUpDecrease_;
00279   double lastDownCost_;
00281   double lastUpCost_;
00283   mutable int lastDownDecrease_;
00285   mutable int lastUpDecrease_;
00287   int numberTimesDown_;
00289   int numberTimesUp_;
00291   int numberTimesDownInfeasible_;
00293   int numberTimesUpInfeasible_;
00295   int numberBeforeTrust_;
00297   int numberTimesDownLocalFixed_;
00299   int numberTimesUpLocalFixed_;
00301   double numberTimesDownTotalFixed_;
00303   double numberTimesUpTotalFixed_;
00305   int numberTimesProbingTotal_;
00307 #define CBC_INSTRUMENT
00308 #ifdef CBC_INSTRUMENT
00309   mutable int numberTimesInfeasible_;
00310 #endif
00311 
00315   int method_;
00316 };
00317 
00318 
00329 class CbcDynamicPseudoCostBranchingObject : public CbcIntegerBranchingObject {
00330 
00331 public:
00332 
00334   CbcDynamicPseudoCostBranchingObject ();
00335 
00343   CbcDynamicPseudoCostBranchingObject (CbcModel *model, int variable,
00344                                        int way , double value, 
00345                                        CbcSimpleIntegerDynamicPseudoCost * object) ;
00346   
00354   CbcDynamicPseudoCostBranchingObject (CbcModel *model, int variable, int way,
00355                              double lowerValue, double upperValue) ;
00356   
00358   CbcDynamicPseudoCostBranchingObject ( const CbcDynamicPseudoCostBranchingObject &);
00359    
00361   CbcDynamicPseudoCostBranchingObject & operator= (const CbcDynamicPseudoCostBranchingObject& rhs);
00362 
00364   virtual CbcBranchingObject * clone() const;
00365 
00367   virtual ~CbcDynamicPseudoCostBranchingObject ();
00368 
00370   void fillPart (int variable,
00371              int way , double value, 
00372              CbcSimpleIntegerDynamicPseudoCost * object) ;
00373   
00374   using CbcBranchingObject::branch ;
00379   virtual double branch();
00380 
00385   virtual int fillStrongInfo( CbcStrongInfo & info);
00386 
00388   inline double changeInGuessed() const
00389   { return changeInGuessed_;}
00391   inline void setChangeInGuessed(double value)
00392   { changeInGuessed_=value;}
00394   inline CbcSimpleIntegerDynamicPseudoCost * object() const
00395   { return object_;}
00397   inline void setObject(CbcSimpleIntegerDynamicPseudoCost * object)
00398   { object_=object;}
00399 
00401   virtual int type() const { return 400; }
00402 
00403   // LL: compareOriginalObject and compareBranchingObject are inherited from
00404   // CbcIntegerBranchingObject thus need not be declared/defined here. After
00405   // all, this kind of branching object is simply using pseudocosts to make
00406   // decisions, but once the decisions are made they are the same kind as in
00407   // the underlying class.
00408 
00409 protected:
00411   double changeInGuessed_;
00413   CbcSimpleIntegerDynamicPseudoCost * object_;
00414 
00415 };
00422 class CbcBranchDynamicDecision : public CbcBranchDecision {
00423 public:
00424   // Default Constructor 
00425   CbcBranchDynamicDecision ();
00426 
00427   // Copy constructor 
00428   CbcBranchDynamicDecision ( const CbcBranchDynamicDecision &);
00429 
00430   virtual ~CbcBranchDynamicDecision();
00431 
00433   virtual CbcBranchDecision * clone() const;
00434 
00436   virtual void initialize(CbcModel * model);
00437 
00457   virtual int betterBranch(CbcBranchingObject * thisOne,
00458                             CbcBranchingObject * bestSoFar,
00459                             double changeUp, int numInfUp,
00460                             double changeDn, int numInfDn);
00462   virtual void setBestCriterion(double value);
00463   virtual double getBestCriterion() const;
00466   virtual int whichMethod() {return 3;}
00467 
00470   virtual void saveBranchingObject(OsiBranchingObject * object) ;
00473   virtual void updateInformation(OsiSolverInterface * solver,
00474                                  const CbcNode * node);
00475 
00476 
00477 private:
00478   
00480   CbcBranchDynamicDecision & operator=(const CbcBranchDynamicDecision& rhs);
00481 
00483 
00485   double bestCriterion_;
00486 
00488   double bestChangeUp_;
00489 
00491   int bestNumberUp_;
00492 
00494   double bestChangeDown_;
00495 
00497   int bestNumberDown_;
00498 
00500   CbcBranchingObject * bestObject_;
00501 };
00502 #endif

Generated on Wed Oct 7 03:01:15 2009 by  doxygen 1.4.7