Cbc 2.10.5
Loading...
Searching...
No Matches
CbcBranchingObject.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 CbcBranchingObject_H
9#define CbcBranchingObject_H
10
11#include <string>
12#include <vector>
13#include "CbcBranchBase.hpp"
14#include "OsiBranchingObject.hpp"
15
16// The types of objects that will be derived from this class.
31};
32
51class CbcBranchingObject : public OsiBranchingObject {
52
53public:
56
58 CbcBranchingObject(CbcModel *model, int variable, int way, double value);
59
62
65
67 virtual CbcBranchingObject *clone() const = 0;
68
71
77 {
78 return 0;
79 }
82 {
83 branchIndex_ = 0;
84 }
86 inline void setNumberBranches(int value)
87 {
88 branchIndex_ = 0;
89 numberBranches_ = value;
90 }
91
98 virtual double branch() = 0;
105 virtual double branch(OsiSolverInterface *)
106 {
107 return branch();
108 }
111 virtual void fix(OsiSolverInterface *,
112 double *, double *,
113 int) const {}
114
117 virtual bool tighten(OsiSolverInterface *) { return false; }
118
122 virtual void previousBranch()
123 {
124 assert(branchIndex_ > 0);
125 branchIndex_--;
126 way_ = -way_;
127 }
128
129 using OsiBranchingObject::print;
132 virtual void print() const {}
133
145 inline int variable() const
146 {
147 return variable_;
148 }
149
157 inline int way() const
158 {
159 return way_;
160 }
161
166 inline void way(int way)
167 {
168 way_ = way;
169 }
170
172 inline void setModel(CbcModel *model)
173 {
174 model_ = model;
175 }
177 inline CbcModel *model() const
178 {
179 return model_;
180 }
181
183 inline CbcObject *object() const
184 {
185 return originalCbcObject_;
186 }
188 inline void setOriginalObject(CbcObject *object)
189 {
191 }
192
193 // Methods used in heuristics
194
199 virtual CbcBranchObjType type() const = 0;
200
208 virtual int compareOriginalObject(const CbcBranchingObject *brObj) const
209 {
210 const CbcBranchingObject *br = dynamic_cast< const CbcBranchingObject * >(brObj);
211 return variable() - br->variable();
212 }
213
222 virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap = false) = 0;
223
224protected:
229
232 // was - Way to branch - -1 down (first), 1 up, -2 down (second), 2 up (second)
240 int way_;
241};
242#endif
243
244/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
245*/
CbcRangeCompare
CbcBranchObjType
@ DynamicPseudoCostBranchObj
@ CliqueBranchObj
@ GeneralDepthBranchObj
@ CutBranchingObj
@ NWayBranchObj
@ SimpleIntegerDynamicPseudoCostBranchObj
@ FollowOnBranchObj
@ SoSBranchObj
@ DummyBranchObj
@ LongCliqueBranchObj
@ LotsizeBranchObj
@ OneGeneralBranchingObj
@ SimpleIntegerBranchObj
Abstract branching object base class Now just difference with OsiBranchingObject.
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child.
void resetNumberBranchesLeft()
Reset number of branches left to original.
int variable_
Branching variable (0 is first integer)
int way_
The state of the branching object.
virtual CbcBranchObjType type() const =0
Return the type (an integer identifier) of this.
CbcObject * originalCbcObject_
Pointer back to object which created.
CbcObject * object() const
Return pointer back to object which created.
void setNumberBranches(int value)
Set number of branches to do.
CbcBranchingObject(CbcModel *model, int variable, int way, double value)
Constructor.
CbcBranchingObject & operator=(const CbcBranchingObject &rhs)
Assignment operator.
virtual CbcBranchingObject * clone() const =0
Clone.
virtual bool tighten(OsiSolverInterface *)
Change (tighten) bounds in object to reflect bounds in solver.
virtual int fillStrongInfo(CbcStrongInfo &)
Some branchingObjects may claim to be able to skip strong branching.
CbcBranchingObject()
Default Constructor.
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap=false)=0
Compare the this with brObj.
CbcModel * model_
The model that owns this branching object.
void way(int way)
Set the state of the branching object.
virtual int compareOriginalObject(const CbcBranchingObject *brObj) const
Compare the original object of this with the original object of brObj.
virtual double branch()=0
Execute the actions required to branch, as specified by the current state of the branching object,...
virtual double branch(OsiSolverInterface *)
Execute the actions required to branch, as specified by the current state of the branching object,...
virtual void fix(OsiSolverInterface *, double *, double *, int) const
Update bounds in solver as in 'branch' and update given bounds.
CbcModel * model() const
Return model.
void setOriginalObject(CbcObject *object)
Set pointer back to object which created.
int variable() const
Index identifying the associated CbcObject within its class.
int way() const
Get the state of the branching object.
virtual void print() const
Print something about branch - only if log level high.
void setModel(CbcModel *model)
update model
CbcBranchingObject(const CbcBranchingObject &)
Copy constructor.
virtual ~CbcBranchingObject()
Destructor.
Simple Branch and bound class.
Definition: CbcModel.hpp:100
Abstract base class for ‘objects’.
Definition: CbcObject.hpp:51