 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
18 #ifndef SUMOAbstractRouter_h
19 #define SUMOAbstractRouter_h
45 template<
class E,
class V>
57 :
edge(e),
effort(std::numeric_limits<double>::max()),
84 effort = std::numeric_limits<double>::max();
96 typedef double(*
Operation)(
const E*
const,
const V*
const, double);
100 const bool havePermissions,
const bool haveRestrictions) :
125 virtual bool compute(
const E* from,
const E* to,
const V*
const vehicle,
126 SUMOTime msTime, std::vector<const E*>& into,
bool silent =
false) = 0;
130 inline bool computeLooped(
const E* from,
const E* to,
const V*
const vehicle,
131 SUMOTime msTime, std::vector<const E*>& into,
bool silent =
false) {
133 return compute(from, to, vehicle, msTime, into, silent);
135 double minEffort = std::numeric_limits<double>::max();
136 std::vector<const E*> best;
138 for (
const std::pair<const E*, const E*>& follower : from->getViaSuccessors(vClass)) {
139 std::vector<const E*> tmp;
140 compute(follower.first, to, vehicle, msTime, tmp,
true);
141 if (tmp.size() > 0) {
143 if (effort < minEffort) {
149 if (minEffort != std::numeric_limits<double>::max()) {
150 into.push_back(from);
151 std::copy(best.begin(), best.end(), std::back_inserter(into));
159 inline bool isProhibited(
const E*
const edge,
const V*
const vehicle)
const {
165 inline double getTravelTime(
const E*
const e,
const V*
const v,
const double t,
const double effort)
const {
166 return myTTOperation ==
nullptr ? effort : (*myTTOperation)(e, v, t);
169 inline void updateViaEdgeCost(
const E* viaEdge,
const V*
const v,
double& time,
double& effort,
double& length)
const {
170 while (viaEdge !=
nullptr && viaEdge->isInternal()) {
171 const double viaEffortDelta = this->
getEffort(viaEdge, v, time);
173 effort += viaEffortDelta;
174 length += viaEdge->getLength();
175 viaEdge = viaEdge->getViaSuccessors().front().second;
179 inline void updateViaCost(
const E*
const prev,
const E*
const e,
const V*
const v,
double& time,
double& effort,
double& length)
const {
180 if (prev !=
nullptr) {
181 for (
const std::pair<const E*, const E*>& follower : prev->getViaSuccessors()) {
182 if (follower.first == e) {
188 const double effortDelta = this->
getEffort(e, v, time);
189 effort += effortDelta;
191 length += e->getLength();
195 inline double recomputeCosts(
const std::vector<const E*>& edges,
const V*
const v,
SUMOTime msTime,
double* lengthp =
nullptr)
const {
199 if (lengthp ==
nullptr) {
204 const E* prev =
nullptr;
205 for (
const E*
const e : edges) {
216 inline double getEffort(
const E*
const e,
const V*
const v,
double t)
const {
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
long long int myQueryVisits
counters for performance logging
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
const std::string myType
the type of this router
SUMOAbstractRouter & operator=(const SUMOAbstractRouter &s)
Invalidated assignment operator.
double(* Operation)(const E *const, const V *const, double)
Type of the function that is used to retrieve the edge effort.
const bool myHavePermissions
whether edge permissions need to be considered
virtual ~SUMOAbstractRouter()
Destructor.
double getEffort(const E *const e, const V *const v, double t) const
std::vector< E * > myProhibited
EdgeInfo(const E *const e)
Constructor.
void updateViaCost(const E *const prev, const E *const e, const V *const v, double &time, double &effort, double &length) const
double leaveTime
The time the vehicle leaves the edge.
bool prohibited
whether the edge is currently not allowed
double effort
Effort to reach the edge.
Operation myOperation
The object's operation to perform.
static long getCurrentMillis()
Returns the current time in milliseconds.
double heuristicEffort
Estimated effort to reach the edge (effort + lower bound on remaining effort)
bool computeLooped(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)
Builds the route between the given edges using the minimum effort at the given time if from == to,...
bool isProhibited(const E *const edge, const V *const vehicle) const
const bool myHaveRestrictions
whether edge restrictions need to be considered
bool visited
whether the edge was already evaluated
void setBulkMode(const bool mode)
long long int myNumQueries
long long int myQueryTimeSum
const EdgeInfo * prev
The previous edge.
virtual void prohibit(const std::vector< E * > &)
const E *const edge
The current edge.
bool myBulkMode
whether we are currently operating several route queries in a bulk
double getTravelTime(const E *const e, const V *const v, const double t, const double effort) const
SUMOAbstractRouter(const std::string &type, bool unbuildIsWarning, Operation operation, Operation ttOperation, const bool havePermissions, const bool haveRestrictions)
Constructor.
void endQuery(int visits)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
virtual SUMOAbstractRouter * clone()=0
MsgHandler *const myErrorMsgHandler
the handler for routing errors
EdgeInfo & operator=(const EdgeInfo &s)=delete
Invalidated assignment operator.
double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
void updateViaEdgeCost(const E *viaEdge, const V *const v, double &time, double &effort, double &length) const
void informf(const std::string &format, T value, Targs... Fargs)
adds a new formatted message
long long int myQueryStartTime
the time spent querying in milliseconds
@ SVC_IGNORING
vehicles ignoring classes
#define WRITE_MESSAGE(msg)
Operation myTTOperation
The object's operation to perform for travel times.