Cbc  2.10.10
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CbcNodeInfo.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/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:
77  CbcNodeInfo();
78 
80  CbcNodeInfo(const CbcNodeInfo &);
81 
82 #ifdef JJF_ZERO
83 
89 #endif
90 
96 
102  virtual ~CbcNodeInfo();
104 
110  virtual void applyToModel(CbcModel *model, CoinWarmStartBasis *&basis,
112  int &currentNumberCuts) const = 0;
114  virtual int applyBounds(int iColumn, double &lower, double &upper, int force) = 0;
115 
120  virtual CbcNodeInfo *buildRowBasis(CoinWarmStartBasis &basis) const = 0;
122  virtual CbcNodeInfo *clone() const = 0;
124  virtual void allBranchesGone() {}
125 #ifndef JJF_ONE
126  inline void increment(int amount = 1)
128  {
129  numberPointingToThis_ += amount; /*printf("CbcNodeInfo %x incremented by %d to %d\n",this,amount,numberPointingToThis_);*/
130  }
131 
133  inline int decrement(int amount = 1)
134  {
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  {
151  numberPointingToThis_ = number;
152  numberBranchesLeft_ = number;
153  }
154 
156  inline int numberBranchesLeft() const
157  {
158  return numberBranchesLeft_;
159  }
160 
162  inline void setNumberBranchesLeft(int value)
163  {
164  numberBranchesLeft_ = value;
165  }
166 
168  inline int numberPointingToThis() const
169  {
170  return numberPointingToThis_;
171  }
172 
174  inline void setNumberPointingToThis(int number)
175  {
176  numberPointingToThis_ = number;
177  }
178 
181  {
183  }
184 
186  inline int branchedOn()
187  {
190  return numberBranchesLeft_;
191  }
192 
194  inline void throwAway()
195  {
198  }
199 
202  {
203  return parent_;
204  }
206  inline void nullParent()
207  {
208  parent_ = NULL;
209  }
210 
211  void addCuts(OsiCuts &cuts, int numberToBranch, //int * whichGenerator,
213  void addCuts(int numberCuts, CbcCountRowCut **cuts, int numberToBranch);
217  void deleteCuts(int numberToDelete, CbcCountRowCut **cuts);
218  void deleteCuts(int numberToDelete, int *which);
219 
221  void deleteCut(int whichOne);
222 
224  void decrementCuts(int change = 1);
225 
227  void incrementCuts(int change = 1);
228 
230  void decrementParentCuts(CbcModel *model, int change = 1);
231 
233  void incrementParentCuts(CbcModel *model, int change = 1);
234 
236  inline CbcCountRowCut **cuts() const
237  {
238  return cuts_;
239  }
240 
242  inline int numberCuts() const
243  {
244  return numberCuts_;
245  }
246  inline void setNumberCuts(int value)
247  {
248  numberCuts_ = value;
249  }
250 
252  inline void nullOwner()
253  {
254  owner_ = NULL;
255  }
256  const inline CbcNode *owner() const
257  {
258  return owner_;
259  }
260  inline CbcNode *mutableOwner() const
261  {
262  return owner_;
263  }
265  inline int nodeNumber() const
266  {
267  return nodeNumber_;
268  }
269  inline void setNodeNumber(int node)
270  {
271  nodeNumber_ = node;
272  }
280  void deactivate(int mode = 3);
282  inline bool allActivated() const
283  {
284  return ((active_ & 7) == 7);
285  }
287  inline bool marked() const
288  {
289  return ((active_ & 8) != 0);
290  }
292  inline void mark()
293  {
294  active_ |= 8;
295  }
297  inline void unmark()
298  {
299  active_ &= ~8;
300  }
302  inline bool symmetryWorked() const
303  {
304  return (active_ & 16) != 0;
305  }
307  inline void setSymmetryWorked()
308  {
309  active_ |= 16;
310  }
311 
313  inline const OsiBranchingObject *parentBranch() const
314  {
315  return parentBranch_;
316  }
318  void unsetParentBasedData();
319 
320 protected:
329 
332 
334  OsiBranchingObject *parentBranch_;
335 
338 
341 
344 
347 
351 
364  int active_;
365 
366 private:
368  CbcNodeInfo &operator=(const CbcNodeInfo &rhs);
369 
371  void setParentBasedData();
372 };
373 
374 #endif // CbcNodeInfo_H
375 
376 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
377 */
CbcNodeInfo::cuts_
CbcCountRowCut ** cuts_
Array of pointers to cuts.
Definition: CbcNodeInfo.hpp:346
CbcNodeInfo::nullParent
void nullParent()
Set parent null.
Definition: CbcNodeInfo.hpp:206
CbcNodeInfo::allActivated
bool allActivated() const
Say if normal.
Definition: CbcNodeInfo.hpp:282
CbcNodeInfo::numberPointingToThis
int numberPointingToThis() const
Return number of objects pointing to this.
Definition: CbcNodeInfo.hpp:168
CbcCountRowCut
OsiRowCut augmented with bookkeeping.
Definition: CbcCountRowCut.hpp:34
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:127
CbcNodeInfo::incrementCuts
void incrementCuts(int change=1)
Increment active cut counts.
CbcNodeInfo::parent_
CbcNodeInfo * parent_
parent
Definition: CbcNodeInfo.hpp:331
CbcNodeInfo::setSymmetryWorked
void setSymmetryWorked()
Say symmetry worked at this node)
Definition: CbcNodeInfo.hpp:307
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:162
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:343
CbcNodeInfo::nodeNumber
int nodeNumber() const
The node number.
Definition: CbcNodeInfo.hpp:265
CbcNodeInfo::incrementNumberPointingToThis
void incrementNumberPointingToThis()
Increment number of objects pointing to this.
Definition: CbcNodeInfo.hpp:180
CbcNodeInfo::parent
CbcNodeInfo * parent() const
Parent of this.
Definition: CbcNodeInfo.hpp:201
CbcNodeInfo::~CbcNodeInfo
virtual ~CbcNodeInfo()
Destructor.
CbcNodeInfo::setNumberPointingToThis
void setNumberPointingToThis(int number)
Set number of objects pointing to this.
Definition: CbcNodeInfo.hpp:174
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:358
CbcNodeInfo::numberPointingToThis_
int numberPointingToThis_
Number of other nodes pointing to this node.
Definition: CbcNodeInfo.hpp:328
CbcNodeInfo::setNodeNumber
void setNodeNumber(int node)
Definition: CbcNodeInfo.hpp:269
CbcNodeInfo::cuts
CbcCountRowCut ** cuts() const
Array of pointers to cuts.
Definition: CbcNodeInfo.hpp:236
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:242
CbcNodeInfo::allBranchesGone
virtual void allBranchesGone()
Called when number branches left down to zero.
Definition: CbcNodeInfo.hpp:124
CbcNodeInfo::decrement
int decrement(int amount=1)
Decrement number of references and return number left.
Definition: CbcNodeInfo.hpp:133
CbcNodeInfo::active_
int active_
Active node information.
Definition: CbcNodeInfo.hpp:364
CbcNodeInfo::initializeInfo
void initializeInfo(int number)
Initialize reference counts.
Definition: CbcNodeInfo.hpp:149
CbcNodeInfo::owner
const CbcNode * owner() const
Definition: CbcNodeInfo.hpp:256
CbcModel
Simple Branch and bound class.
Definition: CbcModel.hpp:100
CbcNodeInfo::symmetryWorked
bool symmetryWorked() const
Get symmetry value (true worked at this node)
Definition: CbcNodeInfo.hpp:302
CbcNodeInfo::deleteCut
void deleteCut(int whichOne)
Really delete a cut.
CbcNodeInfo::nullOwner
void nullOwner()
Set owner null.
Definition: CbcNodeInfo.hpp:252
CbcNodeInfo::parentBranch_
OsiBranchingObject * parentBranch_
Copy of the branching object of the parent when the node is created.
Definition: CbcNodeInfo.hpp:334
CbcBranchBase.hpp
CbcNodeInfo::unmark
void unmark()
Unmark.
Definition: CbcNodeInfo.hpp:297
CbcNodeInfo
Information required to recreate the subproblem at this node.
Definition: CbcNodeInfo.hpp:68
CbcNodeInfo::owner_
CbcNode * owner_
Owner.
Definition: CbcNodeInfo.hpp:337
CbcNodeInfo::marked
bool marked() const
Say if marked.
Definition: CbcNodeInfo.hpp:287
CbcNodeInfo::numberCuts_
int numberCuts_
Number of row cuts (this node)
Definition: CbcNodeInfo.hpp:340
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:313
CbcNodeInfo::numberRows_
int numberRows_
Number of rows in problem (before these cuts).
Definition: CbcNodeInfo.hpp:350
CbcNodeInfo::CbcNodeInfo
CbcNodeInfo()
Default Constructor.
CbcNodeInfo::setNumberCuts
void setNumberCuts(int value)
Definition: CbcNodeInfo.hpp:246
CbcNodeInfo::setParentBasedData
void setParentBasedData()
routine common to constructors
CbcNodeInfo::branchedOn
int branchedOn()
Say one branch taken.
Definition: CbcNodeInfo.hpp:186
CbcNodeInfo::clone
virtual CbcNodeInfo * clone() const =0
Clone.
CbcNodeInfo::operator=
CbcNodeInfo & operator=(const CbcNodeInfo &rhs)
Illegal Assignment operator.
CbcNodeInfo::unsetParentBasedData
void unsetParentBasedData()
If we need to take off parent based data.
CbcNodeInfo::mutableOwner
CbcNode * mutableOwner() const
Definition: CbcNodeInfo.hpp:260
CbcNodeInfo::throwAway
void throwAway()
Say thrown away.
Definition: CbcNodeInfo.hpp:194
CbcNodeInfo::numberBranchesLeft
int numberBranchesLeft() const
Return number of branches left in object.
Definition: CbcNodeInfo.hpp:156
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:292