22 #ifndef DijkstraRouterTT_h
23 #define DijkstraRouterTT_h
70 template<
class E,
class V,
class PF>
79 for (
size_t i = 0; i < noE; i++) {
129 return nod1->
edge->getNumericalID() > nod2->
edge->getNumericalID();
141 for (
typename std::vector<EdgeInfo*>::iterator i =
myFound.begin(); i !=
myFound.end(); i++) {
150 virtual void compute(
const E* from,
const E* to,
const V*
const vehicle,
151 SUMOTime msTime, std::vector<const E*>& into) {
152 assert(from != 0 && (vehicle == 0 || to != 0));
157 const EdgeInfo& toInfo =
myEdgeInfos[to->getNumericalID()];
158 if (toInfo.visited) {
166 EdgeInfo*
const fromInfo = &(
myEdgeInfos[from->getNumericalID()]);
167 fromInfo->traveltime = 0;
177 const E*
const minEdge = minimumInfo->edge;
182 #ifdef DijkstraRouterTT_DEBUG_QUERY_PERF
183 std::cout <<
"visited " +
toString(num_visited) +
" edges (final path length: " +
toString(into.size()) +
")\n";
189 myFound.push_back(minimumInfo);
190 minimumInfo->visited =
true;
191 #ifdef DijkstraRouterTT_DEBUG_QUERY
192 std::cout <<
"DEBUG: hit '" << minEdge->getID() <<
"' TT: " << minimumInfo->traveltime <<
" Q: ";
194 std::cout << (*it)->traveltime <<
"," << (*it)->edge->getID() <<
" ";
198 const SUMOReal traveltime = minimumInfo->traveltime + this->
getEffort(minEdge, vehicle, time + minimumInfo->traveltime);
200 const std::vector<E*>& successors = minEdge->getSuccessors(vClass);
201 for (
typename std::vector<E*>::const_iterator it = successors.begin(); it != successors.end(); ++it) {
202 const E*
const follower = *it;
203 EdgeInfo*
const followerInfo = &(
myEdgeInfos[follower->getNumericalID()]);
205 if (PF::operator()(follower, vehicle)) {
208 const SUMOReal oldEffort = followerInfo->traveltime;
209 if (!followerInfo->visited && traveltime < oldEffort) {
210 followerInfo->traveltime = traveltime;
211 followerInfo->prev = minimumInfo;
224 #ifdef DijkstraRouterTT_DEBUG_QUERY_PERF
225 std::cout <<
"visited " +
toString(num_visited) +
" edges (final path length: " +
toString(into.size()) +
")\n";
236 for (
typename std::vector<const E*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
237 if (PF::operator()(*i, v)) {
240 costs += this->
getEffort(*i, v, time + costs);
248 std::vector<const E*> tmp;
249 while (rbegin != 0) {
250 tmp.push_back(rbegin->edge);
251 rbegin = rbegin->prev;
253 std::copy(tmp.rbegin(), tmp.rend(), std::back_inserter(edges));
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
EdgeInfo(size_t id)
Constructor.
virtual ~DijkstraRouterTT()
Destructor.
SUMOReal recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime) const
bool visited
The previous edge.
virtual void 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...
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
const E * edge
The current edge.
SUMOReal(* Operation)(const E *const, const V *const, SUMOReal)
const EdgeInfo & getEdgeInfo(size_t index) const
Computes the shortest path through a network using the Dijkstra algorithm.
void buildPathFrom(const EdgeInfo *rbegin, std::vector< const E * > &edges)
Builds the path from marked edges.
SUMOReal traveltime
Effort to reach the edge.
bool operator()(const EdgeInfo *nod1, const EdgeInfo *nod2) const
Comparing method.
MsgHandler *const myErrorMsgHandler
the handler for routing errors
bool myBulkMode
whether we are currently operating several route queries in a bulk
EdgeInfoByTTComparator myComparator
Operation myOperation
The object's operation to perform.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
std::vector< EdgeInfo * > myFound
list of visited Edges (for resetting)
std::vector< EdgeInfo > myEdgeInfos
The container of edge information.
virtual SUMOAbstractRouter< E, V > * clone() const
void inform(std::string msg, bool addType=true)
adds a new error to the list
std::vector< EdgeInfo * > myFrontierList
A container for reusage of the min edge heap.
void endQuery(int visits)
EdgeInfo * prev
The previous edge.
DijkstraRouterTT(size_t noE, bool unbuildIsWarning, Operation operation)
Constructor.
SUMOReal getEffort(const E *const e, const V *const v, SUMOReal t) const
vehicles ignoring classes