LEMUR Packages: ompl_lemur or_lemur pr_bgl prpy_lemur
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Groups Pages
lazysp_incsp_astar.h
Go to the documentation of this file.
1 
10 namespace pr_bgl
11 {
12 
20 template <class Graph,
21  class HeuristicMap, class PredecessorMap, class DistanceMap,
22  class CostMap, class ColorMap,
23  typename CompareFunction, typename CombineFunction>
25 {
26 public:
27  typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
28  typedef typename boost::graph_traits<Graph>::edge_descriptor Edge;
29  typedef typename boost::property_traits<DistanceMap>::value_type weight_type;
30 
33  {
34  public:
35  Vertex v_throw;
36  throw_visitor(Vertex v_throw): v_throw(v_throw) {}
37  inline void initialize_vertex(Vertex u, const Graph & g) {}
38  inline void discover_vertex(Vertex u, const Graph & g) {}
39  inline void examine_vertex(Vertex u, const Graph & g)
40  {
41  if (u == v_throw)
43  }
44  inline void examine_edge(Edge e, const Graph & g) {}
45  inline void edge_relaxed(Edge e, const Graph & g) {}
46  inline void edge_not_relaxed(Edge e, const Graph & g) {}
47  inline void black_target(Edge e, const Graph & g) {}
48  inline void finish_vertex(Vertex u, const Graph & g) {}
49  };
50 
52  {
53  public:
54  HeuristicMap heuristic_map;
55  map_heuristic(HeuristicMap heuristic_map): heuristic_map(heuristic_map) {}
56  inline weight_type operator()(Vertex u)
57  {
58  return get(heuristic_map, u);
59  }
60  };
61 
62  HeuristicMap heuristic_map;
63  PredecessorMap predecessor_map;
64  DistanceMap distance_map;
65  CostMap cost_map;
66  ColorMap color_map;
67  CompareFunction compare;
68  CombineFunction combine;
69  weight_type inf;
70  weight_type zero;
71 
72  lazysp_incsp_astar(HeuristicMap heuristic_map, PredecessorMap predecessor_map, DistanceMap distance_map,
73  CostMap cost_map, ColorMap color_map,
74  CompareFunction compare, CombineFunction combine,
75  weight_type inf, weight_type zero):
76  heuristic_map(heuristic_map), predecessor_map(predecessor_map), distance_map(distance_map),
77  cost_map(cost_map), color_map(color_map),
78  compare(compare), combine(combine), inf(inf), zero(zero)
79  {}
80 
81  template <typename WMap>
82  weight_type solve(const Graph & g, Vertex v_start, Vertex v_goal,
83  WMap wmap, std::vector<Edge> & path)
84  {
85  try
86  {
87  boost::astar_search(
88  g,
89  v_start,
90  map_heuristic(heuristic_map), // AStarHeuristic h
91  throw_visitor(v_goal), // AStarVisitor vis
92  predecessor_map, // PredecessorMap predecessor
93  cost_map, // CostMap cost
94  distance_map, // DistanceMap distance
95  wmap, // WeightMap weight
96  get(boost::vertex_index, g), // VertexIndexMap index_map
97  color_map, // ColorMap color
98  compare, combine, inf, zero
99  );
100  }
101  catch (const throw_visitor_exception & ex)
102  {
103  }
104 
105  if (get(distance_map,v_goal) == inf)
106  return inf;
107 
108  // get path
109  path.clear();
110  for (Vertex v_walk=v_goal; v_walk!=v_start;)
111  {
112  Vertex v_pred = get(predecessor_map, v_walk);
113  std::pair<Edge,bool> ret = edge(v_pred, v_walk, g);
114  BOOST_ASSERT(ret.second);
115  path.push_back(ret.first);
116  v_walk = v_pred;
117  }
118  std::reverse(path.begin(),path.end());
119 
120  return get(distance_map, v_goal);
121  }
122 
123  void update_notify(Edge e)
124  {
125  }
126 };
127 
128 template <class Graph, class HeuristicMap, class PredecessorMap, class DistanceMap, class CostMap, class ColorMap, typename CompareFunction, typename CombineFunction>
129 lazysp_incsp_astar<Graph,HeuristicMap,PredecessorMap,DistanceMap,CostMap,ColorMap,CompareFunction,CombineFunction>
130 make_lazysp_incsp_astar(HeuristicMap heuristic_map, PredecessorMap predecessor_map, DistanceMap distance_map, CostMap cost_map, ColorMap color_map, CompareFunction compare, CombineFunction combine, typename boost::property_traits<DistanceMap>::value_type inf, typename boost::property_traits<DistanceMap>::value_type zero)
131 {
132  return lazysp_incsp_astar<Graph,HeuristicMap,PredecessorMap,DistanceMap,CostMap,ColorMap,CompareFunction,CombineFunction>(heuristic_map, predecessor_map, distance_map, cost_map, color_map, compare, combine, inf, zero);
133 }
134 
135 } // namespace pr_bgl
Definition: lazysp_incsp_astar.h:32
Definition: lazysp_incsp_astar.h:51
Definition: lazysp_incsp_astar.h:31
Adaptor to use boost::astar_search as the inner sp algorithm for pr_bgl::lazysp.
Definition: lazysp_incsp_astar.h:24