Cbc  2.9.9
CbcNode.hpp
Go to the documentation of this file.
1 /* $Id: CbcNode.hpp 1957 2013-08-27 15:19:55Z 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 #ifndef CbcNode_H
7 #define CbcNode_H
8 
9 #include <string>
10 #include <vector>
11 
12 #include "CoinWarmStartBasis.hpp"
13 #include "CoinSearchTree.hpp"
14 #include "CbcBranchBase.hpp"
15 #include "CbcNodeInfo.hpp"
16 #include "CbcFullNodeInfo.hpp"
17 #include "CbcPartialNodeInfo.hpp"
18 
19 class OsiSolverInterface;
20 class OsiSolverBranch;
21 
22 class OsiCuts;
23 class OsiRowCut;
24 class OsiRowCutDebugger;
25 class CoinWarmStartBasis;
26 class CbcCountRowCut;
27 class CbcModel;
28 class CbcNode;
29 class CbcSubProblem;
30 class CbcGeneralBranchingObject;
31 
49 class CbcNode : public CoinTreeNode {
50 
51 public:
52 
54  CbcNode ();
55 
57  CbcNode (CbcModel * model, CbcNode * lastNode);
58 
60  CbcNode (const CbcNode &);
61 
63  CbcNode & operator= (const CbcNode& rhs);
64 
67 
83  void
85  CbcNode * lastNode,
86  const CoinWarmStartBasis *lastws,
87  const double * lastLower, const double * lastUpper,
88  int numberOldActiveCuts, int numberNewCuts);
89 
110  int chooseBranch (CbcModel * model,
111  CbcNode * lastNode,
112  int numberPassesLeft);
139  CbcNode * lastNode,
140  OsiSolverBranch * & branches,
141  int numberPassesLeft);
168  int chooseOsiBranch (CbcModel * model,
169  CbcNode * lastNode,
170  OsiBranchingInformation * usefulInfo,
171  int branchState);
187  int chooseClpBranch (CbcModel * model,
188  CbcNode * lastNode);
189  int analyze(CbcModel * model, double * results);
191  void decrementCuts(int change = 1);
192 
194  void decrementParentCuts(CbcModel * model, int change = 1);
195 
197  void nullNodeInfo();
207 
209  int branch(OsiSolverInterface * solver);
210 
214  double checkIsCutoff(double cutoff);
215  // Information to make basis and bounds
216  inline CbcNodeInfo * nodeInfo() const {
217  return nodeInfo_;
218  }
219 
220  // Objective value
221  inline double objectiveValue() const {
222  return objectiveValue_;
223  }
224  inline void setObjectiveValue(double value) {
225  objectiveValue_ = value;
226  }
228  inline int numberBranches() const {
229  if (branch_)
230  return (branch_->numberBranches()) ;
231  else
232  return (-1) ;
233  }
234 
235  /* Active arm of the attached OsiBranchingObject.
236 
237  In the simplest instance, coded -1 for the down arm of the branch, +1 for
238  the up arm. But see OsiBranchingObject::way()
239  Use nodeInfo--.numberBranchesLeft_ to see how active
240  */
241  int way() const;
243  inline int depth() const {
244  return depth_;
245  }
247  inline void setDepth(int value) {
248  depth_ = value;
249  }
251  inline int numberUnsatisfied() const {
252  return numberUnsatisfied_;
253  }
255  inline void setNumberUnsatisfied(int value) {
256  numberUnsatisfied_ = value;
257  }
259  inline double sumInfeasibilities() const {
260  return sumInfeasibilities_;
261  }
263  inline void setSumInfeasibilities(double value) {
264  sumInfeasibilities_ = value;
265  }
266  // Guessed objective value (for solution)
267  inline double guessedObjectiveValue() const {
268  return guessedObjectiveValue_;
269  }
270  inline void setGuessedObjectiveValue(double value) {
271  guessedObjectiveValue_ = value;
272  }
274  inline const OsiBranchingObject * branchingObject() const {
275  return branch_;
276  }
278  inline OsiBranchingObject * modifiableBranchingObject() const {
279  return branch_;
280  }
282  inline void setBranchingObject(OsiBranchingObject * branchingObject) {
283  branch_ = branchingObject;
284  }
286  inline int nodeNumber() const {
287  return nodeNumber_;
288  }
289  inline void setNodeNumber(int node) {
290  nodeNumber_ = node;
291  }
293  inline bool onTree() const {
294  return (state_&1) != 0;
295  }
297  inline void setOnTree(bool yesNo) {
298  if (yesNo) state_ |= 1;
299  else state_ &= ~1;
300  }
302  inline bool active() const {
303  return (state_&2) != 0;
304  }
306  inline void setActive(bool yesNo) {
307  if (yesNo) state_ |= 2;
308  else state_ &= ~2;
309  }
311  inline int getState() const
312  { return state_;}
314  inline void setState(int value)
315  { state_ = value;}
317  void print() const;
319  inline void checkInfo() const {
320  assert (nodeInfo_->numberBranchesLeft() ==
321  branch_->numberBranchesLeft());
322  }
323 
324 private:
325  // Data
327  CbcNodeInfo * nodeInfo_;
329  double objectiveValue_;
331  double guessedObjectiveValue_;
333  double sumInfeasibilities_;
335  OsiBranchingObject * branch_;
337  int depth_;
339  int numberUnsatisfied_;
341  int nodeNumber_;
346  int state_;
347 };
348 
349 
350 #endif
351 
CbcNode::print
void print() const
Print.
CbcNode::way
int way() const
CbcPartialNodeInfo.hpp
CbcNode::CbcNode
CbcNode(CbcModel *model, CbcNode *lastNode)
Construct and increment parent reference count.
CbcCountRowCut
OsiRowCut augmented with bookkeeping.
Definition: CbcCountRowCut.hpp:35
CbcNode::decrementParentCuts
void decrementParentCuts(CbcModel *model, int change=1)
Decrement all active cut counts in chain starting at parent.
CbcNode::setObjectiveValue
void setObjectiveValue(double value)
Definition: CbcNode.hpp:224
CbcNode::branch
int branch(OsiSolverInterface *solver)
Does next branch and updates state.
CbcNode::analyze
int analyze(CbcModel *model, double *results)
CbcNode::nodeInfo
CbcNodeInfo * nodeInfo() const
Definition: CbcNode.hpp:216
CbcNode::setState
void setState(int value)
Set state (really for debug)
Definition: CbcNode.hpp:314
CbcNode::objectiveValue
double objectiveValue() const
Definition: CbcNode.hpp:221
CbcNode::chooseDynamicBranch
int chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, OsiSolverBranch *&branches, int numberPassesLeft)
Create a branching object for the node - when dynamic pseudo costs.
CbcNode::setOnTree
void setOnTree(bool yesNo)
Sets true if on tree.
Definition: CbcNode.hpp:297
CbcNode::setSumInfeasibilities
void setSumInfeasibilities(double value)
Set sum of "infeasibilities" reported by each object.
Definition: CbcNode.hpp:263
CbcNode::sumInfeasibilities
double sumInfeasibilities() const
Get sum of "infeasibilities" reported by each object.
Definition: CbcNode.hpp:259
CbcNode::decrementCuts
void decrementCuts(int change=1)
Decrement active cut counts.
CbcNode::depth
int depth() const
Depth in branch-and-cut search tree.
Definition: CbcNode.hpp:243
CbcNode::numberUnsatisfied
int numberUnsatisfied() const
Get the number of objects unsatisfied at this node.
Definition: CbcNode.hpp:251
CbcNode::setActive
void setActive(bool yesNo)
Sets true if active.
Definition: CbcNode.hpp:306
CbcNode::chooseClpBranch
int chooseClpBranch(CbcModel *model, CbcNode *lastNode)
Create a branching object for the node.
CbcNode::CbcNode
CbcNode(const CbcNode &)
Copy constructor.
CbcNode::setGuessedObjectiveValue
void setGuessedObjectiveValue(double value)
Definition: CbcNode.hpp:270
CbcNode::modifiableBranchingObject
OsiBranchingObject * modifiableBranchingObject() const
Modifiable branching object for this node.
Definition: CbcNode.hpp:278
CbcModel
Simple Branch and bound class.
Definition: CbcModel.hpp:101
CbcNode::chooseOsiBranch
int chooseOsiBranch(CbcModel *model, CbcNode *lastNode, OsiBranchingInformation *usefulInfo, int branchState)
Create a branching object for the node.
CbcNode::guessedObjectiveValue
double guessedObjectiveValue() const
Definition: CbcNode.hpp:267
CbcFullNodeInfo.hpp
CbcNode::setBranchingObject
void setBranchingObject(OsiBranchingObject *branchingObject)
Set branching object for this node (takes ownership)
Definition: CbcNode.hpp:282
CbcNode::setDepth
void setDepth(int value)
Set depth in branch-and-cut search tree.
Definition: CbcNode.hpp:247
CbcNode::checkInfo
void checkInfo() const
Debug.
Definition: CbcNode.hpp:319
CbcNode::CbcNode
CbcNode()
Default Constructor.
CbcBranchBase.hpp
CbcNode::operator=
CbcNode & operator=(const CbcNode &rhs)
Assignment operator.
CbcNodeInfo
Information required to recreate the subproblem at this node.
Definition: CbcNodeInfo.hpp:68
CbcNodeInfo.hpp
CbcNode::chooseBranch
int chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLeft)
Create a branching object for the node.
CbcNode
Information required while the node is live.
Definition: CbcNode.hpp:49
CbcNode::getState
int getState() const
Get state (really for debug)
Definition: CbcNode.hpp:311
CbcNode::nodeNumber
int nodeNumber() const
The node number.
Definition: CbcNode.hpp:286
CbcNode::onTree
bool onTree() const
Returns true if on tree.
Definition: CbcNode.hpp:293
CbcNode::setNumberUnsatisfied
void setNumberUnsatisfied(int value)
Set the number of objects unsatisfied at this node.
Definition: CbcNode.hpp:255
CbcNode::setNodeNumber
void setNodeNumber(int node)
Definition: CbcNode.hpp:289
CbcNode::~CbcNode
~CbcNode()
Destructor.
CbcNode::checkIsCutoff
double checkIsCutoff(double cutoff)
Double checks in case node can change its mind! Returns objective value Can change objective etc.
CbcNode::nullNodeInfo
void nullNodeInfo()
Nulls out node info.
CbcNodeInfo::numberBranchesLeft
int numberBranchesLeft() const
Return number of branches left in object.
Definition: CbcNodeInfo.hpp:155
CbcNode::createInfo
void createInfo(CbcModel *model, CbcNode *lastNode, const CoinWarmStartBasis *lastws, const double *lastLower, const double *lastUpper, int numberOldActiveCuts, int numberNewCuts)
Create a description of the subproblem at this node.
CbcNode::numberBranches
int numberBranches() const
Number of arms defined for the attached OsiBranchingObject.
Definition: CbcNode.hpp:228
CbcNode::branchingObject
const OsiBranchingObject * branchingObject() const
Branching object for this node.
Definition: CbcNode.hpp:274
CbcNode::active
bool active() const
Returns true if active.
Definition: CbcNode.hpp:302
CbcNode::initializeInfo
void initializeInfo()
Initialize reference counts in attached CbcNodeInfo.