Dip-All  0.91.0
CbcSimpleIntegerDynamicPseudoCost.hpp
Go to the documentation of this file.
1 // $Id: CbcSimpleIntegerDynamicPseudoCost.hpp 2094 2014-11-18 11:15:36Z forrest $
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 
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 numberTimesBranched() const {
255  }
257  inline int numberTimesDownInfeasible() const {
259  }
261  inline void setNumberTimesDownInfeasible(int value) {
263  }
267  }
268 
270  inline int numberTimesUpInfeasible() const {
272  }
274  inline void setNumberTimesUpInfeasible(int value) {
275  numberTimesUpInfeasible_ = value;
276  }
280  }
281 
283  inline int numberBeforeTrust() const {
284  return numberBeforeTrust_;
285  }
287  inline void setNumberBeforeTrust(int value) {
288  numberBeforeTrust_ = value;
289  }
293  }
294 
296  virtual double upEstimate() const;
298  virtual double downEstimate() const;
299 
301  inline int method() const {
302  return method_;
303  }
305  inline void setMethod(int value) {
306  method_ = value;
307  }
308 
310  void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown);
312  void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp);
314  void setProbingInformation(int fixedDown, int fixedUp);
315 
317  void print(int type = 0, double value = 0.0) const;
319  bool same(const CbcSimpleIntegerDynamicPseudoCost * obj) const;
320 protected:
322 
333  double sumDownCost_;
335  double sumUpCost_;
339  double sumUpChange_;
341  mutable double downShadowPrice_;
343  mutable double upShadowPrice_;
351  double lastUpCost_;
353  mutable int lastDownDecrease_;
355  mutable int lastUpDecrease_;
377 
381  int method_;
382 };
394 
395 public:
396 
399 
408  int way , double value) ;
409 
417  CbcIntegerPseudoCostBranchingObject (CbcModel *model, int variable, int way,
418  double lowerValue, double upperValue) ;
419 
422 
425 
427  virtual CbcBranchingObject * clone() const;
428 
431 
437  virtual double branch();
438 
440  inline double changeInGuessed() const {
441  return changeInGuessed_;
442  }
444  inline void setChangeInGuessed(double value) {
446  }
447 
449  virtual CbcBranchObjType type() const {
451  }
452 
462  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
463 
464 protected:
467 };
468 #ifdef SWITCH_VARIABLES
469 
475 class CbcSwitchingBinary : public CbcSimpleIntegerDynamicPseudoCost {
476 
477 public:
478 
479  // Default Constructor
480  CbcSwitchingBinary ();
481 
482  // Useful constructor
483  CbcSwitchingBinary (CbcSimpleIntegerDynamicPseudoCost * oldObject,
484  int nOdd,const int * other, const int * otherRow);
485 
486 
487  // Copy constructor
488  CbcSwitchingBinary ( const CbcSwitchingBinary &);
489 
491  virtual CbcObject * clone() const;
492 
493  // Assignment operator
494  CbcSwitchingBinary & operator=( const CbcSwitchingBinary& rhs);
495 
496  // Destructor
497  virtual ~CbcSwitchingBinary ();
498 
500  void addZeroSwitches(int nAdd,const int * columns);
502  virtual double infeasibility(const OsiBranchingInformation * info,
503  int &preferredWay) const;
504 
506  bool same(const CbcSwitchingBinary * obj) const;
508  virtual int setAssociatedBounds(OsiSolverInterface * solver=NULL,
509  int cleanBasis=0) const;
511  int checkAssociatedBounds(const OsiSolverInterface * solver,const double * solution,
512  int printLevel, int state[3], int & nBadFixed) const;
514  inline const double * zeroLowerBound() const
515  { return zeroLowerBound_; }
517  inline const double * oneLowerBound() const
518  { return oneLowerBound_; }
520  inline const double * zeroUpperBound() const
521  { return zeroUpperBound_; }
523  inline const double * oneUpperBound() const
524  { return oneUpperBound_; }
527  inline const int * otherVariable() const
528  { return otherVariable_;}
530  inline int numberOther() const
531  { return numberOther_;}
537  inline int type() const
538  { return type_;}
539 protected:
541 
543  double * zeroLowerBound_;
545  double * oneLowerBound_;
547  double * zeroUpperBound_;
549  double * oneUpperBound_;
552  int * otherVariable_;
554  int numberOther_;
560  int type_;
561 };
562 #endif
563 #endif
564 
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.
CbcRangeCompare
double downShadowPrice_
Current pseudo-shadow price estimate down.
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.
int numberTimesBranched() const
Number times branched.
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 infeasibility() const
Return infeasibility.
double sumDownDecrease_
Sum down decrease number infeasibilities from strong or actual.
void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp)
Pass in information on a up branch.
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.
double value() const
Current value.
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)
Fills in a created branching object.
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 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:245
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.
Abstract Base Class for describing an interface to a solver.
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:240
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:49
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
Solver Branch Class.
CbcBranchObjType
Abstract base class for `objects'.
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:101
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.