19 #ifndef SUMOAbstractRouter_h 20 #define SUMOAbstractRouter_h 45 template<
class E,
class V>
49 typedef double(*
Operation)(
const E*
const,
const V*
const, double);
74 virtual bool compute(
const E* from,
const E* to,
const V*
const vehicle,
75 SUMOTime msTime, std::vector<const E*>& into) = 0;
77 virtual bool isProhibited(
const E*
const ,
const V*
const )
const {
81 inline double getTravelTime(
const E*
const e,
const V*
const v,
const double t,
const double effort)
const {
82 return myTTOperation ==
nullptr ? effort : (*myTTOperation)(e, v, t);
85 inline void updateViaCost(
const E*
const prev,
const E*
const e,
const V*
const v,
double& time,
double& effort)
const {
86 if (prev !=
nullptr) {
87 for (
const std::pair<const E*, const E*>& follower : prev->getViaSuccessors()) {
88 if (follower.first == e) {
89 const E* viaEdge = follower.second;
90 while (viaEdge !=
nullptr && viaEdge != e) {
91 const double viaEffortDelta = this->
getEffort(viaEdge, v, time);
93 effort += viaEffortDelta;
94 viaEdge = viaEdge->getViaSuccessors().front().first;
100 const double effortDelta = this->
getEffort(e, v, time);
101 effort += effortDelta;
109 const E* prev =
nullptr;
110 for (
const E*
const e : edges) {
121 inline double getEffort(
const E*
const e,
const V*
const v,
double t)
const {
165 template<
class E,
class V>
178 if (std::find(myProhibited.begin(), myProhibited.end(), edge) != myProhibited.end()) {
181 return edge->prohibits(vehicle);
185 myProhibited = toProhibit;
void updateViaCost(const E *const prev, const E *const e, const V *const v, double &time, double &effort) const
double getEffort(const E *const e, const V *const v, double t) const
std::vector< E * > myProhibited
double(* Operation)(const E *const, const V *const, double)
Type of the function that is used to retrieve the edge effort.
double getTravelTime(const E *const e, const V *const v, const double t, const double effort) const
long long int myQueryTimeSum
Operation myTTOperation
The object's operation to perform for travel times.
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
bool isProhibited(const E *const edge, const V *const vehicle) const
void prohibit(const std::vector< E *> &toProhibit)
virtual ~SUMOAbstractRouterPermissions()
Destructor.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
SUMOAbstractRouter(const std::string &type, Operation operation=nullptr, Operation ttOperation=nullptr)
Constructor.
SUMOAbstractRouterPermissions(const std::string &type, typename SUMOAbstractRouter< E, V >::Operation operation=nullptr, typename SUMOAbstractRouter< E, V >::Operation ttOperation=nullptr)
Constructor.
bool myBulkMode
whether we are currently operating several route queries in a bulk
Operation myOperation
The object's operation to perform.
long long int myQueryStartTime
the time spent querying in milliseconds
SUMOAbstractRouter & operator=(const SUMOAbstractRouter &s)
Invalidated assignment operator.
virtual ~SUMOAbstractRouter()
Destructor.
virtual bool isProhibited(const E *const, const V *const) const
long long int myNumQueries
long long int myQueryVisits
counters for performance logging
void endQuery(int visits)
double recomputeCosts(const std::vector< const E *> &edges, const V *const v, SUMOTime msTime) const
virtual SUMOAbstractRouter * clone()=0
static long getCurrentMillis()
Returns the current time in milliseconds.
#define WRITE_MESSAGE(msg)
const std::string myType
the type of this router
void setBulkMode(const bool mode)