Re: [Boost-users] [BGL]Using a function for weightmap to dijkstra_shortest_path
-----Original Message----- From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Amit Prakash Ambasta Sent: 23 November 2015 08:20 To: boost-users@lists.boost.org Subject: [Boost-users] [BGL]Using a function for weightmap to dijkstra_shortest_path
Hi,
I am trying to write use BGL.dijkstra to calculate a shortest path in a time dependent network where edge.cost C(u, v) is a function of distance@edge.source and a variable wait time dependent on Edge.departure i.e.
Are you confident that you can use Dijkstra Shortest Paths for this? To me it seems that would only be possible if you knew that delay times are increasing over time, but not when they are fluctuating up and down. The code might be simpler if you put the dynamic part in the combine functor instead of the weight map. using Time = double; using Money = double; struct Distance { Time time; Money cost; }; struct Weight { Time duration; Money cost; Time delay(cost Time& start) const { // delay as a function of start time } }; struct Combine { Distance operator()(const Distance& start, const Weight& weight) const { Distance finish; finish.time = start.time + weight.delay(start.time) + weight.duration; finish.cost = start.cost + weight.cost; return finish; } };
You're correct. Dijkstra doesn't seem like the solution in this case. Using
r_c_shortest paths instead. Is there a parallel version of
r_c_shortest_paths in boost though? I could not find any implementation in
parallel-bgl
On Wed, Nov 25, 2015 at 5:25 PM alex
-----Original Message----- From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Amit Prakash Ambasta Sent: 23 November 2015 08:20 To: boost-users@lists.boost.org Subject: [Boost-users] [BGL]Using a function for weightmap to dijkstra_shortest_path
Hi,
I am trying to write use BGL.dijkstra to calculate a shortest path in a time dependent network where edge.cost C(u, v) is a function of distance@edge.source and a variable wait time dependent on Edge.departure i.e.
Are you confident that you can use Dijkstra Shortest Paths for this? To me it seems that would only be possible if you knew that delay times are increasing over time, but not when they are fluctuating up and down.
The code might be simpler if you put the dynamic part in the combine functor instead of the weight map.
using Time = double; using Money = double;
struct Distance { Time time; Money cost; };
struct Weight { Time duration; Money cost;
Time delay(cost Time& start) const { // delay as a function of start time } };
struct Combine { Distance operator()(const Distance& start, const Weight& weight) const { Distance finish; finish.time = start.time + weight.delay(start.time) + weight.duration; finish.cost = start.cost + weight.cost; return finish; } };
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
alex
-
Amit Prakash Ambasta