Cbc  2.10.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbcSimpleIntegerDynamicPseudoCost.hpp
Go to the documentation of this file.
1 // $Id: CbcSimpleIntegerDynamicPseudoCost.hpp 2465 2019-01-03 19:26:52Z unxusr $
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 
34 
35 public:
36  // Default Constructor
38 
39  // Useful constructor - passed model index
40  CbcSimpleIntegerDynamicPseudoCost(CbcModel *model, int iColumn, double breakEven = 0.5);
41 
42  // Useful constructor - passed model index and pseudo costs
43  CbcSimpleIntegerDynamicPseudoCost(CbcModel *model, int iColumn,
45 
46  // Useful constructor - passed model index and pseudo costs
47  CbcSimpleIntegerDynamicPseudoCost(CbcModel *model, int dummy, int iColumn,
48  double downDynamicPseudoCost, double upDynamicPseudoCost);
49 
50  // Copy constructor
52 
54  virtual CbcObject *clone() const;
55 
56  // Assignment operator
58 
59  // Destructor
61 
63  virtual double infeasibility(const OsiBranchingInformation *info,
64  int &preferredWay) const;
65 
67  virtual CbcBranchingObject *createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way);
68 
70  // void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
71 
76  const CbcNode *node,
77  const CbcBranchingObject *branchingObject);
79  virtual void updateInformation(const CbcObjectUpdateData &data);
81  void copySome(const CbcSimpleIntegerDynamicPseudoCost *otherObject);
83  virtual void updateBefore(const OsiObject *rhs);
85  virtual void updateAfter(const OsiObject *rhs, const OsiObject *baseObject);
87  void updateAfterMini(int numberDown, int numberDownInfeasible, double sumDown,
88  int numberUp, int numberUpInfeasible, double sumUp);
89 
95  virtual OsiSolverBranch *solverBranch() const;
96 
98  inline double downDynamicPseudoCost() const
99  {
100  return downDynamicPseudoCost_;
101  }
103  void setDownDynamicPseudoCost(double value);
105  void updateDownDynamicPseudoCost(double value);
106 
108  inline double upDynamicPseudoCost() const
109  {
110  return upDynamicPseudoCost_;
111  }
113  void setUpDynamicPseudoCost(double value);
115  void updateUpDynamicPseudoCost(double value);
116 
118  inline double downShadowPrice() const
119  {
120  return downShadowPrice_;
121  }
123  inline void setDownShadowPrice(double value)
124  {
125  downShadowPrice_ = value;
126  }
128  inline double upShadowPrice() const
129  {
130  return upShadowPrice_;
131  }
133  inline void setUpShadowPrice(double value)
134  {
135  upShadowPrice_ = value;
136  }
137 
139  inline double upDownSeparator() const
140  {
141  return upDownSeparator_;
142  }
144  inline void setUpDownSeparator(double value)
145  {
146  upDownSeparator_ = value;
147  }
148 
150  inline double sumDownCost() const
151  {
152  return sumDownCost_;
153  }
155  inline void setSumDownCost(double value)
156  {
157  sumDownCost_ = value;
158  }
160  inline void addToSumDownCost(double value)
161  {
162  sumDownCost_ += value;
163  lastDownCost_ = value;
164  }
165 
167  inline double sumUpCost() const
168  {
169  return sumUpCost_;
170  }
172  inline void setSumUpCost(double value)
173  {
174  sumUpCost_ = value;
175  }
177  inline void addToSumUpCost(double value)
178  {
179  sumUpCost_ += value;
180  lastUpCost_ = value;
181  }
182 
184  inline double sumDownChange() const
185  {
186  return sumDownChange_;
187  }
189  inline void setSumDownChange(double value)
190  {
191  sumDownChange_ = value;
192  }
194  inline void addToSumDownChange(double value)
195  {
196  sumDownChange_ += value;
197  }
198 
200  inline double sumUpChange() const
201  {
202  return sumUpChange_;
203  }
205  inline void setSumUpChange(double value)
206  {
207  sumUpChange_ = value;
208  }
210  inline void addToSumUpChange(double value)
211  {
212  sumUpChange_ += value;
213  }
214 
216  inline double sumDownDecrease() const
217  {
218  return sumDownDecrease_;
219  }
221  inline void setSumDownDecrease(double value)
222  {
223  sumDownDecrease_ = value;
224  }
226  inline void addToSumDownDecrease(double value)
227  {
228  sumDownDecrease_ += value; /*lastDownDecrease_ = (int) value;*/
229  }
230 
232  inline double sumUpDecrease() const
233  {
234  return sumUpDecrease_;
235  }
237  inline void setSumUpDecrease(double value)
238  {
239  sumUpDecrease_ = value;
240  }
242  inline void addToSumUpDecrease(double value)
243  {
244  sumUpDecrease_ += value; /*lastUpDecrease_ = (int) value;*/
245  }
246 
248  inline int numberTimesDown() const
249  {
250  return numberTimesDown_;
251  }
253  inline void setNumberTimesDown(int value)
254  {
255  numberTimesDown_ = value;
256  }
259  {
261  }
262 
264  inline int numberTimesUp() const
265  {
266  return numberTimesUp_;
267  }
269  inline void setNumberTimesUp(int value)
270  {
271  numberTimesUp_ = value;
272  }
275  {
276  numberTimesUp_++;
277  }
278 
280  inline int numberTimesBranched() const
281  {
283  }
285  inline int numberTimesDownInfeasible() const
286  {
288  }
290  inline void setNumberTimesDownInfeasible(int value)
291  {
293  }
296  {
298  }
299 
301  inline int numberTimesUpInfeasible() const
302  {
304  }
306  inline void setNumberTimesUpInfeasible(int value)
307  {
308  numberTimesUpInfeasible_ = value;
309  }
312  {
314  }
315 
317  inline int numberBeforeTrust() const
318  {
319  return numberBeforeTrust_;
320  }
322  inline void setNumberBeforeTrust(int value)
323  {
324  numberBeforeTrust_ = value;
325  }
328  {
330  }
331 
333  virtual double upEstimate() const;
335  virtual double downEstimate() const;
336 
338  inline int method() const
339  {
340  return method_;
341  }
343  inline void setMethod(int value)
344  {
345  method_ = value;
346  }
347 
349  void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown);
351  void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp);
353  void setProbingInformation(int fixedDown, int fixedUp);
354 
356  void print(int type = 0, double value = 0.0) const;
358  bool same(const CbcSimpleIntegerDynamicPseudoCost *obj) const;
359 
360 protected:
362 
373  double sumDownCost_;
375  double sumUpCost_;
379  double sumUpChange_;
381  mutable double downShadowPrice_;
383  mutable double upShadowPrice_;
391  double lastUpCost_;
393  mutable int lastDownDecrease_;
395  mutable int lastUpDecrease_;
417 
421  int method_;
422 };
434 
435 public:
438 
447  int way, double value);
448 
456  CbcIntegerPseudoCostBranchingObject(CbcModel *model, int variable, int way,
457  double lowerValue, double upperValue);
458 
461 
464 
466  virtual CbcBranchingObject *clone() const;
467 
470 
476  virtual double branch();
477 
479  inline double changeInGuessed() const
480  {
481  return changeInGuessed_;
482  }
484  inline void setChangeInGuessed(double value)
485  {
487  }
488 
490  virtual CbcBranchObjType type() const
491  {
493  }
494 
503  virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap = false);
504 
505 protected:
508 };
509 #ifdef SWITCH_VARIABLES
510 
515 class CbcSwitchingBinary : public CbcSimpleIntegerDynamicPseudoCost {
516 
517 public:
518  // Default Constructor
519  CbcSwitchingBinary();
520 
521  // Useful constructor
522  CbcSwitchingBinary(CbcSimpleIntegerDynamicPseudoCost *oldObject,
523  int nOdd, const int *other, const int *otherRow);
524 
525  // Copy constructor
526  CbcSwitchingBinary(const CbcSwitchingBinary &);
527 
529  virtual CbcObject *clone() const;
530 
531  // Assignment operator
532  CbcSwitchingBinary &operator=(const CbcSwitchingBinary &rhs);
533 
534  // Destructor
535  virtual ~CbcSwitchingBinary();
536 
538  void addZeroSwitches(int nAdd, const int *columns);
540  virtual double infeasibility(const OsiBranchingInformation *info,
541  int &preferredWay) const;
542 
544  bool same(const CbcSwitchingBinary *obj) const;
546  virtual int setAssociatedBounds(OsiSolverInterface *solver = NULL,
547  int cleanBasis = 0) const;
549  int checkAssociatedBounds(const OsiSolverInterface *solver, const double *solution,
550  int printLevel, int state[3], int &nBadFixed) const;
552  inline const double *zeroLowerBound() const
553  {
554  return zeroLowerBound_;
555  }
557  inline const double *oneLowerBound() const
558  {
559  return oneLowerBound_;
560  }
562  inline const double *zeroUpperBound() const
563  {
564  return zeroUpperBound_;
565  }
567  inline const double *oneUpperBound() const
568  {
569  return oneUpperBound_;
570  }
573  inline const int *otherVariable() const
574  {
575  return otherVariable_;
576  }
578  inline int numberOther() const
579  {
580  return numberOther_;
581  }
587  inline int type() const
588  {
589  return type_;
590  }
591 
592 protected:
594 
596  double *zeroLowerBound_;
598  double *oneLowerBound_;
600  double *zeroUpperBound_;
602  double *oneUpperBound_;
605  int *otherVariable_;
607  int numberOther_;
613  int type_;
614 };
615 #endif
616 #endif
617 
618 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
619 */
Simple branching object for an integer variable.
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.
double value() const
Current value.
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:258
void setUpDownSeparator(double value)
Set up down separator.
Abstract Base Class for describing an interface to a solver.
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.
void addToSumUpChange(double value)
Add to up sum change and set last and square.
double infeasibility() const
Return infeasibility.
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:252
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 numberTimesBranched() const
Number times branched.
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)
Fills in a created branching object.
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)
Solver Branch Class.
virtual double downEstimate() const
Return "down" estimate (default 1.0e-5)
virtual CbcObject * clone() const
Clone.
Abstract base class for `objects'.
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.