22 #ifndef DijkstraRouterTT_h 23 #define DijkstraRouterTT_h 70 template<
class E,
class V,
class PF>
74 typedef double(*
Operation)(
const E*
const,
const V*
const, double);
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() +
"'.");
172 #ifdef DijkstraRouterTT_DEBUG_QUERY 173 std::cout <<
"DEBUG: starting search for '" << vehicle->getID() <<
"' time: " <<
STEPS2TIME(msTime) <<
"\n";
179 if (toInfo.visited) {
188 fromInfo->traveltime = 0;
198 const E*
const minEdge = minimumInfo->edge;
203 #ifdef DijkstraRouterTT_DEBUG_QUERY_PERF 204 std::cout <<
"visited " +
toString(num_visited) +
" edges (final path length=" +
toString(into.size()) +
" edges=" +
toString(into) +
")\n";
210 myFound.push_back(minimumInfo);
211 minimumInfo->visited =
true;
212 #ifdef DijkstraRouterTT_DEBUG_QUERY 213 std::cout <<
"DEBUG: hit '" << minEdge->getID() <<
"' TT: " << minimumInfo->traveltime <<
" Q: ";
215 std::cout << (*it)->traveltime <<
"," << (*it)->edge->getID() <<
" ";
219 const double traveltime = minimumInfo->traveltime + this->
getEffort(minEdge, vehicle, time + minimumInfo->traveltime);
221 const std::vector<E*>& successors = minEdge->getSuccessors(vClass);
222 for (
typename std::vector<E*>::const_iterator it = successors.begin(); it != successors.end(); ++it) {
223 const E*
const follower = *it;
226 if (PF::operator()(follower, vehicle)) {
229 const double oldEffort = followerInfo->traveltime;
230 if (!followerInfo->visited && traveltime < oldEffort) {
232 followerInfo->prev = minimumInfo;
245 #ifdef DijkstraRouterTT_DEBUG_QUERY_PERF 246 std::cout <<
"visited " +
toString(num_visited) +
" edges (unsuccesful path length: " +
toString(into.size()) +
")\n";
249 myErrorMsgHandler->
inform(
"No connection between edge '" + from->getID() +
"' and edge '" + to->getID() +
"' found.");
258 for (
typename std::vector<const E*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
259 if (PF::operator()(*i, v)) {
262 costs += this->
getEffort(*i, v, time + costs);
270 std::vector<const E*> tmp;
271 while (rbegin != 0) {
272 tmp.push_back(rbegin->edge);
273 rbegin = rbegin->prev;
275 std::copy(tmp.rbegin(), tmp.rend(), std::back_inserter(edges));
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
double getEffort(const E *const e, const V *const v, double t) const
virtual ~DijkstraRouterTT()
Destructor.
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.
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.
MsgHandler *const myErrorMsgHandler
the handler for routing errors
const EdgeInfo & getEdgeInfo(int index) const
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double traveltime
Effort to reach the edge.
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...
bool myBulkMode
whether we are currently operating several route queries in a bulk
double(* Operation)(const E *const, const V *const, double)
EdgeInfoByTTComparator myComparator
Operation myOperation
The object's operation to perform.
std::vector< EdgeInfo * > myFound
list of visited Edges (for resetting)
std::vector< EdgeInfo > myEdgeInfos
The container of edge information.
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
virtual SUMOAbstractRouter< E, V > * clone()
DijkstraRouterTT(const std::vector< E *> &edges, bool unbuildIsWarning, Operation operation)
Constructor.
std::vector< EdgeInfo * > myFrontierList
A container for reusage of the min edge heap.
void endQuery(int visits)
EdgeInfo * prev
The previous edge.
vehicles ignoring classes
DijkstraRouterTT(const std::vector< EdgeInfo > &edgeInfos, bool unbuildIsWarning, Operation operation)
bool operator()(const EdgeInfo *nod1, const EdgeInfo *nod2) const
Comparing method.