Cbc 2.10.11
Loading...
Searching...
No Matches
CbcObject.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/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"
14class OsiSolverInterface;
15class OsiSolverBranch;
16
17class CbcModel;
18class CbcNode;
19class CbcNodeInfo;
21class OsiChooseVariable;
23//#############################################################################
24
50// This can be used if object wants to skip strong branching
51typedef 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
67class CbcObject : public OsiObject {
68
69public:
70 // Default Constructor
72
73 // Useful constructor
75
76 // Copy constructor
78
79 // Assignment operator
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 {
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
138 virtual CbcBranchingObject *createCbcBranch(OsiSolverInterface *
139 /* solver */,
140 const OsiBranchingInformation *
141 /* info */,
142 int /* way */)
143 {
144 // return createBranch(solver, info, way);
145 return NULL;
146 }
147 virtual OsiBranchingObject *createBranch(OsiSolverInterface * /*solver*/,
148 const OsiBranchingInformation * /*info*/, int /*way*/) const
149 {
150 throw CoinError("Need code", "createBranch", "CbcBranchBase");
151 }
152#endif
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
205 virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface *solver,
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 *) {}
271
272protected:
274
278 int id_;
283};
284
285#endif
286
287/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
288*/
Abstract branching object base class Now just difference with OsiBranchingObject.
Simple Branch and bound class.
Definition CbcModel.hpp:100
Information required to recreate the subproblem at this node.
Information required while the node is live.
Definition CbcNode.hpp:49
virtual void resetBounds(const OsiSolverInterface *)
Reset variable bounds to their original values.
void setId(int value)
Set identifier (normally column number in matrix) but 1000000000 to 1100000000 means optional branchi...
virtual void redoSequenceEtc(CbcModel *, int, const int *)
Redoes data when sequence numbers change.
virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface *solver, const CbcNode *node, const CbcBranchingObject *branchingObject)
Pass in information on branch just done and create CbcObjectUpdateData instance.
void setPosition(int position)
Set position in object_ list.
CbcModel * model_
data
virtual CbcBranchingObject * notPreferredNewFeasible() const
Given a valid solution (with reduced costs, etc.), return a branching object which would give a new f...
int position() const
Get position in object_ list.
virtual OsiBranchingObject * createBranch(OsiSolverInterface *, const OsiBranchingInformation *, int) const
void setModel(CbcModel *model)
update model
virtual void initializeForBranching(CbcModel *)
Initialize for branching.
virtual OsiBranchingObject * createOsiBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way) const
Create an Osibranching object and indicate which way to branch first.
virtual double feasibleRegion(OsiSolverInterface *solver) const
For the variable(s) referenced by the object, look at the current solution and set bounds to match th...
void setPreferredWay(int value)
Set -1 down always chosen first, +1 up always, 0 normal.
CbcObject & operator=(const CbcObject &rhs)
virtual CbcObject * clone() const =0
Clone.
virtual double feasibleRegion(OsiSolverInterface *solver, const OsiBranchingInformation *info) const
Dummy one for compatibility.
int position_
Position in object list.
virtual void feasibleRegion()=0
For the variable(s) referenced by the object, look at the current solution and set bounds to match th...
int id() const
Identifier (normally column number in matrix)
int id_
Identifier (normally column number in matrix)
CbcObject(const CbcObject &)
CbcModel * model() const
Return model.
virtual ~CbcObject()
Destructor.
int preferredWay() const
If -1 down always chosen first, +1 up always, 0 normal.
virtual double infeasibility(const OsiBranchingInformation *, int &preferredWay) const
Infeasibility of the object.
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...
CbcObject(CbcModel *model)
virtual double infeasibility(int &) const
int preferredWay_
If -1 down always chosen first, +1 up always, 0 normal.
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
bool optionalObject() const
Return true if optional branching object i.e.
virtual void updateInformation(const CbcObjectUpdateData &)
Update object by CbcObjectUpdateData.
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *, const OsiBranchingInformation *, int)
Create a branching object and indicate which way to branch first.
Abstract base class for ‘objects’.
Definition CbcObject.hpp:51
double upMovement
Definition CbcObject.hpp:53
CbcBranchingObject * possibleBranch
Definition CbcObject.hpp:52
double downMovement
Definition CbcObject.hpp:54