Cbc  2.10.10
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CbcNode.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 #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:
53  CbcNode();
54 
56  CbcNode(CbcModel *model, CbcNode *lastNode);
57 
59  CbcNode(const CbcNode &);
60 
62  CbcNode &operator=(const CbcNode &rhs);
63 
65  ~CbcNode();
66 
82  void
83  createInfo(CbcModel *model,
84  CbcNode *lastNode,
85  const CoinWarmStartBasis *lastws,
86  const double *lastLower, const double *lastUpper,
87  int numberOldActiveCuts, int numberNewCuts);
88 
109  int chooseBranch(CbcModel *model,
110  CbcNode *lastNode,
111  int numberPassesLeft);
137  int chooseDynamicBranch(CbcModel *model,
138  CbcNode *lastNode,
139  OsiSolverBranch *&branches,
140  int numberPassesLeft);
167  int chooseOsiBranch(CbcModel *model,
168  CbcNode *lastNode,
169  OsiBranchingInformation *usefulInfo,
170  int branchState);
186  int chooseClpBranch(CbcModel *model,
187  CbcNode *lastNode);
188  int analyze(CbcModel *model, double *results);
190  void decrementCuts(int change = 1);
191 
193  void decrementParentCuts(CbcModel *model, int change = 1);
194 
196  void nullNodeInfo();
205  void initializeInfo();
206 
208  int branch(OsiSolverInterface *solver);
209 
213  double checkIsCutoff(double cutoff);
214  // Information to make basis and bounds
215  inline CbcNodeInfo *nodeInfo() const
216  {
217  return nodeInfo_;
218  }
219 
220  // Objective value
221  inline double objectiveValue() const
222  {
223  return objectiveValue_;
224  }
225  inline void setObjectiveValue(double value)
226  {
227  objectiveValue_ = value;
228  }
230  inline int numberBranches() const
231  {
232  if (branch_)
233  return (branch_->numberBranches());
234  else
235  return (-1);
236  }
237 
238  /* Active arm of the attached OsiBranchingObject.
239 
240  In the simplest instance, coded -1 for the down arm of the branch, +1 for
241  the up arm. But see OsiBranchingObject::way()
242  Use nodeInfo--.numberBranchesLeft_ to see how active
243  */
244  int way() const;
246  inline int depth() const
247  {
248  return depth_;
249  }
251  inline void setDepth(int value)
252  {
253  depth_ = value;
254  }
256  inline int numberUnsatisfied() const
257  {
258  return numberUnsatisfied_;
259  }
261  inline void setNumberUnsatisfied(int value)
262  {
263  numberUnsatisfied_ = value;
264  }
266  inline double sumInfeasibilities() const
267  {
268  return sumInfeasibilities_;
269  }
271  inline void setSumInfeasibilities(double value)
272  {
273  sumInfeasibilities_ = value;
274  }
275  // Guessed objective value (for solution)
276  inline double guessedObjectiveValue() const
277  {
278  return guessedObjectiveValue_;
279  }
280  inline void setGuessedObjectiveValue(double value)
281  {
282  guessedObjectiveValue_ = value;
283  }
285  inline const OsiBranchingObject *branchingObject() const
286  {
287  return branch_;
288  }
290  inline OsiBranchingObject *modifiableBranchingObject() const
291  {
292  return branch_;
293  }
295  inline void setBranchingObject(OsiBranchingObject *branchingObject)
296  {
298  }
300  inline int nodeNumber() const
301  {
302  return nodeNumber_;
303  }
304  inline void setNodeNumber(int node)
305  {
306  nodeNumber_ = node;
307  }
309  inline bool onTree() const
310  {
311  return (state_ & 1) != 0;
312  }
314  inline void setOnTree(bool yesNo)
315  {
316  if (yesNo)
317  state_ |= 1;
318  else
319  state_ &= ~1;
320  }
322  inline bool active() const
323  {
324  return (state_ & 2) != 0;
325  }
327  inline void setActive(bool yesNo)
328  {
329  if (yesNo)
330  state_ |= 2;
331  else
332  state_ &= ~2;
333  }
335  inline int getState() const
336  {
337  return state_;
338  }
340  inline void setState(int value)
341  {
342  state_ = value;
343  }
345  void print() const;
347  inline void checkInfo() const
348  {
349  assert(nodeInfo_->numberBranchesLeft() == branch_->numberBranchesLeft());
350  }
351 
352 private:
353  // Data
363  OsiBranchingObject *branch_;
365  int depth_;
374  int state_;
375 };
376 
377 #endif
378 
379 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
380 */
CbcNode::print
void print() const
Print.
CbcNode::way
int way() const
CbcPartialNodeInfo.hpp
CbcNode::objectiveValue_
double objectiveValue_
Objective value.
Definition: CbcNode.hpp:357
CbcNode::numberUnsatisfied_
int numberUnsatisfied_
The number of objects unsatisfied at this node.
Definition: CbcNode.hpp:367
CbcCountRowCut
OsiRowCut augmented with bookkeeping.
Definition: CbcCountRowCut.hpp:34
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:225
CbcNode::sumInfeasibilities_
double sumInfeasibilities_
Sum of "infeasibilities" reported by each object.
Definition: CbcNode.hpp:361
CbcNode::branch
int branch(OsiSolverInterface *solver)
Does next branch and updates state.
CbcNode::nodeNumber_
int nodeNumber_
The node number.
Definition: CbcNode.hpp:369
CbcNode::analyze
int analyze(CbcModel *model, double *results)
CbcNode::nodeInfo_
CbcNodeInfo * nodeInfo_
Information to make basis and bounds.
Definition: CbcNode.hpp:355
CbcNode::nodeInfo
CbcNodeInfo * nodeInfo() const
Definition: CbcNode.hpp:215
CbcNode::setState
void setState(int value)
Set state (really for debug)
Definition: CbcNode.hpp:340
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:314
CbcNode::setSumInfeasibilities
void setSumInfeasibilities(double value)
Set sum of "infeasibilities" reported by each object.
Definition: CbcNode.hpp:271
CbcNode::sumInfeasibilities
double sumInfeasibilities() const
Get sum of "infeasibilities" reported by each object.
Definition: CbcNode.hpp:266
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:246
CbcNode::numberUnsatisfied
int numberUnsatisfied() const
Get the number of objects unsatisfied at this node.
Definition: CbcNode.hpp:256
CbcNode::setActive
void setActive(bool yesNo)
Sets true if active.
Definition: CbcNode.hpp:327
CbcNode::chooseClpBranch
int chooseClpBranch(CbcModel *model, CbcNode *lastNode)
Create a branching object for the node.
CbcNode::state_
int state_
State 1 - on tree 2 - active.
Definition: CbcNode.hpp:374
CbcNode::setGuessedObjectiveValue
void setGuessedObjectiveValue(double value)
Definition: CbcNode.hpp:280
CbcNode::modifiableBranchingObject
OsiBranchingObject * modifiableBranchingObject() const
Modifiable branching object for this node.
Definition: CbcNode.hpp:290
CbcModel
Simple Branch and bound class.
Definition: CbcModel.hpp:100
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:276
CbcFullNodeInfo.hpp
CbcNode::setBranchingObject
void setBranchingObject(OsiBranchingObject *branchingObject)
Set branching object for this node (takes ownership)
Definition: CbcNode.hpp:295
CbcNode::setDepth
void setDepth(int value)
Set depth in branch-and-cut search tree.
Definition: CbcNode.hpp:251
CbcNode::checkInfo
void checkInfo() const
Debug.
Definition: CbcNode.hpp:347
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
CbcNode::depth_
int depth_
Depth of the node in the search tree.
Definition: CbcNode.hpp:365
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::branch_
OsiBranchingObject * branch_
Branching object for this node.
Definition: CbcNode.hpp:363
CbcNode::getState
int getState() const
Get state (really for debug)
Definition: CbcNode.hpp:335
CbcNode::nodeNumber
int nodeNumber() const
The node number.
Definition: CbcNode.hpp:300
CbcNode::onTree
bool onTree() const
Returns true if on tree.
Definition: CbcNode.hpp:309
CbcNode::setNumberUnsatisfied
void setNumberUnsatisfied(int value)
Set the number of objects unsatisfied at this node.
Definition: CbcNode.hpp:261
CbcNode::setNodeNumber
void setNodeNumber(int node)
Definition: CbcNode.hpp:304
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::guessedObjectiveValue_
double guessedObjectiveValue_
Guessed satisfied Objective value.
Definition: CbcNode.hpp:359
CbcNode::nullNodeInfo
void nullNodeInfo()
Nulls out node info.
CbcNodeInfo::numberBranchesLeft
int numberBranchesLeft() const
Return number of branches left in object.
Definition: CbcNodeInfo.hpp:156
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:230
CbcNode::branchingObject
const OsiBranchingObject * branchingObject() const
Branching object for this node.
Definition: CbcNode.hpp:285
CbcNode::active
bool active() const
Returns true if active.
Definition: CbcNode.hpp:322
CbcNode::initializeInfo
void initializeInfo()
Initialize reference counts in attached CbcNodeInfo.