Cbc 2.10.5
Loading...
Searching...
No Matches
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
35public:
36 // Default Constructor
38
39 // Useful constructor - passed model index
41
42 // Useful constructor - passed model index and pseudo costs
45
46 // Useful constructor - passed model index and pseudo costs
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
75 virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface *solver,
76 const CbcNode *node,
77 const CbcBranchingObject *branchingObject);
79 virtual void updateInformation(const CbcObjectUpdateData &data);
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 {
101 }
103 void setDownDynamicPseudoCost(double value);
105 void updateDownDynamicPseudoCost(double value);
106
108 inline double upDynamicPseudoCost() const
109 {
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 {
277 }
278
280 inline int numberTimesBranched() const
281 {
283 }
285 inline int numberTimesDownInfeasible() const
286 {
288 }
290 inline void setNumberTimesDownInfeasible(int value)
291 {
293 }
299
301 inline int numberTimesUpInfeasible() const
302 {
304 }
306 inline void setNumberTimesUpInfeasible(int value)
307 {
309 }
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;
359
360protected:
362
381 mutable double downShadowPrice_;
383 mutable double upShadowPrice_;
393 mutable int lastDownDecrease_;
395 mutable int lastUpDecrease_;
417
422};
434
435public:
438
447 int way, double value);
448
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 {
486 changeInGuessed_ = value;
487 }
488
490 virtual CbcBranchObjType type() const
491 {
493 }
494
503 virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap = false);
504
505protected:
508};
509#ifdef SWITCH_VARIABLES
515class CbcSwitchingBinary : public CbcSimpleIntegerDynamicPseudoCost {
516
517public:
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
592protected:
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*/
CbcRangeCompare
@ SimpleIntegerDynamicPseudoCostBranchObj
Abstract branching object base class Now just difference with OsiBranchingObject.
virtual double branch()=0
Execute the actions required to branch, as specified by the current state of the branching object,...
CbcModel * model() const
Return model.
int variable() const
Index identifying the associated CbcObject within its class.
int way() const
Get the state of the branching object.
Simple branching object for an integer variable.
Simple branching object for an integer variable with pseudo costs.
virtual CbcBranchObjType type() const
Return the type (an integer identifier) of this.
void setChangeInGuessed(double value)
Set change in guessed.
CbcIntegerPseudoCostBranchingObject(CbcModel *model, int variable, int way, double value)
Create a standard floor/ceiling branch object.
CbcIntegerPseudoCostBranchingObject()
Default constructor.
virtual CbcBranchingObject * clone() const
Clone.
CbcIntegerPseudoCostBranchingObject(const CbcIntegerPseudoCostBranchingObject &)
Copy constructor.
virtual double branch()
Sets the bounds for the variable according to the current arm of the branch and advances the object s...
double changeInGuessed_
Change in guessed objective value for next branch.
CbcIntegerPseudoCostBranchingObject(CbcModel *model, int variable, int way, double lowerValue, double upperValue)
Create a degenerate branch object.
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap=false)
Compare the this with brObj.
virtual ~CbcIntegerPseudoCostBranchingObject()
Destructor.
CbcIntegerPseudoCostBranchingObject & operator=(const CbcIntegerPseudoCostBranchingObject &rhs)
Assignment operator.
Simple Branch and bound class.
Definition CbcModel.hpp:100
Information required while the node is live.
Definition CbcNode.hpp:49
CbcModel * model() const
Return model.
int preferredWay() const
If -1 down always chosen first, +1 up always, 0 normal.
Define a single integer class but with dynamic pseudo costs.
CbcSimpleIntegerDynamicPseudoCost(CbcModel *model, int iColumn, double downDynamicPseudoCost, double upDynamicPseudoCost)
void updateDownDynamicPseudoCost(double value)
Modify down pseudo cost in a slightly different way.
void setSumUpDecrease(double value)
Set sum up decrease number infeasibilities from strong or actual.
CbcSimpleIntegerDynamicPseudoCost(CbcModel *model, int dummy, int iColumn, double downDynamicPseudoCost, double upDynamicPseudoCost)
double sumUpChange_
Sum of all changes to x when going up.
double sumDownCost_
Sum down cost from strong or actual.
void setDownShadowPrice(double value)
Set down pseudo shadow price cost.
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way)
Creates a branching object.
CbcSimpleIntegerDynamicPseudoCost & operator=(const CbcSimpleIntegerDynamicPseudoCost &rhs)
void setNumberBeforeTrust(int value)
Set number of times before trusted.
virtual double upEstimate() const
Return "up" estimate.
void setNumberTimesUp(int value)
Set up number times.
void incrementNumberTimesUp()
Increment up number times.
int numberTimesDownLocalFixed_
Number of local probing fixings going down.
void addToSumUpCost(double value)
Add to up sum cost and set last and square.
int method_
Number of times infeasible when tested.
int numberTimesDownInfeasible() const
Down number times infeasible.
double sumDownChange_
Sum of all changes to x when going down.
void setNumberTimesDownInfeasible(int value)
Set down number times infeasible.
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.
int lastDownDecrease_
Last down decrease number infeasibilities from strong (i.e. as computed by last strong)
int numberBeforeTrust_
Number of branches before we trust.
double upShadowPrice_
Current pseudo-shadow price estimate up.
bool same(const CbcSimpleIntegerDynamicPseudoCost *obj) const
Same - returns true if contents match(ish)
double sumDownDecrease_
Sum down decrease number infeasibilities from strong or actual.
CbcSimpleIntegerDynamicPseudoCost(const CbcSimpleIntegerDynamicPseudoCost &)
void setDownDynamicPseudoCost(double value)
Set down pseudo cost.
int numberTimesBranched() const
Number times branched.
void setUpInformation(double changeObjectiveUp, int changeInfeasibilityUp)
Pass in information on a up branch.
void setNumberTimesDown(int value)
Set down number times.
double downDynamicPseudoCost() const
Down pseudo cost.
virtual void updateInformation(const CbcObjectUpdateData &data)
Update object by CbcObjectUpdateData.
void addToSumUpDecrease(double value)
Add to sum up decrease number infeasibilities from strong or actual.
double sumUpCost_
Sum up cost from strong or actual.
void incrementNumberTimesUpInfeasible()
Increment up number times infeasible.
int method() const
method - see below for details
double sumDownDecrease() const
Sum down decrease number infeasibilities from strong or actual.
void setNumberTimesUpInfeasible(int value)
Set up number times infeasible.
int numberTimesDownInfeasible_
Number of times we have been infeasible going down.
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.
virtual double infeasibility(const OsiBranchingInformation *info, int &preferredWay) const
Infeasibility - large is 0.5.
double downShadowPrice_
Current pseudo-shadow price estimate down.
void incrementNumberTimesDownInfeasible()
Increment down number times infeasible.
void setSumUpChange(double value)
Set up sum change.
void addToSumDownDecrease(double value)
Add to sum down decrease number infeasibilities from strong or actual.
double numberTimesDownTotalFixed_
Number of total probing fixings going down.
void setSumDownCost(double value)
Set down sum cost.
double upShadowPrice() const
Up pseudo shadow price cost.
virtual double downEstimate() const
Return "down" estimate (default 1.0e-5)
void setUpShadowPrice(double value)
Set up pseudo shadow price cost.
void addToSumDownCost(double value)
Add to down sum cost and set last and square.
void updateUpDynamicPseudoCost(double value)
Modify up pseudo cost in a slightly different way.
double sumUpDecrease() const
Sum up decrease number infeasibilities from strong or actual.
virtual void updateBefore(const OsiObject *rhs)
Updates stuff like pseudocosts before threads.
virtual CbcObject * clone() const
Clone.
void setUpDownSeparator(double value)
Set up down separator.
int numberTimesUpInfeasible() const
Up number times infeasible.
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.
int numberTimesUpLocalFixed_
Number of local probing fixings going up.
int numberBeforeTrust() const
Number of times before trusted.
void updateAfterMini(int numberDown, int numberDownInfeasible, double sumDown, int numberUp, int numberUpInfeasible, double sumUp)
Updates stuff like pseudocosts after mini branch and bound.
int numberTimesDown_
Number of times we have gone down.
void setUpDynamicPseudoCost(double value)
Set up pseudo cost.
double lastDownCost_
Last down cost from strong (i.e. as computed by last strong)
void incrementNumberTimesDown()
Increment down number times.
void setProbingInformation(int fixedDown, int fixedUp)
Pass in probing information.
int numberTimesUp_
Number of times we have gone up.
CbcSimpleIntegerDynamicPseudoCost(CbcModel *model, int iColumn, double breakEven=0.5)
void addToSumUpChange(double value)
Add to up sum change and set last and square.
void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown)
Pass in information on a down branch.
int numberTimesUpInfeasible_
Number of times we have been infeasible going up.
virtual void updateAfter(const OsiObject *rhs, const OsiObject *baseObject)
Updates stuff like pseudocosts after threads finished.
void incrementNumberBeforeTrust()
Increment number of times before trusted.
double sumUpDecrease_
Sum up decrease number infeasibilities from strong or actual.
int numberTimesProbingTotal_
Number of times probing done.
void copySome(const CbcSimpleIntegerDynamicPseudoCost *otherObject)
Copy some information i.e. just variable stuff.
double lastUpCost_
Last up cost from strong (i.e. as computed by last strong)
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
double downShadowPrice() const
Down pseudo shadow price cost.
int lastUpDecrease_
Last up decrease number infeasibilities from strong (i.e. as computed by last strong)
void addToSumDownChange(double value)
Add to down sum change.
Define a single integer class.
double breakEven() const
Breakeven e.g 0.7 -> >= 0.7 go up first.
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.