22 #ifndef DijkstraRouterTT_h
23 #define DijkstraRouterTT_h
70 template<
class E,
class V,
class PF>
114 return nod1->
edge->getNumericalID() > nod2->
edge->getNumericalID();
124 for (
typename std::vector<E*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
132 for (
typename std::vector<EdgeInfo>::const_iterator i = edgeInfos.begin(); i != edgeInfos.end(); ++i) {
150 for (
typename std::vector<EdgeInfo*>::iterator i =
myFound.begin(); i !=
myFound.end(); i++) {
159 virtual bool compute(
const E* from,
const E* to,
const V*
const vehicle,
160 SUMOTime msTime, std::vector<const E*>& into) {
161 assert(from != 0 && (vehicle == 0 || to != 0));
163 if (PF::operator()(from, vehicle)) {
164 myErrorMsgHandler->
inform(
"Vehicle '" + vehicle->getID() +
"' is not allowed on source edge '" + from->getID() +
"'.");
167 if (PF::operator()(to, vehicle)) {
168 myErrorMsgHandler->
inform(
"Vehicle '" + vehicle->getID() +
"' is not allowed on destination edge '" + to->getID() +
"'.");
175 const EdgeInfo& toInfo =
myEdgeInfos[to->getNumericalID()];
176 if (toInfo.visited) {
184 EdgeInfo*
const fromInfo = &(
myEdgeInfos[from->getNumericalID()]);
185 fromInfo->traveltime = 0;
195 const E*
const minEdge = minimumInfo->edge;
200 #ifdef DijkstraRouterTT_DEBUG_QUERY_PERF
201 std::cout <<
"visited " +
toString(num_visited) +
" edges (final path length: " +
toString(into.size()) +
")\n";
207 myFound.push_back(minimumInfo);
208 minimumInfo->visited =
true;
209 #ifdef DijkstraRouterTT_DEBUG_QUERY
210 std::cout <<
"DEBUG: hit '" << minEdge->getID() <<
"' TT: " << minimumInfo->traveltime <<
" Q: ";
212 std::cout << (*it)->traveltime <<
"," << (*it)->edge->getID() <<
" ";
216 const SUMOReal traveltime = minimumInfo->traveltime + this->
getEffort(minEdge, vehicle, time + minimumInfo->traveltime);
218 const std::vector<E*>& successors = minEdge->getSuccessors(vClass);
219 for (
typename std::vector<E*>::const_iterator it = successors.begin(); it != successors.end(); ++it) {
220 const E*
const follower = *it;
221 EdgeInfo*
const followerInfo = &(
myEdgeInfos[follower->getNumericalID()]);
223 if (PF::operator()(follower, vehicle)) {
226 const SUMOReal oldEffort = followerInfo->traveltime;
227 if (!followerInfo->visited && traveltime < oldEffort) {
228 followerInfo->traveltime = traveltime;
229 followerInfo->prev = minimumInfo;
242 #ifdef DijkstraRouterTT_DEBUG_QUERY_PERF
243 std::cout <<
"visited " +
toString(num_visited) +
" edges (final path length: " +
toString(into.size()) +
")\n";
246 myErrorMsgHandler->
inform(
"No connection between edge '" + from->getID() +
"' and edge '" + to->getID() +
"' found.");
255 for (
typename std::vector<const E*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
256 if (PF::operator()(*i, v)) {
259 costs += this->
getEffort(*i, v, time + costs);
267 std::vector<const E*> tmp;
268 while (rbegin != 0) {
269 tmp.push_back(rbegin->edge);
270 rbegin = rbegin->prev;
272 std::copy(tmp.rbegin(), tmp.rend(), std::back_inserter(edges));
const EdgeInfo & getEdgeInfo(int index) const
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
virtual ~DijkstraRouterTT()
Destructor.
SUMOReal recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime) const
DijkstraRouterTT(const std::vector< E * > &edges, bool unbuildIsWarning, Operation operation)
Constructor.
bool visited
The previous edge.
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)
EdgeInfo(const E *e)
Constructor.
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)
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...
std::vector< EdgeInfo * > myFound
list of visited Edges (for resetting)
std::vector< EdgeInfo > myEdgeInfos
The container of edge information.
void inform(std::string msg, bool addType=true)
adds a new error to the list
virtual SUMOAbstractRouter< E, V > * clone()
std::vector< EdgeInfo * > myFrontierList
A container for reusage of the min edge heap.
void endQuery(int visits)
EdgeInfo * prev
The previous edge.
SUMOReal getEffort(const E *const e, const V *const v, SUMOReal t) const
vehicles ignoring classes
DijkstraRouterTT(const std::vector< EdgeInfo > &edgeInfos, bool unbuildIsWarning, Operation operation)