- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

AbcTreeNode.h
Go to the documentation of this file.
1 /*===========================================================================*
2 * This file is part of the Abstract Library for Parallel Search (ALPS). *
3 * *
4 * ALPS 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 * *
20 * Copyright (C) 2001-2013, Lehigh University, Yan Xu, and Ted Ralphs. *
21 *===========================================================================*/
22
23 #ifndef AbcTreeNode_h_
24 #define AbcTreeNode_h_
25
26 //#include <utility>
27 #include "AlpsKnowledgeBroker.h"
28 #include "AlpsTreeNode.h"
29
30 #include "AbcModel.h"
31 #include "AbcNodeDesc.h"
32
33 //#############################################################################
34
35 enum AbcVarStatus {
36 AbcVarFree,
37 AbcVarFixedToUB,
38 AbcVarFixedToLB
39 };
40
41 //#############################################################################
42
43 class AbcTreeNode : public AlpsTreeNode {
44 private:
45 // NO: default constructor, copy constructor, assignment operator
46 AbcTreeNode(const AbcTreeNode&);
47 AbcTreeNode& operator=(const AbcTreeNode&);
48
49 private:
51 int branchedOn_;
52
54 double branchedOnVal_;
55
57 int branchedDir_;
58
60 double guessedObjectiveValue_;
61
63 int numberUnsatisfied_;
64
65 public:
66 AbcTreeNode()
67 :
68 branchedOn_(-1),
69 branchedOnVal_(ALPS_BND_MAX),
70 branchedDir_(0),
71 guessedObjectiveValue_(ALPS_OBJ_MAX),
72 numberUnsatisfied_(0)
73 {
74 desc_ = new AbcNodeDesc(dynamic_cast<AbcModel*>
75 (getKnowledgeBroker()->getModel()));
76 }
77
78 AbcTreeNode(AbcModel* m)
79 :
80 branchedOn_(-1),
81 branchedOnVal_(ALPS_BND_MAX),
82 branchedDir_(0),
83 guessedObjectiveValue_(ALPS_OBJ_MAX),
84 numberUnsatisfied_(0)
85 {
86 desc_ = new AbcNodeDesc(m);
87 }
88
89 AbcTreeNode(AbcNodeDesc*& desc)
90 :
91 branchedOn_(-1),
92 branchedOnVal_(ALPS_BND_MAX),
93 branchedDir_(0),
94 guessedObjectiveValue_(ALPS_OBJ_MAX),
95 numberUnsatisfied_(0)
96 {
97 desc_ = desc;
98 desc = 0;
99 //At the time of registering node, that node hasn't set broker
100 //desc_->setModel(getKnowledgeBroker()->getDataPool()->getModel());
101 }
102
103 ~AbcTreeNode()
104 {
105 }
106
107 virtual AlpsTreeNode* createNewTreeNode(AlpsNodeDesc*& desc) const;
108
110 virtual int process(bool isRoot = false, bool rampUp = false);
111
120 int chooseBranch (AbcModel * model, bool& strongFound);
121
124 inline double getObjValue() const { return quality_; }
126 inline void setObjValue(const double objValue) { quality_ = objValue; }
128
129 virtual std::vector< CoinTriple<AlpsNodeDesc*, AlpsNodeStatus, double> >
130 branch();
131
133 inline int numberUnsatisfied() const
134 { return numberUnsatisfied_; }
135
137 inline double guessedObjectiveValue() const
138 { return guessedObjectiveValue_; }
140 inline void setGuessedObjectiveValue(double value)
141 { guessedObjectiveValue_ = value; }
143 void setBranchedOn(int b) { branchedOn_ = b; }
145 void setBranchedDir(int d) { branchedDir_ = d; }
147 void setBranchedOnValue(double b) { branchedOnVal_ = b; }
149 int getBranchedOn() const { return branchedOn_; }
151 int getBranchedDir() const { return branchedDir_; }
153 double getBranchedOnValue() const { return branchedOnVal_; }
155 virtual AlpsEncoded* encode() const;
157 virtual AlpsKnowledge* decode(AlpsEncoded&) const;
158
159 };
160
161 #endif
AbcVarFixedToUB
Definition: AbcTreeNode.h:37
AbcTreeNode::operator=
AbcTreeNode & operator=(const AbcTreeNode &)
AbcTreeNode::branch
virtual std::vector< CoinTriple< AlpsNodeDesc *, AlpsNodeStatus, double > > branch()
AbcTreeNode::AbcTreeNode
AbcTreeNode(AbcNodeDesc *&desc)
Definition: AbcTreeNode.h:89
AbcTreeNode::numberUnsatisfied
int numberUnsatisfied() const
Get the number of objects unsatisfied at this node.
Definition: AbcTreeNode.h:133
AbcTreeNode
Definition: AbcTreeNode.h:43
AbcTreeNode::getObjValue
double getObjValue() const
Query/set the objective value (could be approximately or not exit) of the node.
Definition: AbcTreeNode.h:125
AbcTreeNode::process
virtual int process(bool isRoot=false, bool rampUp=false)
Performing the bounding operation.
AbcTreeNode::numberUnsatisfied_
int numberUnsatisfied_
The number of objects unsatisfied at this node.
Definition: AbcTreeNode.h:63
AbcTreeNode::branchedDir_
int branchedDir_
Branching direction.
Definition: AbcTreeNode.h:57
AbcTreeNode::setBranchedDir
void setBranchedDir(int d)
Definition: AbcTreeNode.h:145
AlpsTreeNode::getKnowledgeBroker
AlpsKnowledgeBroker * getKnowledgeBroker() const
Functions to access/set the knwoledge broker.
Definition: AlpsTreeNode.h:160
AlpsEncoded
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
AbcTreeNode::~AbcTreeNode
~AbcTreeNode()
Definition: AbcTreeNode.h:103
AbcVarFree
Definition: AbcTreeNode.h:36
AbcModel.h
AbcTreeNode::AbcTreeNode
AbcTreeNode(AbcModel *m)
Definition: AbcTreeNode.h:78
AbcTreeNode::guessedObjectiveValue_
double guessedObjectiveValue_
Guessed satisfied Objective value.
Definition: AbcTreeNode.h:60
AbcTreeNode::getBranchedOnValue
double getBranchedOnValue() const
Definition: AbcTreeNode.h:153
ALPS_BND_MAX
#define ALPS_BND_MAX
Definition: Alps.h:147
AlpsTreeNode
This class holds one node of the search tree.
Definition: AlpsTreeNode.h:50
AbcTreeNode::getBranchedOn
int getBranchedOn() const
Definition: AbcTreeNode.h:149
AbcNodeDesc
Definition: AbcNodeDesc.h:48
AbcTreeNode::setBranchedOn
void setBranchedOn(int b)
Definition: AbcTreeNode.h:143
AbcTreeNode::AbcTreeNode
AbcTreeNode()
Definition: AbcTreeNode.h:66
ALPS_OBJ_MAX
#define ALPS_OBJ_MAX
Definition: Alps.h:145
AbcVarStatus
AbcVarStatus
Definition: AbcTreeNode.h:35
AbcTreeNode::setGuessedObjectiveValue
void setGuessedObjectiveValue(double value)
Definition: AbcTreeNode.h:140
AlpsKnowledge
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
Definition: AlpsKnowledge.h:51
AlpsTreeNode::quality_
double quality_
The quality of this node.
Definition: AlpsTreeNode.h:72
AbcTreeNode::guessedObjectiveValue
double guessedObjectiveValue() const
Guessed objective value (for solution)
Definition: AbcTreeNode.h:137
AbcTreeNode::encode
virtual AlpsEncoded * encode() const
This method should encode the content of the object and return a pointer to the encoded form...
AlpsTreeNode.h
AbcTreeNode::setObjValue
void setObjValue(const double objValue)
Query/set the objective value (could be approximately or not exit) of the node.
Definition: AbcTreeNode.h:126
AbcVarFixedToLB
Definition: AbcTreeNode.h:38
AbcTreeNode::decode
virtual AlpsKnowledge * decode(AlpsEncoded &) const
This method should decode and return a pointer to a brand new object, i.e., the method must create a ...
AlpsKnowledgeBroker.h
AbcTreeNode::setBranchedOnValue
void setBranchedOnValue(double b)
Definition: AbcTreeNode.h:147
AbcTreeNode::createNewTreeNode
virtual AlpsTreeNode * createNewTreeNode(AlpsNodeDesc *&desc) const
The purpose of this function is be able to create the children of a node after branching.
AbcTreeNode::getBranchedDir
int getBranchedDir() const
Definition: AbcTreeNode.h:151
AbcTreeNode::chooseBranch
int chooseBranch(AbcModel *model, bool &strongFound)
Select the branch variable.
AbcTreeNode::branchedOn_
int branchedOn_
The index of the branching variable.
Definition: AbcTreeNode.h:51
AbcTreeNode::branchedOnVal_
double branchedOnVal_
The solution value (non-integral) of the branching variable.
Definition: AbcTreeNode.h:54
AlpsNodeDesc
A class to refer to the description of a search tree node.
Definition: AlpsNodeDesc.h:35
AbcNodeDesc.h
AbcModel
Model class for ALPS Branch and Cut.
Definition: AbcModel.h:55
AlpsTreeNode::desc_
AlpsNodeDesc * desc_
The actual description of the tree node.
Definition: AlpsTreeNode.h:95