20 template <
class Graph,
class WMap,
21 class HeuristicMap,
class PredecessorMap,
class DistanceMap,
class DistanceLookaheadMap,
22 typename CompareFunction,
typename CombineFunction>
26 typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
27 typedef typename boost::graph_traits<Graph>::edge_descriptor Edge;
28 typedef typename boost::property_traits<WMap>::value_type weight_type;
29 typedef typename boost::property_map<Graph, boost::vertex_index_t>::type VIndexMap;
34 HeuristicMap heuristic_map;
35 map_heuristic(HeuristicMap heuristic_map): heuristic_map(heuristic_map) {}
36 inline weight_type operator()(Vertex u)
38 return get(heuristic_map, u);
46 PredecessorMap predecessor_map;
47 DistanceMap distance_map;
53 boost::astar_visitor<boost::null_visitor>,
59 CompareFunction, CombineFunction,
60 weight_type, weight_type
64 Graph & g, Vertex v_start, Vertex v_goal, WMap w_map,
65 HeuristicMap heuristic_map,
66 PredecessorMap predecessor_map, DistanceMap distance_map,
67 DistanceLookaheadMap distance_lookahead_map,
68 weight_type goal_margin,
69 CompareFunction compare, CombineFunction combine,
70 weight_type inf, weight_type zero):
71 g(g), v_start(v_start), v_goal(v_goal), w_map(w_map),
72 predecessor_map(predecessor_map),
73 distance_map(distance_map),
77 boost::make_astar_visitor(boost::null_visitor()),
80 distance_lookahead_map,
82 get(boost::vertex_index, g),
83 compare, combine, inf, zero,
88 weight_type solve(
const Graph & g, Vertex v_start, Vertex v_goal,
89 WMap wmap, std::vector<Edge> & path)
92 lpastar.compute_shortest_path();
95 if (
get(distance_map,v_goal) == inf)
100 for (Vertex v_walk=v_goal; v_walk!=v_start;)
102 Vertex v_pred =
get(predecessor_map,v_walk);
103 std::pair<Edge,bool> ret = edge(v_pred, v_walk, g);
104 BOOST_ASSERT(ret.second);
105 path.push_back(ret.first);
108 std::reverse(path.begin(),path.end());
110 return get(distance_map,v_goal);
113 void update_notify(Edge euv)
115 Vertex u = source(euv,g);
116 Vertex v = target(euv,g);
118 weight_type wuv =
get(w_map,euv);
119 lpastar.update_predecessor(u, v, wuv);
120 lpastar.update_vertex(v);
122 Edge evu = edge(v,u,g).first;
123 weight_type wvu =
get(w_map,evu);
124 lpastar.update_predecessor(v, u, wvu);
125 lpastar.update_vertex(u);
129 template <
class Graph,
class WMap,
class HeuristicMap,
class PredecessorMap,
class DistanceMap,
class DistanceLookaheadMap,
typename CompareFunction,
typename CombineFunction>
130 lazysp_incsp_lpastar<Graph,WMap,HeuristicMap,PredecessorMap,DistanceMap,DistanceLookaheadMap,CompareFunction,CombineFunction>
131 make_lazysp_incsp_lpastar(
133 typename boost::graph_traits<Graph>::vertex_descriptor v_start,
134 typename boost::graph_traits<Graph>::vertex_descriptor v_goal,
135 WMap w_map, HeuristicMap heuristic_map,
136 PredecessorMap predecessor_map, DistanceMap distance_map,
137 DistanceLookaheadMap distance_lookahead_map,
138 typename boost::property_traits<WMap>::value_type goal_margin,
139 CompareFunction compare, CombineFunction combine,
140 typename boost::property_traits<WMap>::value_type inf,
141 typename boost::property_traits<WMap>::value_type zero)
143 return lazysp_incsp_lpastar<Graph,WMap,HeuristicMap,PredecessorMap,DistanceMap,DistanceLookaheadMap,CompareFunction,CombineFunction>(
144 g, v_start, v_goal, w_map, heuristic_map, predecessor_map, distance_map, distance_lookahead_map, goal_margin, compare, combine, inf, zero);
153 template <
class Graph,
class WMap,
154 class HeuristicMap,
class PredecessorMap,
class DistanceMap,
class DistanceLookaheadMap,
155 typename CompareFunction,
typename CombineFunction>
159 typedef typename boost::reverse_graph<Graph, Graph&> RevGraph;
160 typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
161 typedef typename boost::graph_traits<Graph>::edge_descriptor Edge;
162 typedef typename boost::property_traits<WMap>::value_type weight_type;
163 typedef typename boost::property_map<Graph, boost::vertex_index_t>::type VIndexMap;
168 HeuristicMap heuristic_map;
169 map_heuristic(HeuristicMap heuristic_map): heuristic_map(heuristic_map) {}
170 inline weight_type operator()(Vertex u)
172 return get(heuristic_map, u);
181 PredecessorMap predecessor_map;
182 DistanceMap distance_map;
189 boost::astar_visitor<boost::null_visitor>,
192 DistanceLookaheadMap,
194 boost::detail::reverse_graph_edge_property_map<WMap>,
196 CompareFunction, CombineFunction,
197 weight_type, weight_type
201 Graph & g, Vertex v_start, Vertex v_goal, WMap w_map,
202 HeuristicMap heuristic_map,
203 PredecessorMap predecessor_map, DistanceMap distance_map,
204 DistanceLookaheadMap distance_lookahead_map,
205 weight_type goal_margin,
206 CompareFunction compare, CombineFunction combine,
207 weight_type inf, weight_type zero):
208 g(g), rg(g), v_start(v_start), v_goal(v_goal), w_map(w_map),
209 predecessor_map(predecessor_map),
210 distance_map(distance_map),
215 boost::make_astar_visitor(boost::null_visitor()),
218 distance_lookahead_map,
220 boost::detail::reverse_graph_edge_property_map<WMap>(w_map),
221 get(boost::vertex_index, g),
222 compare, combine, inf, zero,
227 weight_type solve(
const Graph & g, Vertex v_start, Vertex v_goal,
228 WMap wmap, std::vector<Edge> & path)
231 lpastar.compute_shortest_path();
234 if (
get(distance_map,v_start) == inf)
239 for (Vertex v_walk=v_start; v_walk!=v_goal;)
241 Vertex v_succ =
get(predecessor_map,v_walk);
242 std::pair<Edge,bool> ret = edge(v_walk, v_succ, g);
243 BOOST_ASSERT(ret.second);
244 path.push_back(ret.first);
248 return get(distance_map,v_start);
251 void update_notify(Edge euv)
253 Vertex u = source(euv,g);
254 Vertex v = target(euv,g);
256 weight_type wuv =
get(w_map,euv);
257 lpastar.update_predecessor(u, v, wuv);
258 lpastar.update_vertex(v);
260 Edge evu = edge(v,u,g).first;
261 weight_type wvu =
get(w_map,evu);
262 lpastar.update_predecessor(v, u, wvu);
263 lpastar.update_vertex(u);
267 template <
class Graph,
class WMap,
class HeuristicMap,
class PredecessorMap,
class DistanceMap,
class DistanceLookaheadMap,
typename CompareFunction,
typename CombineFunction>
268 lazysp_incsp_rlpastar<Graph,WMap,HeuristicMap,PredecessorMap,DistanceMap,DistanceLookaheadMap,CompareFunction,CombineFunction>
269 make_lazysp_incsp_rlpastar(
271 typename boost::graph_traits<Graph>::vertex_descriptor v_start,
272 typename boost::graph_traits<Graph>::vertex_descriptor v_goal,
273 WMap w_map, HeuristicMap heuristic_map,
274 PredecessorMap predecessor_map, DistanceMap distance_map,
275 DistanceLookaheadMap distance_lookahead_map,
276 typename boost::property_traits<WMap>::value_type goal_margin,
277 CompareFunction compare, CombineFunction combine,
278 typename boost::property_traits<WMap>::value_type inf,
279 typename boost::property_traits<WMap>::value_type zero)
281 return lazysp_incsp_rlpastar<Graph,WMap,HeuristicMap,PredecessorMap,DistanceMap,DistanceLookaheadMap,CompareFunction,CombineFunction>(
282 g, v_start, v_goal, w_map, heuristic_map, predecessor_map, distance_map, distance_lookahead_map, goal_margin, compare, combine, inf, zero);
Implements the Lifelong Planning A* incremental search algorithm.
Definition: lpastar.h:34
Definition: lazysp_incsp_lpastar.h:31
Definition: lazysp_incsp_lpastar.h:156
Adaptor to use pr_bgl::lpastar as the inner sp algorithm for pr_bgl::lazysp.
Definition: lazysp_incsp_lpastar.h:23
Definition: lazysp_incsp_lpastar.h:165