/build/buildd/coinor-cbc-2.5.0/Cbc/src/CbcSimpleIntegerDynamicPseudoCost.hpp
Go to the documentation of this file.
00001 // Edwin 11/17/2009 - carved out of CbcBranchDynamic
00002 #ifndef CbcSimpleIntegerDynamicPseudoCost_H
00003 #define CbcSimpleIntegerDynamicPseudoCost_H
00004 
00005 #include "CbcSimpleInteger.hpp"
00006 
00007 #define TYPERATIO 0.9
00008 #define MINIMUM_MOVEMENT 0.1
00009 #define TYPE2 0
00010 // was 1 - but that looks flakey
00011 #define INFEAS 1
00012 #define MOD_SHADOW 1
00013 // weight at 1.0 is max min
00014 #define WEIGHT_AFTER 0.8
00015 #define WEIGHT_BEFORE 0.1
00016 //Stolen from Constraint Integer Programming book (with epsilon change)
00017 #define WEIGHT_PRODUCT
00018 
00019 
00029 class CbcSimpleIntegerDynamicPseudoCost : public CbcSimpleInteger {
00030 
00031 public:
00032 
00033     // Default Constructor
00034     CbcSimpleIntegerDynamicPseudoCost ();
00035 
00036     // Useful constructor - passed  model index
00037     CbcSimpleIntegerDynamicPseudoCost (CbcModel * model,  int iColumn, double breakEven = 0.5);
00038 
00039     // Useful constructor - passed  model index and pseudo costs
00040     CbcSimpleIntegerDynamicPseudoCost (CbcModel * model, int iColumn,
00041                                        double downDynamicPseudoCost, double upDynamicPseudoCost);
00042 
00043     // Useful constructor - passed  model index and pseudo costs
00044     CbcSimpleIntegerDynamicPseudoCost (CbcModel * model, int dummy, int iColumn,
00045                                        double downDynamicPseudoCost, double upDynamicPseudoCost);
00046 
00047     // Copy constructor
00048     CbcSimpleIntegerDynamicPseudoCost ( const CbcSimpleIntegerDynamicPseudoCost &);
00049 
00051     virtual CbcObject * clone() const;
00052 
00053     // Assignment operator
00054     CbcSimpleIntegerDynamicPseudoCost & operator=( const CbcSimpleIntegerDynamicPseudoCost& rhs);
00055 
00056     // Destructor
00057     virtual ~CbcSimpleIntegerDynamicPseudoCost ();
00058 
00060     virtual double infeasibility(const OsiBranchingInformation * info,
00061                                  int &preferredWay) const;
00062 
00064     virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;
00065 
00066 
00068     void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
00069 
00070 
00074     virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface * solver,
00075             const CbcNode * node,
00076             const CbcBranchingObject * branchingObject);
00078     virtual void updateInformation(const CbcObjectUpdateData & data) ;
00080     void copySome(const CbcSimpleIntegerDynamicPseudoCost * otherObject);
00082     virtual void updateBefore(const OsiObject * rhs) ;
00084     virtual void updateAfter(const OsiObject * rhs, const OsiObject * baseObject) ;
00086     void updateAfterMini(int numberDown, int numberDownInfeasible, double sumDown,
00087                          int numberUp, int numberUpInfeasible, double sumUp);
00088 
00089     using CbcSimpleInteger::solverBranch ;
00094     virtual OsiSolverBranch * solverBranch() const;
00095 
00097     inline double downDynamicPseudoCost() const {
00098         return downDynamicPseudoCost_;
00099     }
00101     void setDownDynamicPseudoCost(double value) ;
00103     void updateDownDynamicPseudoCost(double value);
00104 
00106     inline double upDynamicPseudoCost() const {
00107         return upDynamicPseudoCost_;
00108     }
00110     void setUpDynamicPseudoCost(double value);
00112     void updateUpDynamicPseudoCost(double value);
00113 
00115     inline double downShadowPrice() const {
00116         return downShadowPrice_;
00117     }
00119     inline void setDownShadowPrice(double value) {
00120         downShadowPrice_ = value;
00121     }
00123     inline double upShadowPrice() const {
00124         return upShadowPrice_;
00125     }
00127     inline void setUpShadowPrice(double value) {
00128         upShadowPrice_ = value;
00129     }
00130 
00132     inline double upDownSeparator() const {
00133         return upDownSeparator_;
00134     }
00136     inline void setUpDownSeparator(double value) {
00137         upDownSeparator_ = value;
00138     }
00139 
00141     inline double sumDownCost() const {
00142         return sumDownCost_;
00143     }
00145     inline void setSumDownCost(double value) {
00146         sumDownCost_ = value;
00147     }
00149     inline void addToSumDownCost(double value) {
00150         sumDownCost_ += value;
00151         lastDownCost_ = value;
00152     }
00153 
00155     inline double sumUpCost() const {
00156         return sumUpCost_;
00157     }
00159     inline void setSumUpCost(double value) {
00160         sumUpCost_ = value;
00161     }
00163     inline void addToSumUpCost(double value) {
00164         sumUpCost_ += value;
00165         lastUpCost_ = value;
00166     }
00167 
00169     inline double sumDownChange() const {
00170         return sumDownChange_;
00171     }
00173     inline void setSumDownChange(double value) {
00174         sumDownChange_ = value;
00175     }
00177     inline void addToSumDownChange(double value) {
00178         sumDownChange_ += value;
00179     }
00180 
00182     inline double sumUpChange() const {
00183         return sumUpChange_;
00184     }
00186     inline void setSumUpChange(double value) {
00187         sumUpChange_ = value;
00188     }
00190     inline void addToSumUpChange(double value) {
00191         sumUpChange_ += value;
00192     }
00193 
00195     inline double sumDownDecrease() const {
00196         return sumDownDecrease_;
00197     }
00199     inline void setSumDownDecrease(double value) {
00200         sumDownDecrease_ = value;
00201     }
00203     inline void addToSumDownDecrease(double value) {
00204         sumDownDecrease_ += value;/*lastDownDecrease_ = (int) value;*/
00205     }
00206 
00208     inline double sumUpDecrease() const {
00209         return sumUpDecrease_;
00210     }
00212     inline void setSumUpDecrease(double value) {
00213         sumUpDecrease_ = value;
00214     }
00216     inline void addToSumUpDecrease(double value) {
00217         sumUpDecrease_ += value;/*lastUpDecrease_ = (int) value;*/
00218     }
00219 
00221     inline int numberTimesDown() const {
00222         return numberTimesDown_;
00223     }
00225     inline void setNumberTimesDown(int value) {
00226         numberTimesDown_ = value;
00227     }
00229     inline void incrementNumberTimesDown() {
00230         numberTimesDown_++;
00231     }
00232 
00234     inline int numberTimesUp() const {
00235         return numberTimesUp_;
00236     }
00238     inline void setNumberTimesUp(int value) {
00239         numberTimesUp_ = value;
00240     }
00242     inline void incrementNumberTimesUp() {
00243         numberTimesUp_++;
00244     }
00245 
00247     inline int numberTimesDownInfeasible() const {
00248         return numberTimesDownInfeasible_;
00249     }
00251     inline void setNumberTimesDownInfeasible(int value) {
00252         numberTimesDownInfeasible_ = value;
00253     }
00255     inline void incrementNumberTimesDownInfeasible() {
00256         numberTimesDownInfeasible_++;
00257     }
00258 
00260     inline int numberTimesUpInfeasible() const {
00261         return numberTimesUpInfeasible_;
00262     }
00264     inline void setNumberTimesUpInfeasible(int value) {
00265         numberTimesUpInfeasible_ = value;
00266     }
00268     inline void incrementNumberTimesUpInfeasible() {
00269         numberTimesUpInfeasible_++;
00270     }
00271 
00273     inline int numberBeforeTrust() const {
00274         return numberBeforeTrust_;
00275     }
00277     inline void setNumberBeforeTrust(int value) {
00278         numberBeforeTrust_ = value;
00279     }
00281     inline void incrementNumberBeforeTrust() {
00282         numberBeforeTrust_++;
00283     }
00284 
00286     virtual double upEstimate() const;
00288     virtual double downEstimate() const;
00289 
00291     inline int method() const {
00292         return method_;
00293     }
00295     inline void setMethod(int value) {
00296         method_ = value;
00297     }
00298 
00300     void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown);
00302     void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp);
00304     void setProbingInformation(int fixedDown, int fixedUp);
00305 
00307     void print(int type = 0, double value = 0.0) const;
00309     bool same(const CbcSimpleIntegerDynamicPseudoCost * obj) const;
00310 protected:
00312 
00314     double downDynamicPseudoCost_;
00316     double upDynamicPseudoCost_;
00321     double upDownSeparator_;
00323     double sumDownCost_;
00325     double sumUpCost_;
00327     double sumDownChange_;
00329     double sumUpChange_;
00331     mutable double downShadowPrice_;
00333     mutable double upShadowPrice_;
00335     double sumDownDecrease_;
00337     double sumUpDecrease_;
00339     double lastDownCost_;
00341     double lastUpCost_;
00343     mutable int lastDownDecrease_;
00345     mutable int lastUpDecrease_;
00347     int numberTimesDown_;
00349     int numberTimesUp_;
00351     int numberTimesDownInfeasible_;
00353     int numberTimesUpInfeasible_;
00355     int numberBeforeTrust_;
00357     int numberTimesDownLocalFixed_;
00359     int numberTimesUpLocalFixed_;
00361     double numberTimesDownTotalFixed_;
00363     double numberTimesUpTotalFixed_;
00365     int numberTimesProbingTotal_;
00367 
00371     int method_;
00372 };
00383 class CbcIntegerPseudoCostBranchingObject : public CbcIntegerBranchingObject {
00384 
00385 public:
00386 
00388     CbcIntegerPseudoCostBranchingObject ();
00389 
00397     CbcIntegerPseudoCostBranchingObject (CbcModel *model, int variable,
00398                                          int way , double value) ;
00399 
00407     CbcIntegerPseudoCostBranchingObject (CbcModel *model, int variable, int way,
00408                                          double lowerValue, double upperValue) ;
00409 
00411     CbcIntegerPseudoCostBranchingObject ( const CbcIntegerPseudoCostBranchingObject &);
00412 
00414     CbcIntegerPseudoCostBranchingObject & operator= (const CbcIntegerPseudoCostBranchingObject& rhs);
00415 
00417     virtual CbcBranchingObject * clone() const;
00418 
00420     virtual ~CbcIntegerPseudoCostBranchingObject ();
00421 
00422     using CbcBranchingObject::branch ;
00427     virtual double branch();
00428 
00430     inline double changeInGuessed() const {
00431         return changeInGuessed_;
00432     }
00434     inline void setChangeInGuessed(double value) {
00435         changeInGuessed_ = value;
00436     }
00437 
00439     virtual CbcBranchObjType type() const {
00440         return SimpleIntegerDynamicPseudoCostBranchObj;
00441     }
00442 
00451     virtual CbcRangeCompare compareBranchingObject
00452     (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
00453 
00454 protected:
00456     double changeInGuessed_;
00457 };
00458 #endif
00459