CbcObject.hpp
Go to the documentation of this file.
1 // Edwin 11/12/2009 carved from CbcBranchBase
2 #ifndef CbcObject_H
3 #define CbcObject_H
4 
5 #include <string>
6 #include <vector>
7 #include "OsiBranchingObject.hpp"
8 class OsiSolverInterface;
9 class OsiSolverBranch;
10 
11 class CbcModel;
12 class CbcNode;
13 class CbcNodeInfo;
14 class CbcBranchingObject;
15 class OsiChooseVariable;
17 //#############################################################################
18 
44 // This can be used if object wants to skip strong branching
45 typedef struct {
46  CbcBranchingObject * possibleBranch; // what a branch would do
47  double upMovement; // cost going up (and initial away from feasible)
48  double downMovement; // cost going down
49  int numIntInfeasUp ; // without odd ones
50  int numObjInfeasUp ; // just odd ones
51  bool finishedUp; // true if solver finished
52  int numItersUp ; // number of iterations in solver
53  int numIntInfeasDown ; // without odd ones
54  int numObjInfeasDown ; // just odd ones
55  bool finishedDown; // true if solver finished
56  int numItersDown; // number of iterations in solver
57  int objectNumber; // Which object it is
58  int fix; // 0 if no fix, 1 if we can fix up, -1 if we can fix down
60 
61 class CbcObject : public OsiObject {
62 
63 public:
64 
65  // Default Constructor
66  CbcObject ();
67 
68  // Useful constructor
70 
71  // Copy constructor
72  CbcObject ( const CbcObject &);
73 
74  // Assignment operator
75  CbcObject & operator=( const CbcObject& rhs);
76 
78  virtual CbcObject * clone() const = 0;
79 
81  virtual ~CbcObject ();
82 
97 #ifdef CBC_NEW_STYLE_BRANCH
98  virtual double infeasibility(const OsiBranchingInformation * info,
99  int &preferredWay) const = 0;
100 #else
101  virtual double infeasibility(const OsiBranchingInformation * /*info*/,
102  int &preferredWay) const {
103  return infeasibility(preferredWay);
104  }
105  virtual double infeasibility(int &/*preferredWay*/) const {
106  throw CoinError("Need code", "infeasibility", "CbcBranchBase");
107  }
108 #endif
109 
113  virtual void feasibleRegion() = 0;
115  virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
116 
121  virtual double feasibleRegion(OsiSolverInterface * solver) const ;
122 
128 #ifdef CBC_NEW_STYLE_BRANCH
129  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) = 0;
130 #else
131  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) {
132  return createBranch(solver, info, way);
133  }
134  virtual CbcBranchingObject * createBranch(OsiSolverInterface * /*solver*/,
135  const OsiBranchingInformation * /*info*/, int /*way*/) {
136  throw CoinError("Need code", "createBranch", "CbcBranchBase");
137  }
138 #endif
139 
144  virtual OsiBranchingObject * createOsiBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) const;
149  virtual OsiSolverBranch * solverBranch() const;
150 
160  return NULL;
161  }
162 
172  return NULL;
173  }
174 
179  virtual void resetBounds(const OsiSolverInterface * ) {}
180 
183  virtual void floorCeiling(double & floorValue, double & ceilingValue, double value,
184  double tolerance) const;
185 
189  virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface * solver,
190  const CbcNode * node,
191  const CbcBranchingObject * branchingObject);
192 
194  virtual void updateInformation(const CbcObjectUpdateData & ) {}
195 
197  inline int id() const {
198  return id_;
199  }
200 
204  inline void setId(int value) {
205  id_ = value;
206  }
207 
210  inline bool optionalObject() const {
211  return (id_ >= 1000000000 && id_ < 1100000000);
212  }
213 
215  inline int position() const {
216  return position_;
217  }
218 
220  inline void setPosition(int position) {
222  }
223 
225  inline void setModel(CbcModel * model) {
226  model_ = model;
227  }
228 
230  inline CbcModel * model() const {
231  return model_;
232  }
233 
235  inline int preferredWay() const {
236  return preferredWay_;
237  }
239  inline void setPreferredWay(int value) {
240  preferredWay_ = value;
241  }
243  virtual void redoSequenceEtc(CbcModel * , int , const int * ) {}
244 
245 protected:
247 
251  int id_;
256 
257 };
258 
259 #endif
260