22 #ifndef DijkstraRouterEffort_h 23 #define DijkstraRouterEffort_h 65 template<
class E,
class V,
class PF>
69 typedef double(*
Operation)(
const E*
const,
const V*
const, double);
112 return nod1->
edge->getNumericalID() > nod2->
edge->getNumericalID();
123 for (
typename std::vector<E*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
131 for (
typename std::vector<EdgeInfo>::const_iterator i = edgeInfos.begin(); i != edgeInfos.end(); ++i) {
143 inline double getTravelTime(
const E*
const e,
const V*
const v,
double t)
const {
153 for (
typename std::vector<EdgeInfo*>::iterator i =
myFound.begin(); i !=
myFound.end(); i++) {
162 virtual bool compute(
const E* from,
const E* to,
const V*
const vehicle,
163 SUMOTime msTime, std::vector<const E*>& into) {
164 assert(from != 0 && to != 0);
166 if (PF::operator()(from, vehicle)) {
167 myErrorMsgHandler->
inform(
"Vehicle '" + vehicle->getID() +
"' is not allowed on source edge '" + from->getID() +
"'.");
170 if (PF::operator()(to, vehicle)) {
171 myErrorMsgHandler->
inform(
"Vehicle '" + vehicle->getID() +
"' is not allowed on destination edge '" + to->getID() +
"'.");
178 if (toInfo.visited) {
187 fromInfo->effort = 0;
198 const E*
const minEdge = minimumInfo->edge;
201 myFound.push_back(minimumInfo);
208 minimumInfo->visited =
true;
209 const double effort = minimumInfo->effort + this->
getEffort(minEdge, vehicle, minimumInfo->leaveTime);
210 const double leaveTime = minimumInfo->leaveTime +
getTravelTime(minEdge, vehicle, minimumInfo->leaveTime);
212 const std::vector<E*>& successors = minEdge->getSuccessors(vClass);
213 for (
typename std::vector<E*>::const_iterator it = successors.begin(); it != successors.end(); ++it) {
214 const E*
const follower = *it;
217 if (PF::operator()(follower, vehicle)) {
220 const double oldEffort = followerInfo->effort;
221 if (!followerInfo->visited && effort < oldEffort) {
222 followerInfo->effort =
effort;
224 followerInfo->prev = minimumInfo;
237 myErrorMsgHandler->
inform(
"No connection between edge '" + from->getID() +
"' and edge '" + to->getID() +
"' found.");
245 for (
typename std::vector<const E*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
246 if (PF::operator()(*i, v)) {
258 std::vector<const E*> tmp;
259 while (rbegin != 0) {
260 tmp.push_back(rbegin->edge);
261 rbegin = rbegin->prev;
263 std::copy(tmp.rbegin(), tmp.rend(), std::back_inserter(edges));
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
DijkstraRouterEffort(const std::vector< E *> &edges, bool unbuildIsWarning, Operation effortOperation, Operation ttOperation)
Constructor.
double getEffort(const E *const e, const V *const v, double t) const
Computes the shortest path through a network using the Dijkstra algorithm.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
void buildPathFrom(const EdgeInfo *rbegin, std::vector< const E *> &edges)
Builds the path from marked edges.
double getTravelTime(const E *const e, const V *const v, double t) const
std::vector< EdgeInfo > myEdgeInfos
The container of edge information.
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into)
Builds the route between the given edges using the minimum effort at the given time The definition of...
double(* Operation)(const E *const, const V *const, double)
MsgHandler *const myErrorMsgHandler
the handler for routing errors
EdgeInfo(const E *e)
Constructor.
double effort
Effort to reach the edge.
DijkstraRouterEffort(const std::vector< EdgeInfo > &edgeInfos, bool unbuildIsWarning, Operation effortOperation, Operation ttOperation)
const E * edge
The current edge.
bool myBulkMode
whether we are currently operating several route queries in a bulk
std::vector< EdgeInfo * > myFound
list of visited Edges (for resetting)
EdgeInfoByEffortComparator myComparator
Operation myOperation
The object's operation to perform.
bool visited
The previous edge.
double leaveTime
The time the vehicle leaves the edge.
virtual SUMOAbstractRouter< E, V > * clone()
bool operator()(EdgeInfo *nod1, EdgeInfo *nod2) const
Comparing method.
double recomputeCosts(const std::vector< const E *> &edges, const V *const v, SUMOTime msTime) const
void inform(std::string msg, bool addType=true)
adds a new error to the list
void endQuery(int visits)
Operation myTTOperation
The object's operation to perform for travel times.
std::vector< EdgeInfo * > myFrontierList
A container for reusage of the min edge heap.
virtual ~DijkstraRouterEffort()
Destructor.
EdgeInfo * prev
The previous edge.
vehicles ignoring classes