Cbc  2.10.5
 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 2465 2019-01-03 19:26:52Z unxusr $
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  // Default Constructor
71  CbcObject();
72 
73  // Useful constructor
75 
76  // Copy constructor
77  CbcObject(const CbcObject &);
78 
79  // Assignment operator
80  CbcObject &operator=(const CbcObject &rhs);
81 
83  virtual CbcObject *clone() const = 0;
84 
86  virtual ~CbcObject();
87 
102 #ifdef CBC_NEW_STYLE_BRANCH
103  virtual double infeasibility(const OsiBranchingInformation *info,
104  int &preferredWay) const = 0;
105 #else
106  virtual double infeasibility(const OsiBranchingInformation * /*info*/,
107  int &preferredWay) const
108  {
109  return infeasibility(preferredWay);
110  }
111  virtual double infeasibility(int & /*preferredWay*/) const
112  {
113  throw CoinError("Need code", "infeasibility", "CbcBranchBase");
114  }
115 #endif
116 
120  virtual void feasibleRegion() = 0;
122  virtual double feasibleRegion(OsiSolverInterface *solver, const OsiBranchingInformation *info) const;
123 
128  virtual double feasibleRegion(OsiSolverInterface *solver) const;
129 
135 #ifdef CBC_NEW_STYLE_BRANCH
136  virtual CbcBranchingObject *createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way) = 0;
137 #else
139  /* solver */,
141  /* info */,
142  int /* way */)
143  {
144  // return createBranch(solver, info, way);
145  return NULL;
146  }
148  const OsiBranchingInformation * /*info*/, int /*way*/) const
149  {
150  throw CoinError("Need code", "createBranch", "CbcBranchBase");
151  }
152 #endif
153 
158  virtual OsiBranchingObject *createOsiBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way) const;
163  virtual OsiSolverBranch *solverBranch() const;
164 
174  {
175  return NULL;
176  }
177 
187  {
188  return NULL;
189  }
190 
195  virtual void resetBounds(const OsiSolverInterface *) {}
196 
199  virtual void floorCeiling(double &floorValue, double &ceilingValue, double value,
200  double tolerance) const;
201 
206  const CbcNode *node,
207  const CbcBranchingObject *branchingObject);
208 
210  virtual void updateInformation(const CbcObjectUpdateData &) {}
211 
213  inline int id() const
214  {
215  return id_;
216  }
217 
221  inline void setId(int value)
222  {
223  id_ = value;
224  }
225 
228  inline bool optionalObject() const
229  {
230  return (id_ >= 1000000000 && id_ < 1100000000);
231  }
232 
234  inline int position() const
235  {
236  return position_;
237  }
238 
240  inline void setPosition(int position)
241  {
243  }
244 
246  inline void setModel(CbcModel *model)
247  {
248  model_ = model;
249  }
250 
252  inline CbcModel *model() const
253  {
254  return model_;
255  }
256 
258  inline int preferredWay() const
259  {
260  return preferredWay_;
261  }
263  inline void setPreferredWay(int value)
264  {
265  preferredWay_ = value;
266  }
268  virtual void redoSequenceEtc(CbcModel *, int, const int *) {}
270  virtual void initializeForBranching(CbcModel *) {}
271 
272 protected:
274 
278  int id_;
283 };
284 
285 #endif
286 
287 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
288 */
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:138
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:173
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:270
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:186
void setPosition(int position)
Set position in object_ list.
Definition: CbcObject.hpp:240
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:258
Abstract Base Class for describing an interface to a solver.
int position_
Position in object list.
Definition: CbcObject.hpp:280
virtual double infeasibility(const OsiBranchingInformation *, int &preferredWay) const
Infeasibility of the object.
Definition: CbcObject.hpp:106
void setModel(CbcModel *model)
update model
Definition: CbcObject.hpp:246
void setId(int value)
Set identifier (normally column number in matrix) but 1000000000 to 1100000000 means optional branchi...
Definition: CbcObject.hpp:221
int id_
Identifier (normally column number in matrix)
Definition: CbcObject.hpp:278
double infeasibility() const
Return infeasibility.
int id() const
Identifier (normally column number in matrix)
Definition: CbcObject.hpp:213
int position() const
Get position in object_ list.
Definition: CbcObject.hpp:234
CbcModel * model() const
Return model.
Definition: CbcObject.hpp:252
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:195
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:276
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:282
bool optionalObject() const
Return true if optional branching object i.e.
Definition: CbcObject.hpp:228
int numObjInfeasDown
Definition: CbcObject.hpp:60
void setPreferredWay(int value)
Set -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcObject.hpp:263
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:147
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:100
virtual void updateInformation(const CbcObjectUpdateData &)
Update object by CbcObjectUpdateData.
Definition: CbcObject.hpp:210
virtual void redoSequenceEtc(CbcModel *, int, const int *)
Redoes data when sequence numbers change.
Definition: CbcObject.hpp:268
int numObjInfeasUp
Definition: CbcObject.hpp:56