Alps  2.0.2
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  * Aykut Bulut, Lehigh University *
11  * Ted Ralphs, Lehigh University *
12  * *
13  * Conceptual Design: *
14  * *
15  * Yan Xu, Lehigh University *
16  * Ted Ralphs, Lehigh University *
17  * Laszlo Ladanyi, IBM T.J. Watson Research Center *
18  * Matthew Saltzman, Clemson University *
19  * *
20  * *
21  * Copyright (C) 2001-2019, Lehigh University, Yan Xu, Aykut Bulut, and *
22  * Ted Ralphs. *
23  * All Rights Reserved. *
24  *===========================================================================*/
25 
26 
27 #ifndef AbcTreeNode_h_
28 #define AbcTreeNode_h_
29 
30 //#include <utility>
31 #include "AlpsKnowledgeBroker.h"
32 #include "AlpsTreeNode.h"
33 
34 #include "AbcModel.h"
35 #include "AbcNodeDesc.h"
36 
37 //#############################################################################
38 
43 };
44 
45 //#############################################################################
46 
47 class AbcTreeNode : public AlpsTreeNode {
48  private:
50  int branchedOn_;
51 
53  double branchedOnVal_;
54 
56  int branchedDir_;
57 
60 
63 
64  public:
66  :
67  AlpsTreeNode(),
68  branchedOn_(-1),
70  branchedDir_(0),
73  {
74  desc_ = new AbcNodeDesc();
75  }
76 
78  :
79  AlpsTreeNode(),
80  branchedOn_(-1),
82  branchedDir_(0),
85  {
86  desc_ = desc;
87  desc = 0;
88  //At the time of registering node, that node hasn't set broker
89  //desc_->setModel(getKnowledgeBroker()->getDataPool()->getModel());
90  }
91 
92  virtual ~AbcTreeNode()
93  {
94  }
95 
96  virtual AlpsTreeNode* createNewTreeNode(AlpsNodeDesc*& desc) const;
97 
99  virtual int process(bool isRoot = false, bool rampUp = false);
100 
109  int chooseBranch (AbcModel * model, bool& strongFound);
110 
113  inline double getObjValue() const { return quality_; }
115  inline void setObjValue(const double objValue) { quality_ = objValue; }
117 
118  virtual std::vector< CoinTriple<AlpsNodeDesc*, AlpsNodeStatus, double> >
119  branch();
120 
122  inline int numberUnsatisfied() const
123  { return numberUnsatisfied_; }
124 
126  inline double guessedObjectiveValue() const
127  { return guessedObjectiveValue_; }
129  inline void setGuessedObjectiveValue(double value)
130  { guessedObjectiveValue_ = value; }
132  void setBranchedOn(int b) { branchedOn_ = b; }
134  void setBranchedDir(int d) { branchedDir_ = d; }
136  void setBranchedOnValue(double b) { branchedOnVal_ = b; }
138  int getBranchedOn() const { return branchedOn_; }
140  int getBranchedDir() const { return branchedDir_; }
142  double getBranchedOnValue() const { return branchedOnVal_; }
144 
145  using AlpsKnowledge::encode;
147  virtual AlpsReturnStatus encode(AlpsEncoded * encoded) const;
148 
150  virtual AlpsKnowledge * decode(AlpsEncoded & encoded) const;
151 
154  std::cerr << "Not implemented!" << std::endl;
155  throw std::exception();
156  }
157 
158 private:
160  AbcTreeNode(AbcTreeNode const &);
162  AbcTreeNode & operator=(AbcTreeNode const &);
163 
164 };
165 
166 #endif
AbcTreeNode::AbcTreeNode
AbcTreeNode(AbcNodeDesc *&desc)
Definition: AbcTreeNode.h:77
AbcTreeNode::branch
virtual std::vector< CoinTriple< AlpsNodeDesc *, AlpsNodeStatus, double > > branch()
AbcTreeNode::getBranchedDir
int getBranchedDir() const
Definition: AbcTreeNode.h:140
AbcVarStatus
AbcVarStatus
Definition: AbcTreeNode.h:39
AbcTreeNode::setBranchedOnValue
void setBranchedOnValue(double b)
Definition: AbcTreeNode.h:136
AbcNodeDesc.h
AbcTreeNode::getBranchedOn
int getBranchedOn() const
Definition: AbcTreeNode.h:138
AlpsReturnStatus
AlpsReturnStatus
Definition: Alps.h:261
AlpsKnowledgeBroker.h
AbcTreeNode::branchedOnVal_
double branchedOnVal_
The solution value (non-integral) of the branching variable.
Definition: AbcTreeNode.h:53
AbcVarFixedToLB
@ AbcVarFixedToLB
Definition: AbcTreeNode.h:42
AlpsTreeNode::desc_
AlpsNodeDesc * desc_
The actual description of the tree node.
Definition: AlpsTreeNode.h:93
AbcVarFixedToUB
@ AbcVarFixedToUB
Definition: AbcTreeNode.h:41
AbcTreeNode::decodeToSelf
virtual AlpsReturnStatus decodeToSelf(AlpsEncoded &encoded)
Decode the given AlpsEncoded object into this.
Definition: AbcTreeNode.h:153
AbcTreeNode::numberUnsatisfied
int numberUnsatisfied() const
Get the number of objects unsatisfied at this node.
Definition: AbcTreeNode.h:122
AlpsTreeNode::quality_
double quality_
The quality of this node.
Definition: AlpsTreeNode.h:70
AlpsEncoded
Definition: AlpsEncoded.h:64
AbcTreeNode::guessedObjectiveValue_
double guessedObjectiveValue_
Guessed satisfied Objective value.
Definition: AbcTreeNode.h:59
AbcTreeNode::setGuessedObjectiveValue
void setGuessedObjectiveValue(double value)
Definition: AbcTreeNode.h:129
AlpsTreeNode.h
AbcTreeNode::branchedOn_
int branchedOn_
The index of the branching variable.
Definition: AbcTreeNode.h:50
AlpsTreeNode
This class holds one node of the search tree.
Definition: AlpsTreeNode.h:52
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::setBranchedOn
void setBranchedOn(int b)
Definition: AbcTreeNode.h:132
ALPS_BND_MAX
#define ALPS_BND_MAX
Definition: Alps.h:290
AbcTreeNode::operator=
AbcTreeNode & operator=(AbcTreeNode const &)
Disable copy assignment operator.
AbcTreeNode::decode
virtual AlpsKnowledge * decode(AlpsEncoded &encoded) const
Decode the given AlpsEncoded object into a new AbcTreeNode.
AlpsNodeDesc
This is an abstract base class for subproblem data to be stored in a tree node.
Definition: AlpsNodeDesc.h:45
AbcTreeNode::AbcTreeNode
AbcTreeNode()
Definition: AbcTreeNode.h:65
AbcTreeNode::branchedDir_
int branchedDir_
Branching direction.
Definition: AbcTreeNode.h:56
AbcTreeNode::setBranchedDir
void setBranchedDir(int d)
Definition: AbcTreeNode.h:134
AlpsKnowledge
The abstract base class of Alps knowledges generated during the search.
Definition: AlpsKnowledge.h:63
ALPS_OBJ_MAX
#define ALPS_OBJ_MAX
Definition: Alps.h:288
AbcTreeNode::getObjValue
double getObjValue() const
Query/set the objective value (could be approximately or not exit) of the node.
Definition: AbcTreeNode.h:114
AbcTreeNode::setObjValue
void setObjValue(const double objValue)
Definition: AbcTreeNode.h:115
AlpsKnowledge::encode
AlpsEncoded * encode() const
Encode the content of this into an AlpsEncoded object and return a pointer to it.
AbcTreeNode::chooseBranch
int chooseBranch(AbcModel *model, bool &strongFound)
Select the branch variable.
AbcTreeNode
Definition: AbcTreeNode.h:47
AbcNodeDesc
Definition: AbcNodeDesc.h:52
AbcModel
Model class for ALPS Branch and Cut.
Definition: AbcModel.h:59
AbcVarFree
@ AbcVarFree
Definition: AbcTreeNode.h:40
AbcTreeNode::guessedObjectiveValue
double guessedObjectiveValue() const
Guessed objective value (for solution)
Definition: AbcTreeNode.h:126
AbcTreeNode::~AbcTreeNode
virtual ~AbcTreeNode()
Definition: AbcTreeNode.h:92
AbcModel.h
AbcTreeNode::process
virtual int process(bool isRoot=false, bool rampUp=false)
Performing the bounding operation.
AbcTreeNode::getBranchedOnValue
double getBranchedOnValue() const
Definition: AbcTreeNode.h:142
AbcTreeNode::numberUnsatisfied_
int numberUnsatisfied_
The number of objects unsatisfied at this node.
Definition: AbcTreeNode.h:62