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 
39 };
40 
41 //#############################################################################
42 
43 class AbcTreeNode : public AlpsTreeNode {
44  private:
45  // NO: default constructor, copy constructor, assignment operator
46  AbcTreeNode(const AbcTreeNode&);
48 
49  private:
52 
55 
58 
61 
64 
65  public:
67  :
68  branchedOn_(-1),
70  branchedDir_(0),
73  {
74  desc_ = new AbcNodeDesc(dynamic_cast<AbcModel*>
75  (getKnowledgeBroker()->getModel()));
76  }
77 
79  :
80  branchedOn_(-1),
82  branchedDir_(0),
85  {
86  desc_ = new AbcNodeDesc(m);
87  }
88 
90  :
91  branchedOn_(-1),
93  branchedDir_(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 
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
AbcTreeNode & operator=(const AbcTreeNode &)
virtual std::vector< CoinTriple< AlpsNodeDesc *, AlpsNodeStatus, double > > branch()
AbcTreeNode(AbcNodeDesc *&desc)
Definition: AbcTreeNode.h:89
int numberUnsatisfied() const
Get the number of objects unsatisfied at this node.
Definition: AbcTreeNode.h:133
double getObjValue() const
Query/set the objective value (could be approximately or not exit) of the node.
Definition: AbcTreeNode.h:125
virtual int process(bool isRoot=false, bool rampUp=false)
Performing the bounding operation.
int numberUnsatisfied_
The number of objects unsatisfied at this node.
Definition: AbcTreeNode.h:63
int branchedDir_
Branching direction.
Definition: AbcTreeNode.h:57
void setBranchedDir(int d)
Definition: AbcTreeNode.h:145
AlpsKnowledgeBroker * getKnowledgeBroker() const
Functions to access/set the knwoledge broker.
Definition: AlpsTreeNode.h:156
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
AbcTreeNode(AbcModel *m)
Definition: AbcTreeNode.h:78
double guessedObjectiveValue_
Guessed satisfied Objective value.
Definition: AbcTreeNode.h:60
double getBranchedOnValue() const
Definition: AbcTreeNode.h:153
#define ALPS_BND_MAX
Definition: Alps.h:147
This class holds one node of the search tree.
Definition: AlpsTreeNode.h:50
int getBranchedOn() const
Definition: AbcTreeNode.h:149
void setBranchedOn(int b)
Definition: AbcTreeNode.h:143
#define ALPS_OBJ_MAX
Definition: Alps.h:145
AbcVarStatus
Definition: AbcTreeNode.h:35
void setGuessedObjectiveValue(double value)
Definition: AbcTreeNode.h:140
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
Definition: AlpsKnowledge.h:51
double quality_
The quality of this node.
Definition: AlpsTreeNode.h:72
double guessedObjectiveValue() const
Guessed objective value (for solution)
Definition: AbcTreeNode.h:137
virtual AlpsEncoded * encode() const
This method should encode the content of the object and return a pointer to the encoded form...
void setObjValue(const double objValue)
Query/set the objective value (could be approximately or not exit) of the node.
Definition: AbcTreeNode.h:126
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 ...
void setBranchedOnValue(double b)
Definition: AbcTreeNode.h:147
virtual AlpsTreeNode * createNewTreeNode(AlpsNodeDesc *&desc) const
The purpose of this function is be able to create the children of a node after branching.
int getBranchedDir() const
Definition: AbcTreeNode.h:151
int chooseBranch(AbcModel *model, bool &strongFound)
Select the branch variable.
int branchedOn_
The index of the branching variable.
Definition: AbcTreeNode.h:51
double branchedOnVal_
The solution value (non-integral) of the branching variable.
Definition: AbcTreeNode.h:54
A class to refer to the description of a search tree node.
Definition: AlpsNodeDesc.h:35
Model class for ALPS Branch and Cut.
Definition: AbcModel.h:55
AlpsNodeDesc * desc_
The actual description of the tree node.
Definition: AlpsTreeNode.h:95