CbcSimpleInteger.hpp
Go to the documentation of this file.
1 // Edwin 11/9/2009-- carved out of CbcBranchActual
2 
3 #ifndef CbcSimpleInteger_H
4 #define CbcSimpleInteger_H
5 
17 
18 public:
19 
22 
31  int way , double value) ;
32 
40  CbcIntegerBranchingObject (CbcModel *model, int variable, int way,
41  double lowerValue, double upperValue) ;
42 
45 
48 
50  virtual CbcBranchingObject * clone() const;
51 
53  virtual ~CbcIntegerBranchingObject ();
54 
56  void fillPart ( int variable, int way , double value) ;
62  virtual double branch();
65  virtual void fix(OsiSolverInterface * solver,
66  double * lower, double * upper,
67  int branchState) const ;
70  virtual bool tighten(OsiSolverInterface * ) ;
71 
72 #ifdef JJF_ZERO
73  // No need to override. Default works fine.
77  virtual void previousBranch();
78 #endif
79 
83  virtual void print();
84 
86  inline const double * downBounds() const {
87  return down_;
88  }
90  inline const double * upBounds() const {
91  return up_;
92  }
94  inline void setDownBounds(const double bounds[2]) {
95  memcpy(down_, bounds, 2*sizeof(double));
96  }
98  inline void setUpBounds(const double bounds[2]) {
99  memcpy(up_, bounds, 2*sizeof(double));
100  }
101 #ifdef FUNNY_BRANCHING
102 
104  inline const int * variables() const {
105  return variables_;
106  }
107  // New bound
108  inline const double * newBounds() const {
109  return newBounds_;
110  }
112  inline int numberExtraChangedBounds() const {
113  return numberExtraChangedBounds_;
114  }
116  int applyExtraBounds(int iColumn, double lower, double upper, int way) ;
118  void deactivate();
120  inline bool active() const {
121  return (down_[1] != -COIN_DBL_MAX);
122  }
123 #endif
124 
126  virtual CbcBranchObjType type() const {
127  return SimpleIntegerBranchObj;
128  }
129 
139  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
140 
141 protected:
143  double down_[2];
145  double up_[2];
146 #ifdef FUNNY_BRANCHING
147 
149  int * variables_;
150  // New bound
151  double * newBounds_;
153  int numberExtraChangedBounds_;
154 #endif
155 };
156 
158 
159 
160 class CbcSimpleInteger : public CbcObject {
161 
162 public:
163 
164  // Default Constructor
165  CbcSimpleInteger ();
166 
167  // Useful constructor - passed model and index
168  CbcSimpleInteger (CbcModel * model, int iColumn, double breakEven = 0.5);
169 
170  // Useful constructor - passed model and Osi object
171  CbcSimpleInteger (CbcModel * model, const OsiSimpleInteger * object);
172 
173  // Copy constructor
175 
177  virtual CbcObject * clone() const;
178 
179  // Assignment operator
181 
182  // Destructor
183  virtual ~CbcSimpleInteger ();
185  OsiSimpleInteger * osiObject() const;
187  virtual double infeasibility(const OsiBranchingInformation * info,
188  int &preferredWay) const;
189 
196  virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
197 
203  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;
205  void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
206 
212  virtual OsiSolverBranch * solverBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
213 
220  virtual void feasibleRegion();
221 
226  virtual int columnNumber() const;
228  inline void setColumnNumber(int value) {
229  columnNumber_ = value;
230  }
231 
236  virtual void resetBounds(const OsiSolverInterface * solver) ;
237 
240  virtual void resetSequenceEtc(int numberColumns, const int * originalColumns) ;
242  inline double originalLowerBound() const {
243  return originalLower_;
244  }
245  inline void setOriginalLowerBound(double value) {
246  originalLower_ = value;
247  }
248  inline double originalUpperBound() const {
249  return originalUpper_;
250  }
251  inline void setOriginalUpperBound(double value) {
252  originalUpper_ = value;
253  }
255  inline double breakEven() const {
256  return breakEven_;
257  }
259  inline void setBreakEven(double value) {
260  breakEven_ = value;
261  }
262 
263 
264 protected:
266 
272  double breakEven_;
277 };
278 #endif
279 
virtual void resetSequenceEtc(int numberColumns, const int *originalColumns)
Change column numbers after preprocessing.
Abstract branching object base class Now just difference with OsiBranchingObject. ...
const double * upBounds() const
Lower and upper bounds for up branch.
Define a single integer class.
CbcRangeCompare
virtual void print() const
Print something about branch - only if log level high.
virtual ~CbcSimpleInteger()
virtual void fix(OsiSolverInterface *solver, double *lower, double *upper, int branchState) const
Update bounds in solver as in 'branch' and update given bounds.
CbcBranchObjType
virtual CbcBranchingObject * clone() const
Clone.
CbcIntegerBranchingObject & operator=(const CbcIntegerBranchingObject &rhs)
Assignment operator.
double breakEven_
Breakeven i.e. >= this preferred is up.
int columnNumber_
Column number in model.
int variable() const
Index identifying the associated CbcObject within its class.
CbcIntegerBranchingObject()
Default constructor.
int preferredWay_
If -1 down always chosen first, +1 up always, 0 normal.
void fillPart(int variable, int way, double value)
Does part of constructor.
virtual void resetBounds(const OsiSolverInterface *solver)
Reset variable bounds to their original values.
virtual void feasibleRegion()=0
For the variable(s) referenced by the object, look at the current solution and set bounds to match th...
virtual int columnNumber() const
Column number if single column object -1 otherwise, so returns >= 0 Used by heuristics.
double originalUpperBound() const
int preferredWay() const
If -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcObject.hpp:235
double originalLowerBound() const
Original bounds.
virtual bool tighten(OsiSolverInterface *)
Change (tighten) bounds in object to reflect bounds in solver.
void setDownBounds(const double bounds[2])
Set lower and upper bounds for down branch.
virtual CbcObject * clone() const
Clone.
Simple branching object for an integer variable.
void setOriginalLowerBound(double value)
virtual void feasibleRegion()
Set bounds to fix the variable at the current (integer) value.
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child...
int way() const
Get the state of the branching object.
virtual void print()
Print something about branch - only if log level high.
OsiSimpleInteger * osiObject() const
Construct an OsiSimpleInteger object.
void setBreakEven(double value)
Set breakeven e.g 0.7 -> >= 0.7 go up first.
void setOriginalUpperBound(double value)
double originalLower_
data
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap=false)
Compare the this with brObj.
double up_[2]
Lower [0] and upper [1] bounds for the up arm (way_ = 1)
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way)
Create a branching object and indicate which way to branch first.
double down_[2]
Lower [0] and upper [1] bounds for the down arm (way_ = -1)
virtual CbcBranchObjType type() const
Return the type (an integer identifier) of this.
virtual ~CbcIntegerBranchingObject()
Destructor.
void setColumnNumber(int value)
Set column number.
virtual double infeasibility(const OsiBranchingInformation *info, int &preferredWay) const
Infeasibility - large is 0.5.
double originalUpper_
Original upper bound.
void setUpBounds(const double bounds[2])
Set lower and upper bounds for up branch.
virtual double branch()
Sets the bounds for the variable according to the current arm of the branch and advances the object s...
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
CbcModel * model() const
Return model.
Simple Branch and bound class.
Definition: CbcModel.hpp:98
void fillCreateBranch(CbcIntegerBranchingObject *branching, const OsiBranchingInformation *info, int way)
Fills in a created branching object.
CbcSimpleInteger & operator=(const CbcSimpleInteger &rhs)
const double * downBounds() const
Lower and upper bounds for down branch.
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...