70 template<
class E,
class V,
class PF>
125 return nod1->
edge->getNumericalID() > nod2->
edge->getNumericalID();
132 AStarRouter(
const std::vector<E*>& edges,
bool unbuildIsWarning,
Operation operation,
const LookupTable*
const lookup = 0):
136 for (
typename std::vector<E*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
141 AStarRouter(
const std::vector<EdgeInfo>& edgeInfos,
bool unbuildIsWarning,
Operation operation,
const LookupTable*
const lookup = 0):
145 for (
typename std::vector<EdgeInfo>::const_iterator i = edgeInfos.begin(); i != edgeInfos.end(); ++i) {
160 for (
int i = 0; i < size; i++) {
161 for (
int j = 0; j < size; j++) {
164 (*result)[i].push_back(val);
176 for (
typename std::vector<EdgeInfo*>::iterator i =
myFound.begin(); i !=
myFound.end(); i++) {
184 virtual bool compute(
const E* from,
const E* to,
const V*
const vehicle,
185 SUMOTime msTime, std::vector<const E*>& into) {
186 assert(from != 0 && to != 0);
188 if (PF::operator()(from, vehicle)) {
189 myErrorMsgHandler->
inform(
"Vehicle '" + vehicle->getID() +
"' is not allowed on source edge '" + from->getID() +
"'.");
192 if (PF::operator()(to, vehicle)) {
193 myErrorMsgHandler->
inform(
"Vehicle '" + vehicle->getID() +
"' is not allowed on destination edge '" + to->getID() +
"'.");
201 if (toInfo.visited) {
210 fromInfo->traveltime = 0;
220 const E*
const minEdge = minimumInfo->edge;
229 myFound.push_back(minimumInfo);
230 minimumInfo->visited =
true;
233 const SUMOReal heuristic_remaining =
myLookupTable == 0 ? minEdge->getDistanceTo(to) / vehicle->getMaxSpeed() : (*myLookupTable)[minEdge->getNumericalID()][to->getNumericalID()] / vehicle->getChosenSpeedFactor();
235 const std::vector<E*>& successors = minEdge->getSuccessors(vClass);
236 for (
typename std::vector<E*>::const_iterator it = successors.begin(); it != successors.end(); ++it) {
237 const E*
const follower = *it;
240 if (PF::operator()(follower, vehicle)) {
243 const SUMOReal oldEffort = followerInfo->traveltime;
244 if (!followerInfo->visited && traveltime < oldEffort) {
246 followerInfo->heuristicTime = traveltime + heuristic_remaining;
258 followerInfo->prev = minimumInfo;
271 myErrorMsgHandler->
inform(
"No connection between edge '" + from->getID() +
"' and edge '" + to->getID() +
"' found.");
279 for (
typename std::vector<const E*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
280 if (PF::operator()(*i, v)) {
283 costs += this->
getEffort(*i, v, time + costs);
291 std::vector<const E*> tmp;
292 while (rbegin != 0) {
293 tmp.push_back(rbegin->edge);
294 rbegin = rbegin->prev;
296 std::copy(tmp.rbegin(), tmp.rend(), std::back_inserter(edges));
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
SUMOReal recomputeCosts(const std::vector< const E *> &edges, const V *const v, SUMOTime msTime) const
static LookupTable * createLookupTable(const std::string &filename, const int size)
AStarRouter(const std::vector< EdgeInfo > &edgeInfos, bool unbuildIsWarning, Operation operation, const LookupTable *const lookup=0)
bool visited
The previous edge.
std::vector< EdgeInfo > myEdgeInfos
The container of edge information.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
std::vector< EdgeInfo * > myFrontierList
A container for reusage of the min edge heap.
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 travel time.
EdgeInfoComparator myComparator
std::vector< std::vector< SUMOReal > > LookupTable
MsgHandler *const myErrorMsgHandler
the handler for routing errors
Computes the shortest path through a network using the A* algorithm.
AStarRouter(const std::vector< E *> &edges, bool unbuildIsWarning, Operation operation, const LookupTable *const lookup=0)
Constructor.
EdgeInfo * prev
The previous edge.
virtual SUMOAbstractRouter< E, V > * clone()
EdgeInfo(const E *e)
Constructor.
virtual ~AStarRouter()
Destructor.
bool myBulkMode
whether we are currently operating several route queries in a bulk
void buildPathFrom(const EdgeInfo *rbegin, std::vector< const E *> &edges)
Builds the path from marked edges.
Operation myOperation
The object's operation to perform.
SUMOReal getEffort(const E *const e, const V *const v, SUMOReal t) const
bool operator()(const EdgeInfo *nod1, const EdgeInfo *nod2) const
Comparing method.
SUMOReal heuristicTime
Estimated time to reach the edge (traveltime + lower bound on remaining time)
void inform(std::string msg, bool addType=true)
adds a new error to the list
void endQuery(int visits)
const LookupTable *const myLookupTable
the lookup table for travel time heuristics
SUMOReal traveltime
Effort to reach the edge.
std::vector< EdgeInfo * > myFound
list of visited Edges (for resetting)
vehicles ignoring classes
SUMOReal(* Operation)(const E *const, const V *const, SUMOReal)
const E * edge
The current edge.