21 template <
class Graph,
class WLazyMap,
class IsEvaledMap>
25 typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
26 typedef typename boost::graph_traits<Graph>::edge_descriptor Edge;
27 typedef typename boost::graph_traits<Graph>::edge_iterator EdgeIter;
29 IsEvaledMap is_evaled_map;
33 boost::mt19937 rand_gen;
34 boost::uniform_01<> rand_dist;
35 boost::variate_generator<boost::mt19937&, boost::uniform_01<> > rand_var;
38 int nsamps, Vertex v_start, Vertex v_goal,
unsigned int seed):
39 w_lazy_map(w_lazy_map), is_evaled_map(is_evaled_map),
40 nsamps(nsamps), v_start(v_start), v_goal(v_goal),
41 rand_gen(seed), rand_var(rand_gen, rand_dist)
47 const std::vector< std::pair<Edge,bool> > & path,
48 std::vector<Edge> & to_evaluate)
50 std::map<Edge, int> edge_counts;
51 for (std::pair<EdgeIter,EdgeIter> ep=edges(g); ep.first!=ep.second; ep.first++)
52 edge_counts[*ep.first] = 0;
55 for (
int i=0; i<nsamps; i++)
58 std::map<Edge, double> w_sampled;
59 for (std::pair<EdgeIter,EdgeIter> ep=edges(g); ep.first!=ep.second; ep.first++)
62 if (
get(is_evaled_map,e))
63 w_sampled[e] =
get(w_lazy_map,e);
66 double randvalue = rand_var();
68 w_sampled[e] = std::numeric_limits<double>::max();
71 w_sampled[e] = 1.0 + randvalue / 0.5;
76 std::map<Vertex,double> wsampled_startdist;
77 std::map<Vertex,Vertex> wsampled_preds;
78 boost::dijkstra_shortest_paths(
81 boost::make_assoc_property_map(wsampled_preds),
82 boost::make_assoc_property_map(wsampled_startdist),
83 boost::make_assoc_property_map(w_sampled),
84 boost::get(boost::vertex_index, g),
86 boost::closed_plus<double>(std::numeric_limits<double>::max()),
87 std::numeric_limits<double>::max(),
89 boost::make_dijkstra_visitor(boost::null_visitor())
92 if (wsampled_startdist[v_goal] == std::numeric_limits<double>::max())
96 Vertex v_cur = v_goal;
97 while (v_cur != v_start)
99 Vertex v_prev = wsampled_preds[v_cur];
100 Edge e = boost::edge(v_prev, v_cur, g).first;
108 for (
unsigned int ui=0; ui<path.size(); ui++)
110 Edge e = path[ui].first;
113 if (count_best <= edge_counts[e])
116 count_best = edge_counts[e];
119 to_evaluate.push_back(e_best);
122 template <
class Edge,
class WeightType>
123 void update_notify(Edge e, WeightType e_weight_old) {}
Shortest-path indicator probability selector for pr_bgl::lazysp.
Definition: lazysp_selector_sp_indicator_probability.h:22