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 
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 
268  double originalLower_;
270  double originalUpper_;
272  double breakEven_;
274  int columnNumber_;
276  int preferredWay_;
277 };
278 #endif
279