Bcps 0.95.1
Loading...
Searching...
No Matches
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-2023, 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 "BcpsConfig.h"
34#include "BcpsBranchObject.h"
35#include "BcpsObjectPool.h"
36
37//#############################################################################
45//#############################################################################
46
47class BCPSLIB_EXPORT BcpsTreeNode : public AlpsTreeNode {
48
49 protected:
50
54
55 protected:
56
59 virtual int generateConstraints(BcpsModel *model,
60 BcpsConstraintPool *conPool) {
61 AlpsReturnStatus status = AlpsReturnStatusOk;
62 return status;
63 }
64
67 virtual int generateVariables(BcpsModel *model,
68 BcpsVariablePool *varPool) {
69 AlpsReturnStatus status = AlpsReturnStatusOk;
70 return status;
71 }
72
74 virtual int chooseBranchingObject(BcpsModel *model) = 0;
75
79 virtual int installSubProblem(BcpsModel *model) = 0;
80
92 virtual int handleBoundingStatus(int status, bool &keepOn, bool &fathomed){
93 // Default do nothing.
94 return BcpsReturnStatusOk;
95 }
96
97 public:
98
101
103 virtual ~BcpsTreeNode(){ delete branchObject_; }
104
111 virtual int process(bool isRoot = false, bool rampUp = false);
112
114 virtual int bound(BcpsModel *model) = 0;
115
120 virtual std::vector< CoinTriple<AlpsNodeDesc*, AlpsNodeStatus, double> >
121 branch() = 0;
122
124 const BcpsBranchObject * branchObject() const { return branchObject_; }
125
128
129 protected:
130
132 AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const {
133 AlpsReturnStatus status = AlpsReturnStatusOk;
134 int type = 0;
135 if (branchObject_) {
136 type = branchObject_->getType();
137 encoded->writeRep(type);
138 status = branchObject_->encode(encoded);
139 }
140 else {
141 encoded->writeRep(type);
142 }
143 return status;
144 }
145
146#if 0 // Can't docode a down(blis) branching object here.
148 AlpsReturnStatus decodeBcps(AlpsEncoded &encoded) {
149 AlpsReturnStatus status = AlpsReturnStatusOk;
150 int mark;
151 encoded.readRep(mark);
152
153 if (mark == 1) {
154 // branchObject_ is not NULL.
155 status = branchObject_->encode(encoded);
156 }
157
158 return status;
159 }
160#endif
161
162};
163
164#endif
@ BcpsReturnStatusOk
Definition Bcps.h:31
BcpsBranchObject contains the member data required when choosing branching entities and excuting actu...
virtual AlpsReturnStatus encode(AlpsEncoded *encoded) const
Pack to an encoded object.
virtual int process(bool isRoot=false, bool rampUp=false)
This methods performs the processing of the node.
const BcpsBranchObject * branchObject() const
Return the branching object.
BcpsTreeNode()
Default constructor.
virtual int installSubProblem(BcpsModel *model)=0
Extract node information (bounds, constraints, variables) from this node and load the information int...
AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const
Pack Bcps portion of node into an encoded object.
virtual int generateVariables(BcpsModel *model, BcpsVariablePool *varPool)
Generate variables.
virtual int generateConstraints(BcpsModel *model, BcpsConstraintPool *conPool)
Generate constraints.
virtual ~BcpsTreeNode()
Destructor.
virtual int bound(BcpsModel *model)=0
Bounding procedure to estimate quality of this node.
void setBranchObject(BcpsBranchObject *b)
Set the branching object.
BcpsBranchObject * branchObject_
Branching object for this node, which has information of how to execute branching.
virtual int chooseBranchingObject(BcpsModel *model)=0
Choose a branching object.
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 int handleBoundingStatus(int status, bool &keepOn, bool &fathomed)
Handle bounding status:
#define BCPSLIB_EXPORT
Definition config.h:5