Cbc  trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CbcSimpleIntegerDynamicPseudoCost.hpp
Go to the documentation of this file.
00001 // $Id$
00002 // Copyright (C) 2005, International Business Machines
00003 // Corporation and others.  All Rights Reserved.
00004 // This code is licensed under the terms of the Eclipse Public License (EPL).
00005 
00006 // Edwin 11/17/2009 - carved out of CbcBranchDynamic
00007 
00008 #ifndef CbcSimpleIntegerDynamicPseudoCost_H
00009 #define CbcSimpleIntegerDynamicPseudoCost_H
00010 
00011 #include "CbcSimpleInteger.hpp"
00012 
00013 #define TYPERATIO 0.9
00014 #define MINIMUM_MOVEMENT 0.1
00015 #define TYPE2 0
00016 // was 1 - but that looks flakey
00017 #define INFEAS 1
00018 #define MOD_SHADOW 1
00019 // weight at 1.0 is max min
00020 #define WEIGHT_AFTER 0.8
00021 #define WEIGHT_BEFORE 0.1
00022 //Stolen from Constraint Integer Programming book (with epsilon change)
00023 #define WEIGHT_PRODUCT
00024 
00025 
00035 class CbcSimpleIntegerDynamicPseudoCost : public CbcSimpleInteger {
00036 
00037 public:
00038 
00039     // Default Constructor
00040     CbcSimpleIntegerDynamicPseudoCost ();
00041 
00042     // Useful constructor - passed  model index
00043     CbcSimpleIntegerDynamicPseudoCost (CbcModel * model,  int iColumn, double breakEven = 0.5);
00044 
00045     // Useful constructor - passed  model index and pseudo costs
00046     CbcSimpleIntegerDynamicPseudoCost (CbcModel * model, int iColumn,
00047                                        double downDynamicPseudoCost, double upDynamicPseudoCost);
00048 
00049     // Useful constructor - passed  model index and pseudo costs
00050     CbcSimpleIntegerDynamicPseudoCost (CbcModel * model, int dummy, int iColumn,
00051                                        double downDynamicPseudoCost, double upDynamicPseudoCost);
00052 
00053     // Copy constructor
00054     CbcSimpleIntegerDynamicPseudoCost ( const CbcSimpleIntegerDynamicPseudoCost &);
00055 
00057     virtual CbcObject * clone() const;
00058 
00059     // Assignment operator
00060     CbcSimpleIntegerDynamicPseudoCost & operator=( const CbcSimpleIntegerDynamicPseudoCost& rhs);
00061 
00062     // Destructor
00063     virtual ~CbcSimpleIntegerDynamicPseudoCost ();
00064 
00066     virtual double infeasibility(const OsiBranchingInformation * info,
00067                                  int &preferredWay) const;
00068 
00070     virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;
00071 
00072 
00074     void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
00075 
00076 
00080     virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface * solver,
00081             const CbcNode * node,
00082             const CbcBranchingObject * branchingObject);
00084     virtual void updateInformation(const CbcObjectUpdateData & data) ;
00086     void copySome(const CbcSimpleIntegerDynamicPseudoCost * otherObject);
00088     virtual void updateBefore(const OsiObject * rhs) ;
00090     virtual void updateAfter(const OsiObject * rhs, const OsiObject * baseObject) ;
00092     void updateAfterMini(int numberDown, int numberDownInfeasible, double sumDown,
00093                          int numberUp, int numberUpInfeasible, double sumUp);
00094 
00095     using CbcSimpleInteger::solverBranch ;
00100     virtual OsiSolverBranch * solverBranch() const;
00101 
00103     inline double downDynamicPseudoCost() const {
00104         return downDynamicPseudoCost_;
00105     }
00107     void setDownDynamicPseudoCost(double value) ;
00109     void updateDownDynamicPseudoCost(double value);
00110 
00112     inline double upDynamicPseudoCost() const {
00113         return upDynamicPseudoCost_;
00114     }
00116     void setUpDynamicPseudoCost(double value);
00118     void updateUpDynamicPseudoCost(double value);
00119 
00121     inline double downShadowPrice() const {
00122         return downShadowPrice_;
00123     }
00125     inline void setDownShadowPrice(double value) {
00126         downShadowPrice_ = value;
00127     }
00129     inline double upShadowPrice() const {
00130         return upShadowPrice_;
00131     }
00133     inline void setUpShadowPrice(double value) {
00134         upShadowPrice_ = value;
00135     }
00136 
00138     inline double upDownSeparator() const {
00139         return upDownSeparator_;
00140     }
00142     inline void setUpDownSeparator(double value) {
00143         upDownSeparator_ = value;
00144     }
00145 
00147     inline double sumDownCost() const {
00148         return sumDownCost_;
00149     }
00151     inline void setSumDownCost(double value) {
00152         sumDownCost_ = value;
00153     }
00155     inline void addToSumDownCost(double value) {
00156         sumDownCost_ += value;
00157         lastDownCost_ = value;
00158     }
00159 
00161     inline double sumUpCost() const {
00162         return sumUpCost_;
00163     }
00165     inline void setSumUpCost(double value) {
00166         sumUpCost_ = value;
00167     }
00169     inline void addToSumUpCost(double value) {
00170         sumUpCost_ += value;
00171         lastUpCost_ = value;
00172     }
00173 
00175     inline double sumDownChange() const {
00176         return sumDownChange_;
00177     }
00179     inline void setSumDownChange(double value) {
00180         sumDownChange_ = value;
00181     }
00183     inline void addToSumDownChange(double value) {
00184         sumDownChange_ += value;
00185     }
00186 
00188     inline double sumUpChange() const {
00189         return sumUpChange_;
00190     }
00192     inline void setSumUpChange(double value) {
00193         sumUpChange_ = value;
00194     }
00196     inline void addToSumUpChange(double value) {
00197         sumUpChange_ += value;
00198     }
00199 
00201     inline double sumDownDecrease() const {
00202         return sumDownDecrease_;
00203     }
00205     inline void setSumDownDecrease(double value) {
00206         sumDownDecrease_ = value;
00207     }
00209     inline void addToSumDownDecrease(double value) {
00210         sumDownDecrease_ += value;/*lastDownDecrease_ = (int) value;*/
00211     }
00212 
00214     inline double sumUpDecrease() const {
00215         return sumUpDecrease_;
00216     }
00218     inline void setSumUpDecrease(double value) {
00219         sumUpDecrease_ = value;
00220     }
00222     inline void addToSumUpDecrease(double value) {
00223         sumUpDecrease_ += value;/*lastUpDecrease_ = (int) value;*/
00224     }
00225 
00227     inline int numberTimesDown() const {
00228         return numberTimesDown_;
00229     }
00231     inline void setNumberTimesDown(int value) {
00232         numberTimesDown_ = value;
00233     }
00235     inline void incrementNumberTimesDown() {
00236         numberTimesDown_++;
00237     }
00238 
00240     inline int numberTimesUp() const {
00241         return numberTimesUp_;
00242     }
00244     inline void setNumberTimesUp(int value) {
00245         numberTimesUp_ = value;
00246     }
00248     inline void incrementNumberTimesUp() {
00249         numberTimesUp_++;
00250     }
00251 
00253     inline int numberTimesDownInfeasible() const {
00254         return numberTimesDownInfeasible_;
00255     }
00257     inline void setNumberTimesDownInfeasible(int value) {
00258         numberTimesDownInfeasible_ = value;
00259     }
00261     inline void incrementNumberTimesDownInfeasible() {
00262         numberTimesDownInfeasible_++;
00263     }
00264 
00266     inline int numberTimesUpInfeasible() const {
00267         return numberTimesUpInfeasible_;
00268     }
00270     inline void setNumberTimesUpInfeasible(int value) {
00271         numberTimesUpInfeasible_ = value;
00272     }
00274     inline void incrementNumberTimesUpInfeasible() {
00275         numberTimesUpInfeasible_++;
00276     }
00277 
00279     inline int numberBeforeTrust() const {
00280         return numberBeforeTrust_;
00281     }
00283     inline void setNumberBeforeTrust(int value) {
00284         numberBeforeTrust_ = value;
00285     }
00287     inline void incrementNumberBeforeTrust() {
00288         numberBeforeTrust_++;
00289     }
00290 
00292     virtual double upEstimate() const;
00294     virtual double downEstimate() const;
00295 
00297     inline int method() const {
00298         return method_;
00299     }
00301     inline void setMethod(int value) {
00302         method_ = value;
00303     }
00304 
00306     void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown);
00308     void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp);
00310     void setProbingInformation(int fixedDown, int fixedUp);
00311 
00313     void print(int type = 0, double value = 0.0) const;
00315     bool same(const CbcSimpleIntegerDynamicPseudoCost * obj) const;
00316 protected:
00318 
00320     double downDynamicPseudoCost_;
00322     double upDynamicPseudoCost_;
00327     double upDownSeparator_;
00329     double sumDownCost_;
00331     double sumUpCost_;
00333     double sumDownChange_;
00335     double sumUpChange_;
00337     mutable double downShadowPrice_;
00339     mutable double upShadowPrice_;
00341     double sumDownDecrease_;
00343     double sumUpDecrease_;
00345     double lastDownCost_;
00347     double lastUpCost_;
00349     mutable int lastDownDecrease_;
00351     mutable int lastUpDecrease_;
00353     int numberTimesDown_;
00355     int numberTimesUp_;
00357     int numberTimesDownInfeasible_;
00359     int numberTimesUpInfeasible_;
00361     int numberBeforeTrust_;
00363     int numberTimesDownLocalFixed_;
00365     int numberTimesUpLocalFixed_;
00367     double numberTimesDownTotalFixed_;
00369     double numberTimesUpTotalFixed_;
00371     int numberTimesProbingTotal_;
00373 
00377     int method_;
00378 };
00389 class CbcIntegerPseudoCostBranchingObject : public CbcIntegerBranchingObject {
00390 
00391 public:
00392 
00394     CbcIntegerPseudoCostBranchingObject ();
00395 
00403     CbcIntegerPseudoCostBranchingObject (CbcModel *model, int variable,
00404                                          int way , double value) ;
00405 
00413     CbcIntegerPseudoCostBranchingObject (CbcModel *model, int variable, int way,
00414                                          double lowerValue, double upperValue) ;
00415 
00417     CbcIntegerPseudoCostBranchingObject ( const CbcIntegerPseudoCostBranchingObject &);
00418 
00420     CbcIntegerPseudoCostBranchingObject & operator= (const CbcIntegerPseudoCostBranchingObject& rhs);
00421 
00423     virtual CbcBranchingObject * clone() const;
00424 
00426     virtual ~CbcIntegerPseudoCostBranchingObject ();
00427 
00428     using CbcBranchingObject::branch ;
00433     virtual double branch();
00434 
00436     inline double changeInGuessed() const {
00437         return changeInGuessed_;
00438     }
00440     inline void setChangeInGuessed(double value) {
00441         changeInGuessed_ = value;
00442     }
00443 
00445     virtual CbcBranchObjType type() const {
00446         return SimpleIntegerDynamicPseudoCostBranchObj;
00447     }
00448 
00457     virtual CbcRangeCompare compareBranchingObject
00458     (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
00459 
00460 protected:
00462     double changeInGuessed_;
00463 };
00464 #endif
00465 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines