libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
BaseExpansion.hpp
1 /*
2  * BaseExpansion.hpp
3  *
4  * Created on: Jun 11, 2009
5  * Author: jmainpri
6  */
7 #ifndef P3D_BASE_EXPANSION_HPP
8 #define P3D_BASE_EXPANSION_HPP
9 
10 #include "API/ConfigSpace/configuration.hpp"
11 
12 #include "../p3d/env.hpp"
13 
14 #ifndef LOCALPATH_HPP
15 class LocalPath;
16 #endif
17 
18 #ifndef GRAPH_HPP
19 class Graph;
20 #endif
21 
22 #ifndef NODE_HPP
23 class Node;
24 #endif
25 
35 {
36 public:
37 
41  BaseExpansion();
42  BaseExpansion(Graph* prtGraph);
43 
48 
52  void setGraph(Graph* G) { m_Graph = G; }
53 
57  Graph* getGraph() { return m_Graph; }
58 
62  int getDirectionMethod() { return m_ExpansionDirectionMethod; }
63 
67  void setDirectionMethod(int directionExpansion) { m_ExpansionDirectionMethod = directionExpansion; }
68 
72  int getNodeMethod() { return m_ExpansionNodeMethod; }
73 
77  void setNodeMethod(int nodeExpansion) { m_ExpansionNodeMethod = nodeExpansion; }
78 
82  void setFromComp(Node* fromComp) { m_fromComp = fromComp; }
83 
87  Node* getFromComp() { return m_fromComp; }
88 
92  void setToComp(Node* toComp) { m_toComp = toComp; }
93 
97  Node* getToComp() { return m_toComp; }
98 
102  double step();
103 
104  double getDMax();
105 
107  double computeInterpolationFactor(double pathLength) {
108  return (pathLength == 0.) ? 1. : std::min(1., this->step() / pathLength );
109  }
110 
112  confPtr_t interpolate(confPtr_t conf, LocalPath * path, double factor);
113 
117  double positionAlongPath(LocalPath& path, double param);
118 
123  double pathDelta(LocalPath& path);
124 
129  LocalPath getExtensiontPath(std::tr1::shared_ptr<Configuration> qi,
130  std::tr1::shared_ptr<Configuration> qf );
131 
136  void expansionFailed(Node& node);
137 
141  virtual Node* addNode(Node* currentNode, LocalPath& path, double pathDelta,
142  Node* directionNode, unsigned& nbCreatedNodes);
143 
147  bool refinementControl(LocalPath& path, double rho, Node& compNode);
148 
152  bool nextStep(LocalPath& path,
153  std::tr1::shared_ptr<Configuration>& directionConfig,
154  double& pathDelta,
155  std::tr1::shared_ptr<LocalPath>& newPath,
156  Env::expansionMethod method);
157 
161  bool nextStep(LocalPath& path,
162  Node* directionNode,
163  double& pathDelta,
164  std::tr1::shared_ptr<LocalPath>& newPath,
165  Env::expansionMethod method);
166 
174  virtual Node* getExpansionNode(Node* compNode, confPtr_t direction, int distance);
175 
176  std::tr1::shared_ptr<Configuration> getExpansionDirection(Node* expandComp, Node* goalComp,
177  bool samplePassive, Node*& directionNode);
178 
181  return m_last_added_node;
182  }
183 
184  void addConnectibleNode(){
185  _nbConnectibleNodes++;
186  }
187 
188  unsigned int getNbConnectibleNodes(){
189  return _nbConnectibleNodes;
190  }
191 
192 protected:
193 
194  int m_ExpansionNodeMethod;
195  int m_MaxExpandNodeFailure;
196  int m_kNearestPercent;
197 
198  int m_ExpansionDirectionMethod; // = GLOBAL_CS_EXP;
199  bool m_IsDirSampleWithRlg; //= FALSE;
200 
201  Graph* m_Graph;
202 
203  Node* m_last_added_node;
204 
205  Node* m_fromComp;
206  Node* m_toComp;
207 
208  unsigned int _nbConnectibleNodes;
209 };
210 
211 #endif
void setToComp(Node *toComp)
Set the To Connected Component.
Definition: BaseExpansion.hpp:92
double positionAlongPath(LocalPath &path, double param)
Position on localpath in [0,1].
Definition: BaseExpansion.cpp:69
Classe représentant un Node d'un Graph.
Definition: node.hpp:39
void setDirectionMethod(int directionExpansion)
Set Expansion node Method.
Definition: BaseExpansion.hpp:67
Classe représentant un chemin local.
Definition: localpath.hpp:15
virtual Node * getExpansionNode(Node *compNode, confPtr_t direction, int distance)
Gets the nearest node in the graph.
Definition: BaseExpansion.cpp:253
void setFromComp(Node *fromComp)
Set the From Connected Component.
Definition: BaseExpansion.hpp:82
Definition: graph.hpp:28
Node * getLasAddedNode()
Return last added node.
Definition: BaseExpansion.hpp:180
int getDirectionMethod()
Get Node Expansion Method.
Definition: BaseExpansion.hpp:62
int getNodeMethod()
Get Node Expansion Method.
Definition: BaseExpansion.hpp:72
The expansion class holds the method and local variables allowing to expand a Tree in a given configu...
Definition: BaseExpansion.hpp:34
~BaseExpansion()
Destructor.
Definition: BaseExpansion.cpp:48
Node * getFromComp()
Get the From Connected Component.
Definition: BaseExpansion.hpp:87
void setGraph(Graph *G)
Set the graph that is beeing expanded.
Definition: BaseExpansion.hpp:52
void setNodeMethod(int nodeExpansion)
Set Expansion node Method.
Definition: BaseExpansion.hpp:77
LocalPath getExtensiontPath(std::tr1::shared_ptr< Configuration > qi, std::tr1::shared_ptr< Configuration > qf)
Computes a localpath parameter used for expansion of at max step() of length.
Definition: BaseExpansion.cpp:91
virtual Node * addNode(Node *currentNode, LocalPath &path, double pathDelta, Node *directionNode, unsigned &nbCreatedNodes)
Adds a node to a connected component.
Definition: BaseExpansion.cpp:235
double step()
Expansion Step (Delta)
Definition: BaseExpansion.cpp:53
double computeInterpolationFactor(double pathLength)
Compute the interpolation factor along the path, based on the extension step.
Definition: BaseExpansion.hpp:107
confPtr_t interpolate(confPtr_t conf, LocalPath *path, double factor)
Interpolation along the given path.
Definition: BaseExpansion.cpp:64
double pathDelta(LocalPath &path)
Return the path parameter that is the closest to step()
Definition: BaseExpansion.cpp:79
Node * getToComp()
Get the To Connected Component.
Definition: BaseExpansion.hpp:97
void expansionFailed(Node &node)
Function called when a node can not be connected.
Definition: BaseExpansion.cpp:140
bool nextStep(LocalPath &path, std::tr1::shared_ptr< Configuration > &directionConfig, double &pathDelta, std::tr1::shared_ptr< LocalPath > &newPath, Env::expansionMethod method)
Returns a valid configuration on the local path.
Graph * getGraph()
Get the graph that is beeing expanded.
Definition: BaseExpansion.hpp:57
BaseExpansion()
Constructor.
Definition: BaseExpansion.cpp:21
bool refinementControl(LocalPath &path, double rho, Node &compNode)
Function that balances the ratio of exploration towards refinement.
Definition: BaseExpansion.cpp:105