CbcSimpleIntegerDynamicPseudoCost.hpp
Go to the documentation of this file.
1 // Edwin 11/17/2009 - carved out of CbcBranchDynamic
2 #ifndef CbcSimpleIntegerDynamicPseudoCost_H
3 #define CbcSimpleIntegerDynamicPseudoCost_H
4 
5 #include "CbcSimpleInteger.hpp"
6 
7 #define TYPERATIO 0.9
8 #define MINIMUM_MOVEMENT 0.1
9 #define TYPE2 0
10 // was 1 - but that looks flakey
11 #define INFEAS 1
12 #define MOD_SHADOW 1
13 // weight at 1.0 is max min
14 #define WEIGHT_AFTER 0.8
15 #define WEIGHT_BEFORE 0.1
16 //Stolen from Constraint Integer Programming book (with epsilon change)
17 #define WEIGHT_PRODUCT
18 
19 
30 
31 public:
32 
33  // Default Constructor
35 
36  // Useful constructor - passed model index
37  CbcSimpleIntegerDynamicPseudoCost (CbcModel * model, int iColumn, double breakEven = 0.5);
38 
39  // Useful constructor - passed model index and pseudo costs
40  CbcSimpleIntegerDynamicPseudoCost (CbcModel * model, int iColumn,
42 
43  // Useful constructor - passed model index and pseudo costs
44  CbcSimpleIntegerDynamicPseudoCost (CbcModel * model, int dummy, int iColumn,
45  double downDynamicPseudoCost, double upDynamicPseudoCost);
46 
47  // Copy constructor
49 
51  virtual CbcObject * clone() const;
52 
53  // Assignment operator
55 
56  // Destructor
58 
60  virtual double infeasibility(const OsiBranchingInformation * info,
61  int &preferredWay) const;
62 
64  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;
65 
66 
68  void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
69 
70 
74  virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface * solver,
75  const CbcNode * node,
76  const CbcBranchingObject * branchingObject);
78  virtual void updateInformation(const CbcObjectUpdateData & data) ;
80  void copySome(const CbcSimpleIntegerDynamicPseudoCost * otherObject);
82  virtual void updateBefore(const OsiObject * rhs) ;
84  virtual void updateAfter(const OsiObject * rhs, const OsiObject * baseObject) ;
86  void updateAfterMini(int numberDown, int numberDownInfeasible, double sumDown,
87  int numberUp, int numberUpInfeasible, double sumUp);
88 
94  virtual OsiSolverBranch * solverBranch() const;
95 
97  inline double downDynamicPseudoCost() const {
99  }
101  void setDownDynamicPseudoCost(double value) ;
103  void updateDownDynamicPseudoCost(double value);
104 
106  inline double upDynamicPseudoCost() const {
107  return upDynamicPseudoCost_;
108  }
110  void setUpDynamicPseudoCost(double value);
112  void updateUpDynamicPseudoCost(double value);
113 
115  inline double downShadowPrice() const {
116  return downShadowPrice_;
117  }
119  inline void setDownShadowPrice(double value) {
120  downShadowPrice_ = value;
121  }
123  inline double upShadowPrice() const {
124  return upShadowPrice_;
125  }
127  inline void setUpShadowPrice(double value) {
128  upShadowPrice_ = value;
129  }
130 
132  inline double upDownSeparator() const {
133  return upDownSeparator_;
134  }
136  inline void setUpDownSeparator(double value) {
137  upDownSeparator_ = value;
138  }
139 
141  inline double sumDownCost() const {
142  return sumDownCost_;
143  }
145  inline void setSumDownCost(double value) {
146  sumDownCost_ = value;
147  }
149  inline void addToSumDownCost(double value) {
150  sumDownCost_ += value;
151  lastDownCost_ = value;
152  }
153 
155  inline double sumUpCost() const {
156  return sumUpCost_;
157  }
159  inline void setSumUpCost(double value) {
160  sumUpCost_ = value;
161  }
163  inline void addToSumUpCost(double value) {
164  sumUpCost_ += value;
165  lastUpCost_ = value;
166  }
167 
169  inline double sumDownChange() const {
170  return sumDownChange_;
171  }
173  inline void setSumDownChange(double value) {
174  sumDownChange_ = value;
175  }
177  inline void addToSumDownChange(double value) {
178  sumDownChange_ += value;
179  }
180 
182  inline double sumUpChange() const {
183  return sumUpChange_;
184  }
186  inline void setSumUpChange(double value) {
187  sumUpChange_ = value;
188  }
190  inline void addToSumUpChange(double value) {
191  sumUpChange_ += value;
192  }
193 
195  inline double sumDownDecrease() const {
196  return sumDownDecrease_;
197  }
199  inline void setSumDownDecrease(double value) {
200  sumDownDecrease_ = value;
201  }
203  inline void addToSumDownDecrease(double value) {
204  sumDownDecrease_ += value;/*lastDownDecrease_ = (int) value;*/
205  }
206 
208  inline double sumUpDecrease() const {
209  return sumUpDecrease_;
210  }
212  inline void setSumUpDecrease(double value) {
213  sumUpDecrease_ = value;
214  }
216  inline void addToSumUpDecrease(double value) {
217  sumUpDecrease_ += value;/*lastUpDecrease_ = (int) value;*/
218  }
219 
221  inline int numberTimesDown() const {
222  return numberTimesDown_;
223  }
225  inline void setNumberTimesDown(int value) {
226  numberTimesDown_ = value;
227  }
229  inline void incrementNumberTimesDown() {
231  }
232 
234  inline int numberTimesUp() const {
235  return numberTimesUp_;
236  }
238  inline void setNumberTimesUp(int value) {
239  numberTimesUp_ = value;
240  }
242  inline void incrementNumberTimesUp() {
243  numberTimesUp_++;
244  }
245 
247  inline int numberTimesDownInfeasible() const {
249  }
251  inline void setNumberTimesDownInfeasible(int value) {
253  }
257  }
258 
260  inline int numberTimesUpInfeasible() const {
262  }
264  inline void setNumberTimesUpInfeasible(int value) {
265  numberTimesUpInfeasible_ = value;
266  }
270  }
271 
273  inline int numberBeforeTrust() const {
274  return numberBeforeTrust_;
275  }
277  inline void setNumberBeforeTrust(int value) {
278  numberBeforeTrust_ = value;
279  }
283  }
284 
286  virtual double upEstimate() const;
288  virtual double downEstimate() const;
289 
291  inline int method() const {
292  return method_;
293  }
295  inline void setMethod(int value) {
296  method_ = value;
297  }
298 
300  void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown);
302  void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp);
304  void setProbingInformation(int fixedDown, int fixedUp);
305 
307  void print(int type = 0, double value = 0.0) const;
309  bool same(const CbcSimpleIntegerDynamicPseudoCost * obj) const;
310 protected:
312 
314  double downDynamicPseudoCost_;
316  double upDynamicPseudoCost_;
321  double upDownSeparator_;
323  double sumDownCost_;
325  double sumUpCost_;
327  double sumDownChange_;
329  double sumUpChange_;
331  mutable double downShadowPrice_;
333  mutable double upShadowPrice_;
335  double sumDownDecrease_;
337  double sumUpDecrease_;
339  double lastDownCost_;
341  double lastUpCost_;
343  mutable int lastDownDecrease_;
345  mutable int lastUpDecrease_;
347  int numberTimesDown_;
349  int numberTimesUp_;
355  int numberBeforeTrust_;
367 
371  int method_;
372 };
384 
385 public:
386 
389 
398  int way , double value) ;
399 
408  double lowerValue, double upperValue) ;
409 
412 
415 
417  virtual CbcBranchingObject * clone() const;
418 
421 
427  virtual double branch();
428 
430  inline double changeInGuessed() const {
431  return changeInGuessed_;
432  }
434  inline void setChangeInGuessed(double value) {
435  changeInGuessed_ = value;
436  }
437 
439  virtual CbcBranchObjType type() const {
441  }
442 
452  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
453 
454 protected:
456  double changeInGuessed_;
457 };
458 #endif
459 
double changeInGuessed_
Change in guessed objective value for next branch.
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap=false)
Compare the this with brObj.
virtual void updateBefore(const OsiObject *rhs)
Updates stuff like pseudocosts before threads.
int lastUpDecrease_
Last up decrease number infeasibilities from strong (i.e. as computed by last strong) ...
void addToSumUpDecrease(double value)
Add to sum up decrease number infeasibilities from strong or actual.
void addToSumUpCost(double value)
Add to up sum cost and set last and square.
Abstract branching object base class Now just difference with OsiBranchingObject. ...
virtual ~CbcIntegerPseudoCostBranchingObject()
Destructor.
Define a single integer class.
double sumUpDecrease() const
Sum up decrease number infeasibilities from strong or actual.
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way)
Creates a branching object.
void setSumUpCost(double value)
Set up sum cost.
double downShadowPrice_
Current pseudo-shadow price estimate down.
CbcRangeCompare
virtual double infeasibility(const OsiBranchingInformation *info, int &preferredWay) const
Infeasibility - large is 0.5.
void copySome(const CbcSimpleIntegerDynamicPseudoCost *otherObject)
Copy some information i.e. just variable stuff.
int numberTimesDownLocalFixed_
Number of local probing fixings going down.
int numberBeforeTrust() const
Number of times before trusted.
int numberTimesUpInfeasible_
Number of times we have been infeasible going up.
void setChangeInGuessed(double value)
Set change in guessed.
virtual CbcBranchObjType type() const
Return the type (an integer identifier) of this.
void setProbingInformation(int fixedDown, int fixedUp)
Pass in probing information.
double sumDownCost_
Sum down cost from strong or actual.
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
double sumUpChange_
Sum of all changes to x when going up.
int numberBeforeTrust_
Number of branches before we trust.
virtual CbcObject * clone() const
Clone.
void setSumDownCost(double value)
Set down sum cost.
double sumDownChange_
Sum of all changes to x when going down.
virtual CbcBranchingObject * clone() const
Clone.
virtual void updateAfter(const OsiObject *rhs, const OsiObject *baseObject)
Updates stuff like pseudocosts after threads finished.
void setSumUpChange(double value)
Set up sum change.
double sumDownDecrease_
Sum down decrease number infeasibilities from strong or actual.
void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp)
Pass in information on a up branch.
CbcBranchObjType
int numberTimesUpLocalFixed_
Number of local probing fixings going up.
void updateUpDynamicPseudoCost(double value)
Modify up pseudo cost in a slightly different way.
Define a single integer class but with dynamic pseudo costs.
virtual double downEstimate() const
Return "down" estimate (default 1.0e-5)
void incrementNumberTimesDown()
Increment down number times.
void addToSumUpChange(double value)
Add to up sum change and set last and square.
void incrementNumberTimesUp()
Increment up number times.
void incrementNumberTimesDownInfeasible()
Increment down number times infeasible.
virtual void updateInformation(const CbcObjectUpdateData &data)
Update object by CbcObjectUpdateData.
Simple branching object for an integer variable with pseudo costs.
double upDownSeparator() const
Up down separator.
void addToSumDownCost(double value)
Add to down sum cost and set last and square.
void setNumberTimesDownInfeasible(int value)
Set down number times infeasible.
CbcSimpleIntegerDynamicPseudoCost & operator=(const CbcSimpleIntegerDynamicPseudoCost &rhs)
double downShadowPrice() const
Down pseudo shadow price cost.
void incrementNumberBeforeTrust()
Increment number of times before trusted.
void setUpDownSeparator(double value)
Set up down separator.
int variable() const
Index identifying the associated CbcObject within its class.
double sumDownDecrease() const
Sum down decrease number infeasibilities from strong or actual.
virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface *solver, const CbcNode *node, const CbcBranchingObject *branchingObject)
Pass in information on branch just done and create CbcObjectUpdateData instance.
void setSumDownChange(double value)
Set down sum change.
void addToSumDownDecrease(double value)
Add to sum down decrease number infeasibilities from strong or actual.
double lastUpCost_
Last up cost from strong (i.e. as computed by last strong)
void fillCreateBranch(CbcIntegerBranchingObject *branching, const OsiBranchingInformation *info, int way)
Fills in a created branching object.
void incrementNumberTimesUpInfeasible()
Increment up number times infeasible.
void setSumUpDecrease(double value)
Set sum up decrease number infeasibilities from strong or actual.
void setNumberTimesUp(int value)
Set up number times.
double numberTimesUpTotalFixed_
Number of total probing fixings going up.
double upDownSeparator_
Up/down separator If >0.0 then do first branch up if value-floor(value) >= this value.
void setNumberBeforeTrust(int value)
Set number of times before trusted.
int numberTimesDownInfeasible() const
Down number times infeasible.
int preferredWay() const
If -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcObject.hpp:235
void setNumberTimesDown(int value)
Set down number times.
int lastDownDecrease_
Last down decrease number infeasibilities from strong (i.e. as computed by last strong) ...
void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown)
Pass in information on a down branch.
void setDownDynamicPseudoCost(double value)
Set down pseudo cost.
virtual double branch()
Sets the bounds for the variable according to the current arm of the branch and advances the object s...
double numberTimesDownTotalFixed_
Number of total probing fixings going down.
bool same(const CbcSimpleIntegerDynamicPseudoCost *obj) const
Same - returns true if contents match(ish)
Simple branching object for an integer variable.
double upShadowPrice_
Current pseudo-shadow price estimate up.
CbcIntegerPseudoCostBranchingObject & operator=(const CbcIntegerPseudoCostBranchingObject &rhs)
Assignment operator.
void setUpDynamicPseudoCost(double value)
Set up pseudo cost.
double sumUpDecrease_
Sum up decrease number infeasibilities from strong or actual.
int numberTimesUp_
Number of times we have gone up.
int way() const
Get the state of the branching object.
int numberTimesDownInfeasible_
Number of times we have been infeasible going down.
double downDynamicPseudoCost() const
Down pseudo cost.
double upShadowPrice() const
Up pseudo shadow price cost.
CbcModel * model() const
Return model.
Definition: CbcObject.hpp:230
int method_
Number of times infeasible when tested.
void setSumDownDecrease(double value)
Set sum down decrease number infeasibilities from strong or actual.
void print(int type=0, double value=0.0) const
Print - 0 -summary, 1 just before strong.
void addToSumDownChange(double value)
Add to down sum change.
CbcIntegerPseudoCostBranchingObject()
Default constructor.
void setNumberTimesUpInfeasible(int value)
Set up number times infeasible.
int numberTimesDown_
Number of times we have gone down.
Information required while the node is live.
Definition: CbcNode.hpp:47
void updateDownDynamicPseudoCost(double value)
Modify down pseudo cost in a slightly different way.
double changeInGuessed() const
Change in guessed.
double lastDownCost_
Last down cost from strong (i.e. as computed by last strong)
int method() const
method - see below for details
void updateAfterMini(int numberDown, int numberDownInfeasible, double sumDown, int numberUp, int numberUpInfeasible, double sumUp)
Updates stuff like pseudocosts after mini branch and bound.
void setUpShadowPrice(double value)
Set up pseudo shadow price cost.
int numberTimesProbingTotal_
Number of times probing done.
int numberTimesUpInfeasible() const
Up number times infeasible.
double sumUpCost_
Sum up cost from strong or actual.
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
CbcModel * model() const
Return model.
Simple Branch and bound class.
Definition: CbcModel.hpp:98
void setDownShadowPrice(double value)
Set down pseudo shadow price cost.
double breakEven() const
Breakeven e.g 0.7 -> >= 0.7 go up first.
virtual double branch()=0
Execute the actions required to branch, as specified by the current state of the branching object...
virtual double upEstimate() const
Return "up" estimate.