Cbc  2.10.10
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CbcSimpleInteger.hpp
Go to the documentation of this file.
1 // $Id$
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:
28 
37  int way, double value);
38 
47  double lowerValue, double upperValue);
48 
51 
54 
56  virtual CbcBranchingObject *clone() const;
57 
60 
62  void fillPart(int variable, int way, double value);
68  virtual double branch();
71  virtual void fix(OsiSolverInterface *solver,
72  double *lower, double *upper,
73  int branchState) const;
76  virtual bool tighten(OsiSolverInterface *);
77 
78 #ifdef JJF_ZERO
79  // No need to override. Default works fine.
83  virtual void previousBranch();
84 #endif
85 
89  virtual void print();
90 
92  inline const double *downBounds() const
93  {
94  return down_;
95  }
97  inline const double *upBounds() const
98  {
99  return up_;
100  }
102  inline void setDownBounds(const double bounds[2])
103  {
104  memcpy(down_, bounds, 2 * sizeof(double));
105  }
107  inline void setUpBounds(const double bounds[2])
108  {
109  memcpy(up_, bounds, 2 * sizeof(double));
110  }
111 #ifdef FUNNY_BRANCHING
112 
114  inline const int *variables() const
115  {
116  return variables_;
117  }
118  // New bound
119  inline const double *newBounds() const
120  {
121  return newBounds_;
122  }
124  inline int numberExtraChangedBounds() const
125  {
126  return numberExtraChangedBounds_;
127  }
129  int applyExtraBounds(int iColumn, double lower, double upper, int way);
131  void deactivate();
133  inline bool active() const
134  {
135  return (down_[1] != -COIN_DBL_MAX);
136  }
137 #endif
138 
140  virtual CbcBranchObjType type() const
141  {
142  return SimpleIntegerBranchObj;
143  }
144 
153  virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap = false);
154 
155 protected:
157  double down_[2];
159  double up_[2];
160 #ifdef FUNNY_BRANCHING
161 
163  int *variables_;
164  // New bound
165  double *newBounds_;
167  int numberExtraChangedBounds_;
168 #endif
169 };
170 
172 
173 class CbcSimpleInteger : public CbcObject {
174 
175 public:
176  // Default Constructor
178 
179  // Useful constructor - passed model and index
180  CbcSimpleInteger(CbcModel *model, int iColumn, double breakEven = 0.5);
181 
182  // Useful constructor - passed model and Osi object
183  CbcSimpleInteger(CbcModel *model, const OsiSimpleInteger *object);
184 
185  // Copy constructor
187 
189  virtual CbcObject *clone() const;
190 
191  // Assignment operator
193 
194  // Destructor
195  virtual ~CbcSimpleInteger();
197  OsiSimpleInteger *osiObject() const;
199  virtual double infeasibility(const OsiBranchingInformation *info,
200  int &preferredWay) const;
201 
208  virtual double feasibleRegion(OsiSolverInterface *solver, const OsiBranchingInformation *info) const;
209 
215  virtual CbcBranchingObject *createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way);
217  /*virtual*/ void fillCreateBranch(CbcIntegerBranchingObject *branching, const OsiBranchingInformation *info, int way);
218 
224  virtual OsiSolverBranch *solverBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info) const;
225 
232  virtual void feasibleRegion();
233 
238  virtual int columnNumber() const;
240  inline void setColumnNumber(int value)
241  {
242  columnNumber_ = value;
243  }
244 
249  virtual void resetBounds(const OsiSolverInterface *solver);
250 
253  virtual void resetSequenceEtc(int numberColumns, const int *originalColumns);
255  inline double originalLowerBound() const
256  {
257  return originalLower_;
258  }
259  inline void setOriginalLowerBound(double value)
260  {
261  originalLower_ = value;
262  }
263  inline double originalUpperBound() const
264  {
265  return originalUpper_;
266  }
267  inline void setOriginalUpperBound(double value)
268  {
269  originalUpper_ = value;
270  }
272  inline double breakEven() const
273  {
274  return breakEven_;
275  }
277  inline void setBreakEven(double value)
278  {
279  breakEven_ = value;
280  }
281 
282 protected:
284 
290  double breakEven_;
295 };
296 #endif
297 
298 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
299 */
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:157
CbcBranchingObject::variable
int variable() const
Index identifying the associated CbcObject within its class.
Definition: CbcBranchingObject.hpp:145
CbcSimpleInteger::breakEven_
double breakEven_
Breakeven i.e. >= this preferred is up.
Definition: CbcSimpleInteger.hpp:290
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:258
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:107
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:122
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:263
CbcSimpleInteger::breakEven
double breakEven() const
Breakeven e.g 0.7 -> >= 0.7 go up first.
Definition: CbcSimpleInteger.hpp:272
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:240
CbcIntegerBranchingObject::up_
double up_[2]
Lower [0] and upper [1] bounds for the up arm (way_ = 1)
Definition: CbcSimpleInteger.hpp:159
CbcIntegerBranchingObject::type
virtual CbcBranchObjType type() const
Return the type (an integer identifier) of this.
Definition: CbcSimpleInteger.hpp:140
CbcIntegerBranchingObject::downBounds
const double * downBounds() const
Lower and upper bounds for down branch.
Definition: CbcSimpleInteger.hpp:92
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:18
CbcBranchingObject.hpp
CbcSimpleInteger::operator=
CbcSimpleInteger & operator=(const CbcSimpleInteger &rhs)
CbcSimpleInteger::originalLowerBound
double originalLowerBound() const
Original bounds.
Definition: CbcSimpleInteger.hpp:255
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:292
CbcSimpleInteger::CbcSimpleInteger
CbcSimpleInteger()
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:100
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:277
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:267
CbcBranchingObject::print
virtual void print() const
Print something about branch - only if log level high.
Definition: CbcBranchingObject.hpp:132
CbcBranchingObject
Abstract branching object base class Now just difference with OsiBranchingObject.
Definition: CbcBranchingObject.hpp:51
CbcObject
Definition: CbcObject.hpp:67
CbcSimpleInteger::resetBounds
virtual void resetBounds(const OsiSolverInterface *solver)
Reset variable bounds to their original values.
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:252
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:157
CbcSimpleInteger::originalUpper_
double originalUpper_
Original upper bound.
Definition: CbcSimpleInteger.hpp:288
CbcIntegerBranchingObject::setDownBounds
void setDownBounds(const double bounds[2])
Set lower and upper bounds for down branch.
Definition: CbcSimpleInteger.hpp:102
CbcSimpleInteger
Define a single integer class.
Definition: CbcSimpleInteger.hpp:173
CbcBranchObjType
CbcBranchObjType
Definition: CbcBranchingObject.hpp:17
CbcSimpleInteger::preferredWay_
int preferredWay_
If -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcSimpleInteger.hpp:294
CbcBranchingObject::model
CbcModel * model() const
Return model.
Definition: CbcBranchingObject.hpp:177
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:286
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:259
CbcSimpleInteger::feasibleRegion
virtual void feasibleRegion()
Set bounds to fix the variable at the current (integer) value.
CbcSimpleInteger::createCbcBranch
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way)
Create a branching object and indicate which way to branch first.