CbcSimpleIntegerDynamicPseudoCost.hpp

Go to the documentation of this file.
00001 // $Id: CbcSimpleIntegerDynamicPseudoCost.hpp 2094 2014-11-18 11:15:36Z forrest $
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 numberTimesBranched() const {
00254         return numberTimesDown_ + numberTimesUp_;
00255     }
00257     inline int numberTimesDownInfeasible() const {
00258         return numberTimesDownInfeasible_;
00259     }
00261     inline void setNumberTimesDownInfeasible(int value) {
00262         numberTimesDownInfeasible_ = value;
00263     }
00265     inline void incrementNumberTimesDownInfeasible() {
00266         numberTimesDownInfeasible_++;
00267     }
00268 
00270     inline int numberTimesUpInfeasible() const {
00271         return numberTimesUpInfeasible_;
00272     }
00274     inline void setNumberTimesUpInfeasible(int value) {
00275         numberTimesUpInfeasible_ = value;
00276     }
00278     inline void incrementNumberTimesUpInfeasible() {
00279         numberTimesUpInfeasible_++;
00280     }
00281 
00283     inline int numberBeforeTrust() const {
00284         return numberBeforeTrust_;
00285     }
00287     inline void setNumberBeforeTrust(int value) {
00288         numberBeforeTrust_ = value;
00289     }
00291     inline void incrementNumberBeforeTrust() {
00292         numberBeforeTrust_++;
00293     }
00294 
00296     virtual double upEstimate() const;
00298     virtual double downEstimate() const;
00299 
00301     inline int method() const {
00302         return method_;
00303     }
00305     inline void setMethod(int value) {
00306         method_ = value;
00307     }
00308 
00310     void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown);
00312     void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp);
00314     void setProbingInformation(int fixedDown, int fixedUp);
00315 
00317     void print(int type = 0, double value = 0.0) const;
00319     bool same(const CbcSimpleIntegerDynamicPseudoCost * obj) const;
00320 protected:
00322 
00324     double downDynamicPseudoCost_;
00326     double upDynamicPseudoCost_;
00331     double upDownSeparator_;
00333     double sumDownCost_;
00335     double sumUpCost_;
00337     double sumDownChange_;
00339     double sumUpChange_;
00341     mutable double downShadowPrice_;
00343     mutable double upShadowPrice_;
00345     double sumDownDecrease_;
00347     double sumUpDecrease_;
00349     double lastDownCost_;
00351     double lastUpCost_;
00353     mutable int lastDownDecrease_;
00355     mutable int lastUpDecrease_;
00357     int numberTimesDown_;
00359     int numberTimesUp_;
00361     int numberTimesDownInfeasible_;
00363     int numberTimesUpInfeasible_;
00365     int numberBeforeTrust_;
00367     int numberTimesDownLocalFixed_;
00369     int numberTimesUpLocalFixed_;
00371     double numberTimesDownTotalFixed_;
00373     double numberTimesUpTotalFixed_;
00375     int numberTimesProbingTotal_;
00377 
00381     int method_;
00382 };
00393 class CbcIntegerPseudoCostBranchingObject : public CbcIntegerBranchingObject {
00394 
00395 public:
00396 
00398     CbcIntegerPseudoCostBranchingObject ();
00399 
00407     CbcIntegerPseudoCostBranchingObject (CbcModel *model, int variable,
00408                                          int way , double value) ;
00409 
00417     CbcIntegerPseudoCostBranchingObject (CbcModel *model, int variable, int way,
00418                                          double lowerValue, double upperValue) ;
00419 
00421     CbcIntegerPseudoCostBranchingObject ( const CbcIntegerPseudoCostBranchingObject &);
00422 
00424     CbcIntegerPseudoCostBranchingObject & operator= (const CbcIntegerPseudoCostBranchingObject& rhs);
00425 
00427     virtual CbcBranchingObject * clone() const;
00428 
00430     virtual ~CbcIntegerPseudoCostBranchingObject ();
00431 
00432     using CbcBranchingObject::branch ;
00437     virtual double branch();
00438 
00440     inline double changeInGuessed() const {
00441         return changeInGuessed_;
00442     }
00444     inline void setChangeInGuessed(double value) {
00445         changeInGuessed_ = value;
00446     }
00447 
00449     virtual CbcBranchObjType type() const {
00450         return SimpleIntegerDynamicPseudoCostBranchObj;
00451     }
00452 
00461     virtual CbcRangeCompare compareBranchingObject
00462     (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
00463 
00464 protected:
00466     double changeInGuessed_;
00467 };
00468 #ifdef SWITCH_VARIABLES
00469 
00475 class CbcSwitchingBinary : public CbcSimpleIntegerDynamicPseudoCost {
00476 
00477 public:
00478 
00479     // Default Constructor
00480     CbcSwitchingBinary ();
00481 
00482     // Useful constructor 
00483     CbcSwitchingBinary (CbcSimpleIntegerDynamicPseudoCost * oldObject,
00484                         int nOdd,const int * other, const int * otherRow);
00485 
00486 
00487     // Copy constructor
00488     CbcSwitchingBinary ( const CbcSwitchingBinary &);
00489 
00491     virtual CbcObject * clone() const;
00492 
00493     // Assignment operator
00494     CbcSwitchingBinary & operator=( const CbcSwitchingBinary& rhs);
00495 
00496     // Destructor
00497     virtual ~CbcSwitchingBinary ();
00498 
00500     void addZeroSwitches(int nAdd,const int * columns);
00502     virtual double infeasibility(const OsiBranchingInformation * info,
00503                                  int &preferredWay) const;
00504 
00506     bool same(const CbcSwitchingBinary * obj) const;
00508     virtual int setAssociatedBounds(OsiSolverInterface * solver=NULL,
00509                           int cleanBasis=0) const;
00511     int checkAssociatedBounds(const OsiSolverInterface * solver,const double * solution,
00512                               int printLevel, int state[3], int & nBadFixed) const;
00514     inline const double * zeroLowerBound() const
00515     { return zeroLowerBound_; }
00517     inline const double * oneLowerBound() const
00518     { return oneLowerBound_; }
00520     inline const double * zeroUpperBound() const
00521     { return zeroUpperBound_; }
00523     inline const double * oneUpperBound() const
00524     { return oneUpperBound_; }
00527     inline const int * otherVariable() const
00528     { return otherVariable_;}
00530     inline int numberOther() const
00531     { return numberOther_;}
00537     inline int type() const
00538     { return type_;}
00539 protected:
00541 
00543     double * zeroLowerBound_;
00545     double * oneLowerBound_;
00547     double * zeroUpperBound_;
00549     double * oneUpperBound_;
00552     int * otherVariable_;
00554     int numberOther_;
00560     int type_;
00561 };
00562 #endif
00563 #endif
00564 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 19 Jan 2015 for Cbc by  doxygen 1.6.1