Cbc  2.8.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CbcSimpleIntegerDynamicPseudoCost.hpp
Go to the documentation of this file.
1 // $Id: CbcSimpleIntegerDynamicPseudoCost.hpp 1902 2013-04-10 16:58:16Z stefan $
2 // Copyright (C) 2005, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 // Edwin 11/17/2009 - carved out of CbcBranchDynamic
7 
8 #ifndef CbcSimpleIntegerDynamicPseudoCost_H
9 #define CbcSimpleIntegerDynamicPseudoCost_H
10 
11 #include "CbcSimpleInteger.hpp"
12 
13 #define TYPERATIO 0.9
14 #define MINIMUM_MOVEMENT 0.1
15 #define TYPE2 0
16 // was 1 - but that looks flakey
17 #define INFEAS 1
18 #define MOD_SHADOW 1
19 // weight at 1.0 is max min
20 #define WEIGHT_AFTER 0.8
21 #define WEIGHT_BEFORE 0.1
22 //Stolen from Constraint Integer Programming book (with epsilon change)
23 #define WEIGHT_PRODUCT
24 
25 
36 
37 public:
38 
39  // Default Constructor
41 
42  // Useful constructor - passed model index
43  CbcSimpleIntegerDynamicPseudoCost (CbcModel * model, int iColumn, double breakEven = 0.5);
44 
45  // Useful constructor - passed model index and pseudo costs
46  CbcSimpleIntegerDynamicPseudoCost (CbcModel * model, int iColumn,
48 
49  // Useful constructor - passed model index and pseudo costs
50  CbcSimpleIntegerDynamicPseudoCost (CbcModel * model, int dummy, int iColumn,
51  double downDynamicPseudoCost, double upDynamicPseudoCost);
52 
53  // Copy constructor
55 
57  virtual CbcObject * clone() const;
58 
59  // Assignment operator
61 
62  // Destructor
64 
66  virtual double infeasibility(const OsiBranchingInformation * info,
67  int &preferredWay) const;
68 
70  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;
71 
72 
74  void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
75 
76 
80  virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface * solver,
81  const CbcNode * node,
82  const CbcBranchingObject * branchingObject);
84  virtual void updateInformation(const CbcObjectUpdateData & data) ;
86  void copySome(const CbcSimpleIntegerDynamicPseudoCost * otherObject);
88  virtual void updateBefore(const OsiObject * rhs) ;
90  virtual void updateAfter(const OsiObject * rhs, const OsiObject * baseObject) ;
92  void updateAfterMini(int numberDown, int numberDownInfeasible, double sumDown,
93  int numberUp, int numberUpInfeasible, double sumUp);
94 
100  virtual OsiSolverBranch * solverBranch() const;
101 
103  inline double downDynamicPseudoCost() const {
104  return downDynamicPseudoCost_;
105  }
107  void setDownDynamicPseudoCost(double value) ;
109  void updateDownDynamicPseudoCost(double value);
110 
112  inline double upDynamicPseudoCost() const {
113  return upDynamicPseudoCost_;
114  }
116  void setUpDynamicPseudoCost(double value);
118  void updateUpDynamicPseudoCost(double value);
119 
121  inline double downShadowPrice() const {
122  return downShadowPrice_;
123  }
125  inline void setDownShadowPrice(double value) {
126  downShadowPrice_ = value;
127  }
129  inline double upShadowPrice() const {
130  return upShadowPrice_;
131  }
133  inline void setUpShadowPrice(double value) {
134  upShadowPrice_ = value;
135  }
136 
138  inline double upDownSeparator() const {
139  return upDownSeparator_;
140  }
142  inline void setUpDownSeparator(double value) {
143  upDownSeparator_ = value;
144  }
145 
147  inline double sumDownCost() const {
148  return sumDownCost_;
149  }
151  inline void setSumDownCost(double value) {
152  sumDownCost_ = value;
153  }
155  inline void addToSumDownCost(double value) {
156  sumDownCost_ += value;
157  lastDownCost_ = value;
158  }
159 
161  inline double sumUpCost() const {
162  return sumUpCost_;
163  }
165  inline void setSumUpCost(double value) {
166  sumUpCost_ = value;
167  }
169  inline void addToSumUpCost(double value) {
170  sumUpCost_ += value;
171  lastUpCost_ = value;
172  }
173 
175  inline double sumDownChange() const {
176  return sumDownChange_;
177  }
179  inline void setSumDownChange(double value) {
180  sumDownChange_ = value;
181  }
183  inline void addToSumDownChange(double value) {
184  sumDownChange_ += value;
185  }
186 
188  inline double sumUpChange() const {
189  return sumUpChange_;
190  }
192  inline void setSumUpChange(double value) {
193  sumUpChange_ = value;
194  }
196  inline void addToSumUpChange(double value) {
197  sumUpChange_ += value;
198  }
199 
201  inline double sumDownDecrease() const {
202  return sumDownDecrease_;
203  }
205  inline void setSumDownDecrease(double value) {
206  sumDownDecrease_ = value;
207  }
209  inline void addToSumDownDecrease(double value) {
210  sumDownDecrease_ += value;/*lastDownDecrease_ = (int) value;*/
211  }
212 
214  inline double sumUpDecrease() const {
215  return sumUpDecrease_;
216  }
218  inline void setSumUpDecrease(double value) {
219  sumUpDecrease_ = value;
220  }
222  inline void addToSumUpDecrease(double value) {
223  sumUpDecrease_ += value;/*lastUpDecrease_ = (int) value;*/
224  }
225 
227  inline int numberTimesDown() const {
228  return numberTimesDown_;
229  }
231  inline void setNumberTimesDown(int value) {
232  numberTimesDown_ = value;
233  }
235  inline void incrementNumberTimesDown() {
237  }
238 
240  inline int numberTimesUp() const {
241  return numberTimesUp_;
242  }
244  inline void setNumberTimesUp(int value) {
245  numberTimesUp_ = value;
246  }
248  inline void incrementNumberTimesUp() {
249  numberTimesUp_++;
250  }
251 
253  inline int numberTimesDownInfeasible() const {
255  }
257  inline void setNumberTimesDownInfeasible(int value) {
259  }
263  }
264 
266  inline int numberTimesUpInfeasible() const {
268  }
270  inline void setNumberTimesUpInfeasible(int value) {
271  numberTimesUpInfeasible_ = value;
272  }
276  }
277 
279  inline int numberBeforeTrust() const {
280  return numberBeforeTrust_;
281  }
283  inline void setNumberBeforeTrust(int value) {
284  numberBeforeTrust_ = value;
285  }
289  }
290 
292  virtual double upEstimate() const;
294  virtual double downEstimate() const;
295 
297  inline int method() const {
298  return method_;
299  }
301  inline void setMethod(int value) {
302  method_ = value;
303  }
304 
306  void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown);
308  void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp);
310  void setProbingInformation(int fixedDown, int fixedUp);
311 
313  void print(int type = 0, double value = 0.0) const;
315  bool same(const CbcSimpleIntegerDynamicPseudoCost * obj) const;
316 protected:
318 
329  double sumDownCost_;
331  double sumUpCost_;
335  double sumUpChange_;
337  mutable double downShadowPrice_;
339  mutable double upShadowPrice_;
347  double lastUpCost_;
349  mutable int lastDownDecrease_;
351  mutable int lastUpDecrease_;
373 
377  int method_;
378 };
390 
391 public:
392 
395 
404  int way , double value) ;
405 
413  CbcIntegerPseudoCostBranchingObject (CbcModel *model, int variable, int way,
414  double lowerValue, double upperValue) ;
415 
418 
421 
423  virtual CbcBranchingObject * clone() const;
424 
427 
433  virtual double branch();
434 
436  inline double changeInGuessed() const {
437  return changeInGuessed_;
438  }
440  inline void setChangeInGuessed(double value) {
441  changeInGuessed_ = value;
442  }
443 
445  virtual CbcBranchObjType type() const {
447  }
448 
458  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
459 
460 protected:
463 };
464 #endif
465 
Simple branching object for an integer variable.
void fillCreateBranch(CbcIntegerBranchingObject *branching, const OsiBranchingInformation *info, int way)
Fills in a created branching object.
void updateAfterMini(int numberDown, int numberDownInfeasible, double sumDown, int numberUp, int numberUpInfeasible, double sumUp)
Updates stuff like pseudocosts after mini branch and bound.
virtual void updateBefore(const OsiObject *rhs)
Updates stuff like pseudocosts before threads.
void incrementNumberTimesUp()
Increment up number times.
void addToSumDownCost(double value)
Add to down sum cost and set last and square.
double upShadowPrice_
Current pseudo-shadow price estimate up.
bool same(const CbcSimpleIntegerDynamicPseudoCost *obj) const
Same - returns true if contents match(ish)
void setDownDynamicPseudoCost(double value)
Set down pseudo cost.
void setUpShadowPrice(double value)
Set up pseudo shadow price cost.
int numberTimesUpInfeasible() const
Up number times infeasible.
void setNumberTimesDownInfeasible(int value)
Set down number times infeasible.
int numberBeforeTrust() const
Number of times before trusted.
void setSumDownCost(double value)
Set down sum cost.
void setSumUpCost(double value)
Set up sum cost.
void addToSumDownDecrease(double value)
Add to sum down decrease number infeasibilities from strong or actual.
virtual ~CbcIntegerPseudoCostBranchingObject()
Destructor.
int numberTimesDownInfeasible_
Number of times we have been infeasible going down.
void setUpDynamicPseudoCost(double value)
Set up pseudo cost.
CbcIntegerPseudoCostBranchingObject & operator=(const CbcIntegerPseudoCostBranchingObject &rhs)
Assignment operator.
CbcIntegerPseudoCostBranchingObject()
Default constructor.
virtual CbcBranchingObject * clone() const
Clone.
double sumUpDecrease_
Sum up decrease number infeasibilities from strong or actual.
void setNumberBeforeTrust(int value)
Set number of times before trusted.
int numberTimesDown_
Number of times we have gone down.
void incrementNumberBeforeTrust()
Increment number of times before trusted.
double downDynamicPseudoCost() const
Down pseudo cost.
void addToSumUpDecrease(double value)
Add to sum up decrease number infeasibilities from strong or actual.
double numberTimesDownTotalFixed_
Number of total probing fixings going down.
void incrementNumberTimesDown()
Increment down number times.
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
int method_
Number of times infeasible when tested.
void print(int type=0, double value=0.0) const
Print - 0 -summary, 1 just before strong.
CbcRangeCompare
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way)
Creates a branching object.
Define a single integer class but with dynamic pseudo costs.
int numberTimesDownInfeasible() const
Down number times infeasible.
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
int numberTimesUp_
Number of times we have gone up.
virtual void updateInformation(const CbcObjectUpdateData &data)
Update object by CbcObjectUpdateData.
double sumUpDecrease() const
Sum up decrease number infeasibilities from strong or actual.
int numberTimesDownLocalFixed_
Number of local probing fixings going down.
int preferredWay() const
If -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcObject.hpp:245
void setUpDownSeparator(double value)
Set up down separator.
Define a single integer class.
virtual double upEstimate() const
Return "up" estimate.
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap=false)
Compare the this with brObj.
int numberTimesProbingTotal_
Number of times probing done.
virtual double branch()
Sets the bounds for the variable according to the current arm of the branch and advances the object s...
double downShadowPrice_
Current pseudo-shadow price estimate down.
int variable() const
Index identifying the associated CbcObject within its class.
virtual double infeasibility(const OsiBranchingInformation *info, int &preferredWay) const
Infeasibility - large is 0.5.
void addToSumUpChange(double value)
Add to up sum change and set last and square.
double sumDownDecrease_
Sum down decrease number infeasibilities from strong or actual.
void setSumUpChange(double value)
Set up sum change.
double sumUpCost_
Sum up cost from strong or actual.
void updateUpDynamicPseudoCost(double value)
Modify up pseudo cost in a slightly different way.
CbcModel * model() const
Return model.
Definition: CbcObject.hpp:240
double upShadowPrice() const
Up pseudo shadow price cost.
int way() const
Get the state of the branching object.
double sumUpChange_
Sum of all changes to x when going up.
double sumDownChange_
Sum of all changes to x when going down.
void setProbingInformation(int fixedDown, int fixedUp)
Pass in probing information.
void addToSumDownChange(double value)
Add to down sum change.
virtual CbcBranchObjType type() const
Return the type (an integer identifier) of this.
void incrementNumberTimesUpInfeasible()
Increment up number times infeasible.
Abstract branching object base class Now just difference with OsiBranchingObject. ...
double sumDownCost_
Sum down cost from strong or actual.
Information required while the node is live.
Definition: CbcNode.hpp:49
CbcSimpleIntegerDynamicPseudoCost & operator=(const CbcSimpleIntegerDynamicPseudoCost &rhs)
void setSumUpDecrease(double value)
Set sum up decrease number infeasibilities from strong or actual.
void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp)
Pass in information on a up branch.
void setNumberTimesDown(int value)
Set down number times.
CbcBranchObjType
int lastUpDecrease_
Last up decrease number infeasibilities from strong (i.e. as computed by last strong) ...
int numberBeforeTrust_
Number of branches before we trust.
int method() const
method - see below for details
CbcModel * model() const
Return model.
virtual double branch()=0
Execute the actions required to branch, as specified by the current state of the branching object...
void copySome(const CbcSimpleIntegerDynamicPseudoCost *otherObject)
Copy some information i.e. just variable stuff.
void setNumberTimesUpInfeasible(int value)
Set up number times infeasible.
double breakEven() const
Breakeven e.g 0.7 -> >= 0.7 go up first.
void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown)
Pass in information on a down branch.
double changeInGuessed() const
Change in guessed.
void setSumDownDecrease(double value)
Set sum down decrease number infeasibilities from strong or actual.
void addToSumUpCost(double value)
Add to up sum cost and set last and square.
double changeInGuessed_
Change in guessed objective value for next branch.
void setChangeInGuessed(double value)
Set change in guessed.
double numberTimesUpTotalFixed_
Number of total probing fixings going up.
void incrementNumberTimesDownInfeasible()
Increment down number times infeasible.
void setNumberTimesUp(int value)
Set up number times.
double upDownSeparator_
Up/down separator If >0.0 then do first branch up if value-floor(value) >= this value.
Simple branching object for an integer variable with pseudo costs.
double downShadowPrice() const
Down pseudo shadow price cost.
int numberTimesUpLocalFixed_
Number of local probing fixings going up.
virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface *solver, const CbcNode *node, const CbcBranchingObject *branchingObject)
Pass in information on branch just done and create CbcObjectUpdateData instance.
int lastDownDecrease_
Last down decrease number infeasibilities from strong (i.e. as computed by last strong) ...
void setSumDownChange(double value)
Set down sum change.
void setDownShadowPrice(double value)
Set down pseudo shadow price cost.
virtual void updateAfter(const OsiObject *rhs, const OsiObject *baseObject)
Updates stuff like pseudocosts after threads finished.
double lastUpCost_
Last up cost from strong (i.e. as computed by last strong)
virtual double downEstimate() const
Return "down" estimate (default 1.0e-5)
virtual CbcObject * clone() const
Clone.
Simple Branch and bound class.
Definition: CbcModel.hpp:100
int numberTimesUpInfeasible_
Number of times we have been infeasible going up.
double lastDownCost_
Last down cost from strong (i.e. as computed by last strong)
double sumDownDecrease() const
Sum down decrease number infeasibilities from strong or actual.
double upDownSeparator() const
Up down separator.
void updateDownDynamicPseudoCost(double value)
Modify down pseudo cost in a slightly different way.