/home/coin/SVN-release/CoinAll-1.1.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) ;
00087 
00088   using CbcSimpleInteger::solverBranch ;
00093   virtual OsiSolverBranch * solverBranch() const;
00094   
00096   inline double downDynamicPseudoCost() const
00097   { return downDynamicPseudoCost_;}
00099   inline void setDownDynamicPseudoCost(double value)
00100   { downDynamicPseudoCost_=value;}
00101 
00103   inline double upDynamicPseudoCost() const
00104   { return upDynamicPseudoCost_;}
00106   inline void setUpDynamicPseudoCost(double value)
00107   { upDynamicPseudoCost_=value;}
00108 
00110   inline double upDownSeparator() const
00111   { return upDownSeparator_;}
00113   inline void setUpDownSeparator(double value)
00114   { upDownSeparator_=value;}
00115 
00117   inline double sumDownCost() const
00118   { return sumDownCost_;}
00120   inline void setSumDownCost(double value)
00121   { sumDownCost_=value;}
00123   inline void addToSumDownCost(double value)
00124   { sumDownCost_+=value;lastDownCost_=value;sumDownCostSquared_ += value*value;}
00125 
00127   inline double sumUpCost() const
00128   { return sumUpCost_;}
00130   inline void setSumUpCost(double value)
00131   { sumUpCost_=value;}
00133   inline void addToSumUpCost(double value)
00134   { sumUpCost_+=value;lastUpCost_=value;sumUpCostSquared_ += value*value;}
00135 
00137   inline double sumDownChange() const
00138   { return sumDownChange_;}
00140   inline void setSumDownChange(double value)
00141   { sumDownChange_=value;}
00143   inline void addToSumDownChange(double value)
00144   { sumDownChange_+=value;}
00145 
00147   inline double sumUpChange() const
00148   { return sumUpChange_;}
00150   inline void setSumUpChange(double value)
00151   { sumUpChange_=value;}
00153   inline void addToSumUpChange(double value)
00154   { sumUpChange_+=value;}
00155 
00157   inline double sumDownDecrease() const
00158   { return sumDownDecrease_;}
00160   inline void setSumDownDecrease(double value)
00161   { sumDownDecrease_=value;}
00163   inline void addToSumDownDecrease(double value)
00164   { sumDownDecrease_+=value;/*lastDownDecrease_ = (int) value;*/}
00165 
00167   inline double sumUpDecrease() const
00168   { return sumUpDecrease_;}
00170   inline void setSumUpDecrease(double value)
00171   { sumUpDecrease_=value;}
00173   inline void addToSumUpDecrease(double value)
00174   { sumUpDecrease_+=value;/*lastUpDecrease_ = (int) value;*/}
00175 
00177   inline int numberTimesDown() const
00178   { return numberTimesDown_;}
00180   inline void setNumberTimesDown(int value)
00181   { numberTimesDown_=value;}
00183   inline void incrementNumberTimesDown()
00184   { numberTimesDown_++;}
00185 
00187   inline int numberTimesUp() const
00188   { return numberTimesUp_;}
00190   inline void setNumberTimesUp(int value)
00191   { numberTimesUp_=value;}
00193   inline void incrementNumberTimesUp()
00194   { numberTimesUp_++;}
00195 
00197   inline int numberTimesDownInfeasible() const
00198   { return numberTimesDownInfeasible_;}
00200   inline void setNumberTimesDownInfeasible(int value)
00201   { numberTimesDownInfeasible_=value;}
00203   inline void incrementNumberTimesDownInfeasible()
00204   { numberTimesDownInfeasible_++;}
00205 
00207   inline int numberTimesUpInfeasible() const
00208   { return numberTimesUpInfeasible_;}
00210   inline void setNumberTimesUpInfeasible(int value)
00211   { numberTimesUpInfeasible_=value;}
00213   inline void incrementNumberTimesUpInfeasible()
00214   { numberTimesUpInfeasible_++;}
00215 
00217   inline int numberBeforeTrust() const
00218   { return numberBeforeTrust_;}
00220   inline void setNumberBeforeTrust(int value)
00221   { numberBeforeTrust_=value;}
00222 
00224   virtual double upEstimate() const;
00226   virtual double downEstimate() const;
00227   
00229   inline int method() const
00230   { return method_;}
00232   inline void setMethod(int value)
00233   { method_=value;}
00234 
00236   void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown);
00238   void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp);
00240   void setProbingInformation(int fixedDown, int fixedUp);
00241 
00243   void print(int type=0, double value=0.0) const;
00245   bool same(const CbcSimpleIntegerDynamicPseudoCost * obj) const;
00246 protected:
00248 
00250   double downDynamicPseudoCost_;
00252   double upDynamicPseudoCost_;
00257   double upDownSeparator_;
00259   double sumDownCost_;
00261   double sumUpCost_;
00263   double sumDownChange_;
00265   double sumUpChange_;
00267   mutable double sumDownCostSquared_;
00269   mutable double sumUpCostSquared_;
00271   double sumDownDecrease_;
00273   double sumUpDecrease_;
00275   double lastDownCost_;
00277   double lastUpCost_;
00279   mutable int lastDownDecrease_;
00281   mutable int lastUpDecrease_;
00283   int numberTimesDown_;
00285   int numberTimesUp_;
00287   int numberTimesDownInfeasible_;
00289   int numberTimesUpInfeasible_;
00291   int numberBeforeTrust_;
00293   int numberTimesDownLocalFixed_;
00295   int numberTimesUpLocalFixed_;
00297   double numberTimesDownTotalFixed_;
00299   double numberTimesUpTotalFixed_;
00301   int numberTimesProbingTotal_;
00303 #define CBC_INSTRUMENT
00304 #ifdef CBC_INSTRUMENT
00305   mutable int numberTimesInfeasible_;
00306 #endif
00307 
00311   int method_;
00312 };
00313 
00314 
00325 class CbcDynamicPseudoCostBranchingObject : public CbcIntegerBranchingObject {
00326 
00327 public:
00328 
00330   CbcDynamicPseudoCostBranchingObject ();
00331 
00339   CbcDynamicPseudoCostBranchingObject (CbcModel *model, int variable,
00340                                        int way , double value, 
00341                                        CbcSimpleIntegerDynamicPseudoCost * object) ;
00342   
00350   CbcDynamicPseudoCostBranchingObject (CbcModel *model, int variable, int way,
00351                              double lowerValue, double upperValue) ;
00352   
00354   CbcDynamicPseudoCostBranchingObject ( const CbcDynamicPseudoCostBranchingObject &);
00355    
00357   CbcDynamicPseudoCostBranchingObject & operator= (const CbcDynamicPseudoCostBranchingObject& rhs);
00358 
00360   virtual CbcBranchingObject * clone() const;
00361 
00363   virtual ~CbcDynamicPseudoCostBranchingObject ();
00364 
00366   void fillPart (int variable,
00367              int way , double value, 
00368              CbcSimpleIntegerDynamicPseudoCost * object) ;
00369   
00370   using CbcBranchingObject::branch ;
00375   virtual double branch();
00376 
00381   virtual int fillStrongInfo( CbcStrongInfo & info);
00382 
00384   inline double changeInGuessed() const
00385   { return changeInGuessed_;}
00387   inline void setChangeInGuessed(double value)
00388   { changeInGuessed_=value;}
00390   inline CbcSimpleIntegerDynamicPseudoCost * object() const
00391   { return object_;}
00393   inline void setObject(CbcSimpleIntegerDynamicPseudoCost * object)
00394   { object_=object;}
00395 
00397   virtual int type() const { return 400; }
00398 
00399   // LL: compareOriginalObject and compareBranchingObject are inherited from
00400   // CbcIntegerBranchingObject thus need not be declared/defined here. After
00401   // all, this kind of branching object is simply using pseudocosts to make
00402   // decisions, but once the decisions are made they are the same kind as in
00403   // the underlying class.
00404 
00405 protected:
00407   double changeInGuessed_;
00409   CbcSimpleIntegerDynamicPseudoCost * object_;
00410 
00411 };
00418 class CbcBranchDynamicDecision : public CbcBranchDecision {
00419 public:
00420   // Default Constructor 
00421   CbcBranchDynamicDecision ();
00422 
00423   // Copy constructor 
00424   CbcBranchDynamicDecision ( const CbcBranchDynamicDecision &);
00425 
00426   virtual ~CbcBranchDynamicDecision();
00427 
00429   virtual CbcBranchDecision * clone() const;
00430 
00432   virtual void initialize(CbcModel * model);
00433 
00453   virtual int betterBranch(CbcBranchingObject * thisOne,
00454                             CbcBranchingObject * bestSoFar,
00455                             double changeUp, int numInfUp,
00456                             double changeDn, int numInfDn);
00458   virtual void setBestCriterion(double value);
00459   virtual double getBestCriterion() const;
00462   virtual int whichMethod() {return 3;}
00463 
00466   virtual void saveBranchingObject(OsiBranchingObject * object) ;
00469   virtual void updateInformation(OsiSolverInterface * solver,
00470                                  const CbcNode * node);
00471 
00472 
00473 private:
00474   
00476   CbcBranchDynamicDecision & operator=(const CbcBranchDynamicDecision& rhs);
00477 
00479 
00481   double bestCriterion_;
00482 
00484   double bestChangeUp_;
00485 
00487   int bestNumberUp_;
00488 
00490   double bestChangeDown_;
00491 
00493   int bestNumberDown_;
00494 
00496   CbcBranchingObject * bestObject_;
00497 };
00498 #endif

Generated on Sun Nov 14 14:06:30 2010 for Coin-All by  doxygen 1.4.7