Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbcObject.hpp
Go to the documentation of this file.
1 // $Id: CbcObject.hpp 1899 2013-04-09 18:12:08Z stefan $
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/12/2009 carved from CbcBranchBase
7 
8 #ifndef CbcObject_H
9 #define CbcObject_H
10 
11 #include <string>
12 #include <vector>
13 #include "OsiBranchingObject.hpp"
14 class OsiSolverInterface;
15 class OsiSolverBranch;
16 
17 class CbcModel;
18 class CbcNode;
19 class CbcNodeInfo;
20 class CbcBranchingObject;
21 class OsiChooseVariable;
23 //#############################################################################
24 
50 // This can be used if object wants to skip strong branching
51 typedef struct {
52  CbcBranchingObject * possibleBranch; // what a branch would do
53  double upMovement; // cost going up (and initial away from feasible)
54  double downMovement; // cost going down
55  int numIntInfeasUp ; // without odd ones
56  int numObjInfeasUp ; // just odd ones
57  bool finishedUp; // true if solver finished
58  int numItersUp ; // number of iterations in solver
59  int numIntInfeasDown ; // without odd ones
60  int numObjInfeasDown ; // just odd ones
61  bool finishedDown; // true if solver finished
62  int numItersDown; // number of iterations in solver
63  int objectNumber; // Which object it is
64  int fix; // 0 if no fix, 1 if we can fix up, -1 if we can fix down
66 
67 class CbcObject : public OsiObject {
68 
69 public:
70 
71  // Default Constructor
72  CbcObject ();
73 
74  // Useful constructor
76 
77  // Copy constructor
78  CbcObject ( const CbcObject &);
79 
80  // Assignment operator
81  CbcObject & operator=( const CbcObject& rhs);
82 
84  virtual CbcObject * clone() const = 0;
85 
87  virtual ~CbcObject ();
88 
103 #ifdef CBC_NEW_STYLE_BRANCH
104  virtual double infeasibility(const OsiBranchingInformation * info,
105  int &preferredWay) const = 0;
106 #else
107  virtual double infeasibility(const OsiBranchingInformation * /*info*/,
108  int &preferredWay) const {
109  return infeasibility(preferredWay);
110  }
111  virtual double infeasibility(int &/*preferredWay*/) const {
112  throw CoinError("Need code", "infeasibility", "CbcBranchBase");
113  }
114 #endif
115 
119  virtual void feasibleRegion() = 0;
121  virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
122 
127  virtual double feasibleRegion(OsiSolverInterface * solver) const ;
128 
134 #ifdef CBC_NEW_STYLE_BRANCH
135  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) = 0;
136 #else
138  /* solver */,
140  /* info */, int /* way */) {
141  // return createBranch(solver, info, way);
142  return NULL;
143  }
145  const OsiBranchingInformation * /*info*/, int /*way*/) const {
146  throw CoinError("Need code", "createBranch", "CbcBranchBase");
147  }
148 #endif
149 
154  virtual OsiBranchingObject * createOsiBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) const;
159  virtual OsiSolverBranch * solverBranch() const;
160 
170  return NULL;
171  }
172 
182  return NULL;
183  }
184 
189  virtual void resetBounds(const OsiSolverInterface * ) {}
190 
193  virtual void floorCeiling(double & floorValue, double & ceilingValue, double value,
194  double tolerance) const;
195 
200  const CbcNode * node,
201  const CbcBranchingObject * branchingObject);
202 
204  virtual void updateInformation(const CbcObjectUpdateData & ) {}
205 
207  inline int id() const {
208  return id_;
209  }
210 
214  inline void setId(int value) {
215  id_ = value;
216  }
217 
220  inline bool optionalObject() const {
221  return (id_ >= 1000000000 && id_ < 1100000000);
222  }
223 
225  inline int position() const {
226  return position_;
227  }
228 
230  inline void setPosition(int position) {
232  }
233 
235  inline void setModel(CbcModel * model) {
236  model_ = model;
237  }
238 
240  inline CbcModel * model() const {
241  return model_;
242  }
243 
245  inline int preferredWay() const {
246  return preferredWay_;
247  }
249  inline void setPreferredWay(int value) {
250  preferredWay_ = value;
251  }
253  virtual void redoSequenceEtc(CbcModel * , int , const int * ) {}
255  virtual void initializeForBranching(CbcModel * ) {}
256 
257 protected:
259 
263  int id_;
268 
269 };
270 
271 #endif
272 
Error Class thrown by an exception.
Definition: CoinError.hpp:42
double downMovement
Definition: CbcObject.hpp:54
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *, const OsiBranchingInformation *, int)
Create a branching object and indicate which way to branch first.
Definition: CbcObject.hpp:137
virtual void floorCeiling(double &floorValue, double &ceilingValue, double value, double tolerance) const
Returns floor and ceiling i.e.
virtual CbcBranchingObject * preferredNewFeasible() const
Given a valid solution (with reduced costs, etc.), return a branching object which would give a new f...
Definition: CbcObject.hpp:169
CbcBranchingObject * possibleBranch
Definition: CbcObject.hpp:52
virtual void feasibleRegion()=0
For the variable(s) referenced by the object, look at the current solution and set bounds to match th...
double upMovement
Definition: CbcObject.hpp:53
Abstract base class for `objects&#39;.
Definition: CbcObject.hpp:51
virtual void initializeForBranching(CbcModel *)
Initialize for branching.
Definition: CbcObject.hpp:255
int numIntInfeasUp
Definition: CbcObject.hpp:55
Abstract branching object base class.
int numIntInfeasDown
Definition: CbcObject.hpp:59
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
virtual CbcBranchingObject * notPreferredNewFeasible() const
Given a valid solution (with reduced costs, etc.), return a branching object which would give a new f...
Definition: CbcObject.hpp:181
void setPosition(int position)
Set position in object_ list.
Definition: CbcObject.hpp:230
virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface *solver, const CbcNode *node, const CbcBranchingObject *branchingObject)
Pass in information on branch just done and create CbcObjectUpdateData instance.
int preferredWay() const
If -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcObject.hpp:245
Abstract Base Class for describing an interface to a solver.
int position_
Position in object list.
Definition: CbcObject.hpp:265
virtual double infeasibility(const OsiBranchingInformation *, int &preferredWay) const
Infeasibility of the object.
Definition: CbcObject.hpp:107
void setModel(CbcModel *model)
update model
Definition: CbcObject.hpp:235
void setId(int value)
Set identifier (normally column number in matrix) but 1000000000 to 1100000000 means optional branchi...
Definition: CbcObject.hpp:214
int id_
Identifier (normally column number in matrix)
Definition: CbcObject.hpp:263
double infeasibility() const
Return infeasibility.
int id() const
Identifier (normally column number in matrix)
Definition: CbcObject.hpp:207
int position() const
Get position in object_ list.
Definition: CbcObject.hpp:225
CbcModel * model() const
Return model.
Definition: CbcObject.hpp:240
virtual CbcObject * clone() const =0
Clone.
Abstract branching object base class Now just difference with OsiBranchingObject. ...
virtual void resetBounds(const OsiSolverInterface *)
Reset variable bounds to their original values.
Definition: CbcObject.hpp:189
Information required while the node is live.
Definition: CbcNode.hpp:49
virtual double infeasibility(int &) const
Definition: CbcObject.hpp:111
CbcModel * model_
data
Definition: CbcObject.hpp:261
Information required to recreate the subproblem at this node.
Definition: CbcNodeInfo.hpp:68
virtual ~CbcObject()
Destructor.
CbcObject & operator=(const CbcObject &rhs)
int preferredWay_
If -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcObject.hpp:267
bool optionalObject() const
Return true if optional branching object i.e.
Definition: CbcObject.hpp:220
int numObjInfeasDown
Definition: CbcObject.hpp:60
void setPreferredWay(int value)
Set -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcObject.hpp:249
This class chooses a variable to branch on.
bool finishedDown
Definition: CbcObject.hpp:61
virtual OsiBranchingObject * createBranch(OsiSolverInterface *, const OsiBranchingInformation *, int) const
Create a branching object and indicate which way to branch first.
Definition: CbcObject.hpp:144
Solver Branch Class.
virtual OsiBranchingObject * createOsiBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way) const
Create an Osibranching object and indicate which way to branch first.
Abstract base class for `objects&#39;.
Simple Branch and bound class.
Definition: CbcModel.hpp:101
virtual void updateInformation(const CbcObjectUpdateData &)
Update object by CbcObjectUpdateData.
Definition: CbcObject.hpp:204
virtual void redoSequenceEtc(CbcModel *, int, const int *)
Redoes data when sequence numbers change.
Definition: CbcObject.hpp:253
int numObjInfeasUp
Definition: CbcObject.hpp:56