Cbc  2.9.9
CbcNodeInfo.hpp
Go to the documentation of this file.
1 // $Id: CbcNodeInfo.hpp 2048 2014-07-16 09:29:16Z forrest $
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/24/09 carved from CbcNode
7 
8 #ifndef CbcNodeInfo_H
9 #define CbcNodeInfo_H
10 
11 #include <string>
12 #include <vector>
13 
14 #include "CoinWarmStartBasis.hpp"
15 #include "CoinSearchTree.hpp"
16 #include "CbcBranchBase.hpp"
17 
18 class OsiSolverInterface;
19 class OsiSolverBranch;
20 
21 class OsiCuts;
22 class OsiRowCut;
23 class OsiRowCutDebugger;
24 class CoinWarmStartBasis;
25 class CbcCountRowCut;
26 class CbcModel;
27 class CbcNode;
28 class CbcSubProblem;
29 class CbcGeneralBranchingObject;
30 
31 //#############################################################################
68 class CbcNodeInfo {
69 
70 public:
71 
79 
82 
83 #ifdef JJF_ZERO
84 
90 #endif
91 
97 
103  virtual ~CbcNodeInfo();
105 
106 
112  virtual void applyToModel (CbcModel *model, CoinWarmStartBasis *&basis,
114  int &currentNumberCuts) const = 0 ;
116  virtual int applyBounds(int iColumn, double & lower, double & upper, int force) = 0;
117 
122  virtual CbcNodeInfo * buildRowBasis(CoinWarmStartBasis & basis) const = 0;
124  virtual CbcNodeInfo * clone() const = 0;
126  virtual void allBranchesGone() {}
127 #ifndef JJF_ONE
128  inline void increment(int amount = 1) {
130  numberPointingToThis_ += amount;/*printf("CbcNodeInfo %x incremented by %d to %d\n",this,amount,numberPointingToThis_);*/
131  }
132 
134  inline int decrement(int amount = 1) {
135  numberPointingToThis_ -= amount;/*printf("CbcNodeInfo %x decremented by %d to %d\n",this,amount,numberPointingToThis_);*/
136  return numberPointingToThis_;
137  }
138 #else
139  void increment(int amount = 1);
142  int decrement(int amount = 1);
143 #endif
144 
149  inline void initializeInfo(int number) {
150  numberPointingToThis_ = number;
151  numberBranchesLeft_ = number;
152  }
153 
155  inline int numberBranchesLeft() const {
156  return numberBranchesLeft_;
157  }
158 
160  inline void setNumberBranchesLeft(int value) {
161  numberBranchesLeft_ = value;
162  }
163 
165  inline int numberPointingToThis() const {
166  return numberPointingToThis_;
167  }
168 
170  inline void setNumberPointingToThis(int number) {
171  numberPointingToThis_ = number;
172  }
173 
177  }
178 
180  inline int branchedOn() {
183  return numberBranchesLeft_;
184  }
185 
187  inline void throwAway() {
190  }
191 
193  CbcNodeInfo * parent() const {
194  return parent_;
195  }
197  inline void nullParent() {
198  parent_ = NULL;
199  }
200 
201  void addCuts(OsiCuts & cuts, int numberToBranch, //int * whichGenerator,
203  void addCuts(int numberCuts, CbcCountRowCut ** cuts, int numberToBranch);
207  void deleteCuts(int numberToDelete, CbcCountRowCut ** cuts);
208  void deleteCuts(int numberToDelete, int * which);
209 
211  void deleteCut(int whichOne);
212 
214  void decrementCuts(int change = 1);
215 
217  void incrementCuts(int change = 1);
218 
220  void decrementParentCuts(CbcModel * model, int change = 1);
221 
223  void incrementParentCuts(CbcModel * model, int change = 1);
224 
226  inline CbcCountRowCut ** cuts() const {
227  return cuts_;
228  }
229 
231  inline int numberCuts() const {
232  return numberCuts_;
233  }
234  inline void setNumberCuts(int value) {
235  numberCuts_ = value;
236  }
237 
239  inline void nullOwner() {
240  owner_ = NULL;
241  }
242  const inline CbcNode * owner() const {
243  return owner_;
244  }
245  inline CbcNode * mutableOwner() const {
246  return owner_;
247  }
249  inline int nodeNumber() const {
250  return nodeNumber_;
251  }
252  inline void setNodeNumber(int node) {
253  nodeNumber_ = node;
254  }
262  void deactivate(int mode = 3);
264  inline bool allActivated() const {
265  return ((active_&7) == 7);
266  }
268  inline bool marked() const {
269  return ((active_&8) != 0);
270  }
272  inline void mark() {
273  active_ |= 8;
274  }
276  inline void unmark() {
277  active_ &= ~8;
278  }
280  inline bool symmetryWorked() const
281  { return (active_&16) !=0;}
283  inline void setSymmetryWorked()
284  { active_ |= 16;}
285 
287  inline const OsiBranchingObject * parentBranch() const {
288  return parentBranch_;
289  }
292 protected:
293 
302 
305 
307  OsiBranchingObject * parentBranch_;
308 
311 
314 
317 
320 
324 
337  int active_;
338 
339 private:
340 
342  CbcNodeInfo & operator=(const CbcNodeInfo& rhs);
343 
345  void setParentBasedData();
346 };
347 
348 #endif // CbcNodeInfo_H
349 
CbcNodeInfo::cuts_
CbcCountRowCut ** cuts_
Array of pointers to cuts.
Definition: CbcNodeInfo.hpp:319
CbcNodeInfo::nullParent
void nullParent()
Set parent null.
Definition: CbcNodeInfo.hpp:197
CbcNodeInfo::allActivated
bool allActivated() const
Say if normal.
Definition: CbcNodeInfo.hpp:264
CbcNodeInfo::numberPointingToThis
int numberPointingToThis() const
Return number of objects pointing to this.
Definition: CbcNodeInfo.hpp:165
CbcCountRowCut
OsiRowCut augmented with bookkeeping.
Definition: CbcCountRowCut.hpp:35
CbcNodeInfo::applyToModel
virtual void applyToModel(CbcModel *model, CoinWarmStartBasis *&basis, CbcCountRowCut **addCuts, int &currentNumberCuts) const =0
Modify model according to information at node.
CbcNodeInfo::increment
void increment(int amount=1)
Increment number of references.
Definition: CbcNodeInfo.hpp:129
CbcNodeInfo::incrementCuts
void incrementCuts(int change=1)
Increment active cut counts.
CbcNodeInfo::parent_
CbcNodeInfo * parent_
parent
Definition: CbcNodeInfo.hpp:304
CbcNodeInfo::CbcNodeInfo
CbcNodeInfo(const CbcNodeInfo &)
Copy constructor.
CbcNodeInfo::setSymmetryWorked
void setSymmetryWorked()
Say symmetry worked at this node)
Definition: CbcNodeInfo.hpp:283
CbcNodeInfo::deactivate
void deactivate(int mode=3)
Deactivate node information.
CbcNodeInfo::setNumberBranchesLeft
void setNumberBranchesLeft(int value)
Set number of branches left in object.
Definition: CbcNodeInfo.hpp:160
CbcNodeInfo::addCuts
void addCuts(int numberCuts, CbcCountRowCut **cuts, int numberToBranch)
CbcNodeInfo::deleteCuts
void deleteCuts(int numberToDelete, CbcCountRowCut **cuts)
Delete cuts (decrements counts) Slow unless cuts in same order as saved.
CbcNodeInfo::nodeNumber_
int nodeNumber_
The node number.
Definition: CbcNodeInfo.hpp:316
CbcNodeInfo::nodeNumber
int nodeNumber() const
The node number.
Definition: CbcNodeInfo.hpp:249
CbcNodeInfo::incrementNumberPointingToThis
void incrementNumberPointingToThis()
Increment number of objects pointing to this.
Definition: CbcNodeInfo.hpp:175
CbcNodeInfo::parent
CbcNodeInfo * parent() const
Parent of this.
Definition: CbcNodeInfo.hpp:193
CbcNodeInfo::~CbcNodeInfo
virtual ~CbcNodeInfo()
Destructor.
CbcNodeInfo::setNumberPointingToThis
void setNumberPointingToThis(int number)
Set number of objects pointing to this.
Definition: CbcNodeInfo.hpp:170
CbcNodeInfo::decrementParentCuts
void decrementParentCuts(CbcModel *model, int change=1)
Decrement all active cut counts in chain starting at parent.
CbcNodeInfo::decrementCuts
void decrementCuts(int change=1)
Decrement active cut counts.
CbcNodeInfo::numberBranchesLeft_
int numberBranchesLeft_
Number of branch arms left to explore at this node.
Definition: CbcNodeInfo.hpp:331
CbcNodeInfo::deleteCuts
void deleteCuts(int numberToDelete, int *which)
CbcNodeInfo::numberPointingToThis_
int numberPointingToThis_
Number of other nodes pointing to this node.
Definition: CbcNodeInfo.hpp:301
CbcNodeInfo::setNodeNumber
void setNodeNumber(int node)
Definition: CbcNodeInfo.hpp:252
CbcNodeInfo::cuts
CbcCountRowCut ** cuts() const
Array of pointers to cuts.
Definition: CbcNodeInfo.hpp:226
CbcNodeInfo::buildRowBasis
virtual CbcNodeInfo * buildRowBasis(CoinWarmStartBasis &basis) const =0
Builds up row basis backwards (until original model).
CbcNodeInfo::numberCuts
int numberCuts() const
Number of row cuts (this node)
Definition: CbcNodeInfo.hpp:231
CbcNodeInfo::allBranchesGone
virtual void allBranchesGone()
Called when number branches left down to zero.
Definition: CbcNodeInfo.hpp:126
CbcNodeInfo::decrement
int decrement(int amount=1)
Decrement number of references and return number left.
Definition: CbcNodeInfo.hpp:134
CbcNodeInfo::active_
int active_
Active node information.
Definition: CbcNodeInfo.hpp:337
CbcNodeInfo::initializeInfo
void initializeInfo(int number)
Initialize reference counts.
Definition: CbcNodeInfo.hpp:149
CbcNodeInfo::owner
const CbcNode * owner() const
Definition: CbcNodeInfo.hpp:242
CbcModel
Simple Branch and bound class.
Definition: CbcModel.hpp:101
CbcNodeInfo::symmetryWorked
bool symmetryWorked() const
Get symmetry value (true worked at this node)
Definition: CbcNodeInfo.hpp:280
CbcNodeInfo::deleteCut
void deleteCut(int whichOne)
Really delete a cut.
CbcNodeInfo::nullOwner
void nullOwner()
Set owner null.
Definition: CbcNodeInfo.hpp:239
CbcNodeInfo::parentBranch_
OsiBranchingObject * parentBranch_
Copy of the branching object of the parent when the node is created.
Definition: CbcNodeInfo.hpp:307
CbcBranchBase.hpp
CbcNodeInfo::unmark
void unmark()
Unmark.
Definition: CbcNodeInfo.hpp:276
CbcNodeInfo
Information required to recreate the subproblem at this node.
Definition: CbcNodeInfo.hpp:68
CbcNodeInfo::owner_
CbcNode * owner_
Owner.
Definition: CbcNodeInfo.hpp:310
CbcNodeInfo::marked
bool marked() const
Say if marked.
Definition: CbcNodeInfo.hpp:268
CbcNodeInfo::numberCuts_
int numberCuts_
Number of row cuts (this node)
Definition: CbcNodeInfo.hpp:313
CbcNodeInfo::CbcNodeInfo
CbcNodeInfo(CbcNodeInfo *parent, CbcNode *owner)
Construct with parent and owner.
CbcNode
Information required while the node is live.
Definition: CbcNode.hpp:49
CbcNodeInfo::parentBranch
const OsiBranchingObject * parentBranch() const
Branching object for the parent.
Definition: CbcNodeInfo.hpp:287
CbcNodeInfo::numberRows_
int numberRows_
Number of rows in problem (before these cuts).
Definition: CbcNodeInfo.hpp:323
CbcNodeInfo::CbcNodeInfo
CbcNodeInfo()
Default Constructor.
CbcNodeInfo::setNumberCuts
void setNumberCuts(int value)
Definition: CbcNodeInfo.hpp:234
CbcNodeInfo::branchedOn
int branchedOn()
Say one branch taken.
Definition: CbcNodeInfo.hpp:180
CbcNodeInfo::clone
virtual CbcNodeInfo * clone() const =0
Clone.
CbcNodeInfo::unsetParentBasedData
void unsetParentBasedData()
If we need to take off parent based data.
CbcNodeInfo::mutableOwner
CbcNode * mutableOwner() const
Definition: CbcNodeInfo.hpp:245
CbcNodeInfo::throwAway
void throwAway()
Say thrown away.
Definition: CbcNodeInfo.hpp:187
CbcNodeInfo::numberBranchesLeft
int numberBranchesLeft() const
Return number of branches left in object.
Definition: CbcNodeInfo.hpp:155
CbcNodeInfo::addCuts
void addCuts(OsiCuts &cuts, int numberToBranch, int numberPointingToThis)
CbcNodeInfo::incrementParentCuts
void incrementParentCuts(CbcModel *model, int change=1)
Increment all active cut counts in parent chain.
CbcNodeInfo::applyBounds
virtual int applyBounds(int iColumn, double &lower, double &upper, int force)=0
Just apply bounds to one variable - force means overwrite by lower,upper (1=>infeasible)
CbcNodeInfo::mark
void mark()
Mark.
Definition: CbcNodeInfo.hpp:272