Bcps  0.94.3
BcpsTreeNode.h
Go to the documentation of this file.
1 /*===========================================================================*
2  * This file is part of the Branch, Constrain and Price Software (BiCePS) *
3  * *
4  * BiCePS is distributed under the Eclipse Public License as part of the *
5  * COIN-OR repository (http://www.coin-or.org). *
6  * *
7  * Authors: *
8  * *
9  * Yan Xu, Lehigh University *
10  * Ted Ralphs, Lehigh University *
11  * *
12  * Conceptual Design: *
13  * *
14  * Yan Xu, Lehigh University *
15  * Ted Ralphs, Lehigh University *
16  * Laszlo Ladanyi, IBM T.J. Watson Research Center *
17  * Matthew Saltzman, Clemson University *
18  * *
19  * Copyright (C) 2001-2013, Lehigh University, Yan Xu, and Ted Ralphs. *
20  * All Rights Reserved. *
21  *===========================================================================*/
22 
23 #ifndef BcpsTreeNode_h_
24 #define BcpsTreeNode_h_
25 
26 #include "BcpsNodeDesc.h"
27 
28 #include <vector>
29 
30 #include "AlpsTreeNode.h"
31 #include "AlpsNodeDesc.h"
32 
33 #include "BcpsBranchObject.h"
34 #include "BcpsObjectPool.h"
35 
36 //#############################################################################
44 //#############################################################################
45 
46 class BcpsTreeNode : public AlpsTreeNode {
47 
48  protected:
49 
53 
54  protected:
55 
58  virtual int generateConstraints(BcpsModel *model,
59  BcpsConstraintPool *conPool) {
60  AlpsReturnStatus status = AlpsReturnStatusOk;
61  return status;
62  }
63 
66  virtual int generateVariables(BcpsModel *model,
67  BcpsVariablePool *varPool) {
68  AlpsReturnStatus status = AlpsReturnStatusOk;
69  return status;
70  }
71 
73  virtual int chooseBranchingObject(BcpsModel *model) = 0;
74 
78  virtual int installSubProblem(BcpsModel *model) = 0;
79 
91  virtual int handleBoundingStatus(int status, bool &keepOn, bool &fathomed){
92  // Default do nothing.
93  return BcpsReturnStatusOk;
94  }
95 
96  public:
97 
99  BcpsTreeNode() : branchObject_(NULL) { }
100 
102  virtual ~BcpsTreeNode(){ delete branchObject_; }
103 
110  virtual int process(bool isRoot = false, bool rampUp = false);
111 
113  virtual int bound(BcpsModel *model) = 0;
114 
119  virtual std::vector< CoinTriple<AlpsNodeDesc*, AlpsNodeStatus, double> >
120  branch() = 0;
121 
123  const BcpsBranchObject * branchObject() const { return branchObject_; }
124 
126  void setBranchObject(BcpsBranchObject * b) { branchObject_ = b; }
127 
128  protected:
129 
131  AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const {
132  AlpsReturnStatus status = AlpsReturnStatusOk;
133  int type = 0;
134  if (branchObject_) {
135  type = branchObject_->getType();
136  encoded->writeRep(type);
137  status = branchObject_->encode(encoded);
138  }
139  else {
140  encoded->writeRep(type);
141  }
142  return status;
143  }
144 
145 #if 0 // Can't docode a down(blis) branching object here.
146 
147  AlpsReturnStatus decodeBcps(AlpsEncoded &encoded) {
148  AlpsReturnStatus status = AlpsReturnStatusOk;
149  int mark;
150  encoded.readRep(mark);
151 
152  if (mark == 1) {
153  // branchObject_ is not NULL.
154  status = branchObject_->encode(encoded);
155  }
156 
157  return status;
158  }
159 #endif
160 
161 };
162 
163 #endif
This class contain the data for a BCPS search tree node.
Definition: BcpsTreeNode.h:46
void setBranchObject(BcpsBranchObject *b)
Set the branching object.
Definition: BcpsTreeNode.h:126
virtual int bound(BcpsModel *model)=0
Bounding procedure to estimate quality of this node.
virtual int generateConstraints(BcpsModel *model, BcpsConstraintPool *conPool)
Generate constraints.
Definition: BcpsTreeNode.h:58
virtual int process(bool isRoot=false, bool rampUp=false)
This methods performs the processing of the node.
virtual std::vector< CoinTriple< AlpsNodeDesc *, AlpsNodeStatus, double > > branch()=0
This method must be invoked on a pregnant node (which has all the information needed to create the ch...
virtual ~BcpsTreeNode()
Destructor.
Definition: BcpsTreeNode.h:102
virtual AlpsReturnStatus encode(AlpsEncoded *encoded) const
Pack to an encoded object.
virtual int generateVariables(BcpsModel *model, BcpsVariablePool *varPool)
Generate variables.
Definition: BcpsTreeNode.h:66
BcpsTreeNode()
Default constructor.
Definition: BcpsTreeNode.h:99
AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const
Pack Bcps portion of node into an encoded object.
Definition: BcpsTreeNode.h:131
virtual int installSubProblem(BcpsModel *model)=0
Extract node information (bounds, constraints, variables) from this node and load the information int...
const BcpsBranchObject * branchObject() const
Return the branching object.
Definition: BcpsTreeNode.h:123
BcpsBranchObject * branchObject_
Branching object for this node, which has information of how to execute branching.
Definition: BcpsTreeNode.h:52
virtual int chooseBranchingObject(BcpsModel *model)=0
Choose a branching object.
BcpsBranchObject contains the member data required when choosing branching entities and excuting actu...
virtual int handleBoundingStatus(int status, bool &keepOn, bool &fathomed)
Handle bounding status:
Definition: BcpsTreeNode.h:91
int getType()
Get type.