Cbc  2.9.9
CbcSimpleInteger.hpp
Go to the documentation of this file.
1 // $Id: CbcSimpleInteger.hpp 1943 2013-07-21 09:05:45Z forrest $
2 // Copyright (C) 2002, 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/9/2009-- carved out of CbcBranchActual
7 
8 #ifndef CbcSimpleInteger_H
9 #define CbcSimpleInteger_H
10 
11 #include "CbcBranchingObject.hpp"
12 
24 
25 public:
26 
29 
38  int way , double value) ;
39 
48  double lowerValue, double upperValue) ;
49 
52 
55 
57  virtual CbcBranchingObject * clone() const;
58 
61 
63  void fillPart ( int variable, int way , double value) ;
69  virtual double branch();
72  virtual void fix(OsiSolverInterface * solver,
73  double * lower, double * upper,
74  int branchState) const ;
77  virtual bool tighten(OsiSolverInterface * ) ;
78 
79 #ifdef JJF_ZERO
80  // No need to override. Default works fine.
84  virtual void previousBranch();
85 #endif
86 
90  virtual void print();
91 
93  inline const double * downBounds() const {
94  return down_;
95  }
97  inline const double * upBounds() const {
98  return up_;
99  }
101  inline void setDownBounds(const double bounds[2]) {
102  memcpy(down_, bounds, 2*sizeof(double));
103  }
105  inline void setUpBounds(const double bounds[2]) {
106  memcpy(up_, bounds, 2*sizeof(double));
107  }
108 #ifdef FUNNY_BRANCHING
109 
111  inline const int * variables() const {
112  return variables_;
113  }
114  // New bound
115  inline const double * newBounds() const {
116  return newBounds_;
117  }
119  inline int numberExtraChangedBounds() const {
120  return numberExtraChangedBounds_;
121  }
123  int applyExtraBounds(int iColumn, double lower, double upper, int way) ;
125  void deactivate();
127  inline bool active() const {
128  return (down_[1] != -COIN_DBL_MAX);
129  }
130 #endif
131 
133  virtual CbcBranchObjType type() const {
134  return SimpleIntegerBranchObj;
135  }
136 
146  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
147 
148 protected:
150  double down_[2];
152  double up_[2];
153 #ifdef FUNNY_BRANCHING
154 
156  int * variables_;
157  // New bound
158  double * newBounds_;
160  int numberExtraChangedBounds_;
161 #endif
162 };
163 
165 
166 
167 class CbcSimpleInteger : public CbcObject {
168 
169 public:
170 
171  // Default Constructor
173 
174  // Useful constructor - passed model and index
175  CbcSimpleInteger (CbcModel * model, int iColumn, double breakEven = 0.5);
176 
177  // Useful constructor - passed model and Osi object
178  CbcSimpleInteger (CbcModel * model, const OsiSimpleInteger * object);
179 
180  // Copy constructor
182 
184  virtual CbcObject * clone() const;
185 
186  // Assignment operator
188 
189  // Destructor
190  virtual ~CbcSimpleInteger ();
192  OsiSimpleInteger * osiObject() const;
194  virtual double infeasibility(const OsiBranchingInformation * info,
195  int &preferredWay) const;
196 
203  virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
204 
210  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;
212  /*virtual*/ void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
213 
219  virtual OsiSolverBranch * solverBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
220 
227  virtual void feasibleRegion();
228 
233  virtual int columnNumber() const;
235  inline void setColumnNumber(int value) {
236  columnNumber_ = value;
237  }
238 
243  virtual void resetBounds(const OsiSolverInterface * solver) ;
244 
247  virtual void resetSequenceEtc(int numberColumns, const int * originalColumns) ;
249  inline double originalLowerBound() const {
250  return originalLower_;
251  }
252  inline void setOriginalLowerBound(double value) {
253  originalLower_ = value;
254  }
255  inline double originalUpperBound() const {
256  return originalUpper_;
257  }
258  inline void setOriginalUpperBound(double value) {
259  originalUpper_ = value;
260  }
262  inline double breakEven() const {
263  return breakEven_;
264  }
266  inline void setBreakEven(double value) {
267  breakEven_ = value;
268  }
269 
270 
271 protected:
273 
279  double breakEven_;
284 };
285 #endif
286 
CbcObject::solverBranch
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
CbcBranchingObject::way
int way() const
Get the state of the branching object.
Definition: CbcBranchingObject.hpp:154
CbcBranchingObject::variable
int variable() const
Index identifying the associated CbcObject within its class.
Definition: CbcBranchingObject.hpp:143
CbcSimpleInteger::breakEven_
double breakEven_
Breakeven i.e. >= this preferred is up.
Definition: CbcSimpleInteger.hpp:279
CbcIntegerBranchingObject::fillPart
void fillPart(int variable, int way, double value)
Does part of constructor.
CbcObject::preferredWay
int preferredWay() const
If -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcObject.hpp:245
CbcSimpleInteger::osiObject
OsiSimpleInteger * osiObject() const
Construct an OsiSimpleInteger object.
CbcIntegerBranchingObject::setUpBounds
void setUpBounds(const double bounds[2])
Set lower and upper bounds for up branch.
Definition: CbcSimpleInteger.hpp:105
CbcIntegerBranchingObject::fix
virtual void fix(OsiSolverInterface *solver, double *lower, double *upper, int branchState) const
Update bounds in solver as in 'branch' and update given bounds.
CbcBranchingObject::previousBranch
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child.
Definition: CbcBranchingObject.hpp:121
CbcObject::feasibleRegion
virtual void feasibleRegion()=0
For the variable(s) referenced by the object, look at the current solution and set bounds to match th...
CbcSimpleInteger::originalUpperBound
double originalUpperBound() const
Definition: CbcSimpleInteger.hpp:255
CbcSimpleInteger::breakEven
double breakEven() const
Breakeven e.g 0.7 -> >= 0.7 go up first.
Definition: CbcSimpleInteger.hpp:262
CbcBranchingObject::branch
virtual double branch()=0
Execute the actions required to branch, as specified by the current state of the branching object,...
CbcSimpleInteger::setColumnNumber
void setColumnNumber(int value)
Set column number.
Definition: CbcSimpleInteger.hpp:235
CbcIntegerBranchingObject::up_
double up_[2]
Lower [0] and upper [1] bounds for the up arm (way_ = 1)
Definition: CbcSimpleInteger.hpp:152
CbcIntegerBranchingObject::type
virtual CbcBranchObjType type() const
Return the type (an integer identifier) of this.
Definition: CbcSimpleInteger.hpp:133
CbcSimpleInteger::solverBranch
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
CbcIntegerBranchingObject::downBounds
const double * downBounds() const
Lower and upper bounds for down branch.
Definition: CbcSimpleInteger.hpp:93
CbcSimpleInteger::resetSequenceEtc
virtual void resetSequenceEtc(int numberColumns, const int *originalColumns)
Change column numbers after preprocessing.
CbcIntegerBranchingObject::CbcIntegerBranchingObject
CbcIntegerBranchingObject()
Default constructor.
SimpleIntegerBranchObj
@ SimpleIntegerBranchObj
Definition: CbcBranchingObject.hpp:20
CbcBranchingObject.hpp
CbcSimpleInteger::operator=
CbcSimpleInteger & operator=(const CbcSimpleInteger &rhs)
CbcSimpleInteger::originalLowerBound
double originalLowerBound() const
Original bounds.
Definition: CbcSimpleInteger.hpp:249
CbcIntegerBranchingObject::clone
virtual CbcBranchingObject * clone() const
Clone.
CbcIntegerBranchingObject::upBounds
const double * upBounds() const
Lower and upper bounds for up branch.
Definition: CbcSimpleInteger.hpp:97
CbcSimpleInteger::columnNumber_
int columnNumber_
Column number in model.
Definition: CbcSimpleInteger.hpp:281
CbcSimpleInteger::CbcSimpleInteger
CbcSimpleInteger()
CbcIntegerBranchingObject::CbcIntegerBranchingObject
CbcIntegerBranchingObject(CbcModel *model, int variable, int way, double value)
Create a standard floor/ceiling branch object.
CbcSimpleInteger::feasibleRegion
virtual double feasibleRegion(OsiSolverInterface *solver, const OsiBranchingInformation *info) const
Set bounds to fix the variable at the current (integer) value.
CbcIntegerBranchingObject::branch
virtual double branch()
Sets the bounds for the variable according to the current arm of the branch and advances the object s...
CbcIntegerBranchingObject::~CbcIntegerBranchingObject
virtual ~CbcIntegerBranchingObject()
Destructor.
CbcModel
Simple Branch and bound class.
Definition: CbcModel.hpp:101
CbcIntegerBranchingObject::operator=
CbcIntegerBranchingObject & operator=(const CbcIntegerBranchingObject &rhs)
Assignment operator.
CbcSimpleInteger::setBreakEven
void setBreakEven(double value)
Set breakeven e.g 0.7 -> >= 0.7 go up first.
Definition: CbcSimpleInteger.hpp:266
CbcIntegerBranchingObject::compareBranchingObject
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap=false)
Compare the this with brObj.
CbcSimpleInteger::setOriginalUpperBound
void setOriginalUpperBound(double value)
Definition: CbcSimpleInteger.hpp:258
CbcBranchingObject::print
virtual void print() const
Print something about branch - only if log level high.
Definition: CbcBranchingObject.hpp:130
CbcSimpleInteger::CbcSimpleInteger
CbcSimpleInteger(CbcModel *model, const OsiSimpleInteger *object)
CbcIntegerBranchingObject::CbcIntegerBranchingObject
CbcIntegerBranchingObject(const CbcIntegerBranchingObject &)
Copy constructor.
CbcBranchingObject
Abstract branching object base class Now just difference with OsiBranchingObject.
Definition: CbcBranchingObject.hpp:53
CbcObject
Definition: CbcObject.hpp:67
CbcSimpleInteger::resetBounds
virtual void resetBounds(const OsiSolverInterface *solver)
Reset variable bounds to their original values.
CbcSimpleInteger::CbcSimpleInteger
CbcSimpleInteger(CbcModel *model, int iColumn, double breakEven=0.5)
CbcIntegerBranchingObject::CbcIntegerBranchingObject
CbcIntegerBranchingObject(CbcModel *model, int variable, int way, double lowerValue, double upperValue)
Create a degenerate branch object.
CbcSimpleInteger::columnNumber
virtual int columnNumber() const
Column number if single column object -1 otherwise, so returns >= 0 Used by heuristics.
CbcSimpleInteger::clone
virtual CbcObject * clone() const
Clone.
CbcObject::model
CbcModel * model() const
Return model.
Definition: CbcObject.hpp:240
CbcIntegerBranchingObject
Simple branching object for an integer variable.
Definition: CbcSimpleInteger.hpp:23
CbcRangeCompare
CbcRangeCompare
Definition: CbcBranchBase.hpp:13
CbcIntegerBranchingObject::down_
double down_[2]
Lower [0] and upper [1] bounds for the down arm (way_ = -1)
Definition: CbcSimpleInteger.hpp:150
CbcSimpleInteger::originalUpper_
double originalUpper_
Original upper bound.
Definition: CbcSimpleInteger.hpp:277
CbcIntegerBranchingObject::setDownBounds
void setDownBounds(const double bounds[2])
Set lower and upper bounds for down branch.
Definition: CbcSimpleInteger.hpp:101
CbcSimpleInteger
Define a single integer class.
Definition: CbcSimpleInteger.hpp:167
CbcBranchObjType
CbcBranchObjType
Definition: CbcBranchingObject.hpp:19
CbcSimpleInteger::preferredWay_
int preferredWay_
If -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcSimpleInteger.hpp:283
CbcBranchingObject::model
CbcModel * model() const
Return model.
Definition: CbcBranchingObject.hpp:171
CbcSimpleInteger::~CbcSimpleInteger
virtual ~CbcSimpleInteger()
CbcIntegerBranchingObject::tighten
virtual bool tighten(OsiSolverInterface *)
Change (tighten) bounds in object to reflect bounds in solver.
CbcSimpleInteger::originalLower_
double originalLower_
data
Definition: CbcSimpleInteger.hpp:275
CbcSimpleInteger::fillCreateBranch
void fillCreateBranch(CbcIntegerBranchingObject *branching, const OsiBranchingInformation *info, int way)
Fills in a created branching object.
CbcIntegerBranchingObject::print
virtual void print()
Print something about branch - only if log level high.
CbcSimpleInteger::infeasibility
virtual double infeasibility(const OsiBranchingInformation *info, int &preferredWay) const
Infeasibility - large is 0.5.
CbcSimpleInteger::setOriginalLowerBound
void setOriginalLowerBound(double value)
Definition: CbcSimpleInteger.hpp:252
CbcSimpleInteger::feasibleRegion
virtual void feasibleRegion()
Set bounds to fix the variable at the current (integer) value.
CbcSimpleInteger::CbcSimpleInteger
CbcSimpleInteger(const CbcSimpleInteger &)
CbcSimpleInteger::createCbcBranch
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way)
Create a branching object and indicate which way to branch first.