CbcNode.hpp
Go to the documentation of this file.
1 /* $Id: CbcNode.hpp 1400 2009-12-11 14:14:06Z lou $ */
2 // Copyright (C) 2002, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 #ifndef CbcNode_H
5 #define CbcNode_H
6 
7 #include <string>
8 #include <vector>
9 
10 #include "CoinWarmStartBasis.hpp"
11 #include "CoinSearchTree.hpp"
12 #include "CbcBranchBase.hpp"
13 #include "CbcNodeInfo.hpp"
14 #include "CbcFullNodeInfo.hpp"
15 #include "CbcPartialNodeInfo.hpp"
16 
17 class OsiSolverInterface;
18 class OsiSolverBranch;
19 
20 class OsiCuts;
21 class OsiRowCut;
22 class OsiRowCutDebugger;
23 class CoinWarmStartBasis;
24 class CbcCountRowCut;
25 class CbcModel;
26 class CbcNode;
27 class CbcSubProblem;
28 class CbcGeneralBranchingObject;
29 
47 class CbcNode : public CoinTreeNode {
48 
49 public:
50 
52  CbcNode ();
53 
55  CbcNode (CbcModel * model, CbcNode * lastNode);
56 
58  CbcNode (const CbcNode &);
59 
61  CbcNode & operator= (const CbcNode& rhs);
62 
64  ~CbcNode ();
65 
81  void
82  createInfo(CbcModel * model,
83  CbcNode * lastNode,
84  const CoinWarmStartBasis *lastws,
85  const double * lastLower, const double * lastUpper,
86  int numberOldActiveCuts, int numberNewCuts);
87 
108  int chooseBranch (CbcModel * model,
109  CbcNode * lastNode,
110  int numberPassesLeft);
136  int chooseDynamicBranch (CbcModel * model,
137  CbcNode * lastNode,
138  OsiSolverBranch * & branches,
139  int numberPassesLeft);
166  int chooseOsiBranch (CbcModel * model,
167  CbcNode * lastNode,
168  OsiBranchingInformation * usefulInfo,
169  int branchState);
185  int chooseClpBranch (CbcModel * model,
186  CbcNode * lastNode);
187  int analyze(CbcModel * model, double * results);
189  void decrementCuts(int change = 1);
190 
192  void decrementParentCuts(CbcModel * model, int change = 1);
193 
195  void nullNodeInfo();
204  void initializeInfo();
205 
207  int branch(OsiSolverInterface * solver);
208 
212  double checkIsCutoff(double cutoff);
213  // Information to make basis and bounds
214  inline CbcNodeInfo * nodeInfo() const {
215  return nodeInfo_;
216  }
217 
218  // Objective value
219  inline double objectiveValue() const {
220  return objectiveValue_;
221  }
222  inline void setObjectiveValue(double value) {
223  objectiveValue_ = value;
224  }
226  inline int numberBranches() const {
227  if (branch_)
228  return (branch_->numberBranches()) ;
229  else
230  return (-1) ;
231  }
232 
233  /* Active arm of the attached OsiBranchingObject.
234 
235  In the simplest instance, coded -1 for the down arm of the branch, +1 for
236  the up arm. But see OsiBranchingObject::way()
237  Use nodeInfo--.numberBranchesLeft_ to see how active
238  */
239  int way() const;
241  inline int depth() const {
242  return depth_;
243  }
245  inline void setDepth(int value) {
246  depth_ = value;
247  }
249  inline int numberUnsatisfied() const {
250  return numberUnsatisfied_;
251  }
253  inline void setNumberUnsatisfied(int value) {
254  numberUnsatisfied_ = value;
255  }
257  inline double sumInfeasibilities() const {
258  return sumInfeasibilities_;
259  }
261  inline void setSumInfeasibilities(double value) {
262  sumInfeasibilities_ = value;
263  }
264  // Guessed objective value (for solution)
265  inline double guessedObjectiveValue() const {
266  return guessedObjectiveValue_;
267  }
268  inline void setGuessedObjectiveValue(double value) {
269  guessedObjectiveValue_ = value;
270  }
272  inline const OsiBranchingObject * branchingObject() const {
273  return branch_;
274  }
276  inline OsiBranchingObject * modifiableBranchingObject() const {
277  return branch_;
278  }
280  inline void setBranchingObject(OsiBranchingObject * branchingObject) {
282  }
284  inline int nodeNumber() const {
285  return nodeNumber_;
286  }
287  inline void setNodeNumber(int node) {
288  nodeNumber_ = node;
289  }
291  inline bool onTree() const {
292  return (state_&1) != 0;
293  }
295  inline void setOnTree(bool yesNo) {
296  if (yesNo) state_ |= 1;
297  else state_ &= ~1;
298  }
300  inline bool active() const {
301  return (state_&2) != 0;
302  }
304  inline void setActive(bool yesNo) {
305  if (yesNo) state_ |= 2;
306  else state_ &= ~2;
307  }
309  void print() const;
311  inline void checkInfo() const {
312  assert (nodeInfo_->numberBranchesLeft() ==
313  branch_->numberBranchesLeft());
314  }
315 
316 private:
317  // Data
327  OsiBranchingObject * branch_;
329  int depth_;
338  int state_;
339 };
340 
341 
342 #endif
343