19 #ifndef SUMOAbstractRouter_h 20 #define SUMOAbstractRouter_h 46 template<
class E,
class V>
58 :
edge(e),
effort(std::numeric_limits<double>::max()),
82 effort = std::numeric_limits<double>::max();
83 heuristicEffort = std::numeric_limits<double>::max();
94 typedef double(*
Operation)(
const E*
const,
const V*
const, double);
120 virtual bool compute(
const E* from,
const E* to,
const V*
const vehicle,
121 SUMOTime msTime, std::vector<const E*>& into,
bool silent =
false) = 0;
126 SUMOTime msTime, std::vector<const E*>& into,
bool silent =
false) {
128 return compute(from, to, vehicle, msTime, into, silent);
130 double minEffort = std::numeric_limits<double>::max();
131 std::vector<const E*> best;
133 for (
const std::pair<const E*, const E*>& follower : from->getViaSuccessors(vClass)) {
134 std::vector<const E*> tmp;
135 compute(follower.first, to, vehicle, msTime, tmp,
true);
136 if (tmp.size() > 0) {
138 if (effort < minEffort) {
144 if (minEffort != std::numeric_limits<double>::max()) {
145 into.push_back(from);
146 std::copy(best.begin(), best.end(), std::back_inserter(into));
149 myErrorMsgHandler->
inform(
"No connection between edge '" + from->getID() +
"' and edge '" + to->getID() +
"' found.");
159 inline double getTravelTime(
const E*
const e,
const V*
const v,
const double t,
const double effort)
const {
164 while (viaEdge !=
nullptr && viaEdge->isInternal()) {
165 const double viaEffortDelta = this->
getEffort(viaEdge, v, time);
167 effort += viaEffortDelta;
168 length += viaEdge->getLength();
169 viaEdge = viaEdge->getViaSuccessors().front().second;
173 inline void updateViaCost(
const E*
const prev,
const E*
const e,
const V*
const v,
double& time,
double&
effort,
double& length)
const {
174 if (prev !=
nullptr) {
175 for (
const std::pair<const E*, const E*>& follower : prev->getViaSuccessors()) {
176 if (follower.first == e) {
182 const double effortDelta = this->
getEffort(e, v, time);
183 effort += effortDelta;
185 length += e->getLength();
189 inline double recomputeCosts(
const std::vector<const E*>& edges,
const V*
const v,
SUMOTime msTime,
double* lengthp =
nullptr)
const {
193 if (lengthp ==
nullptr) {
198 const E*
prev =
nullptr;
199 for (
const E*
const e : edges) {
210 inline double getEffort(
const E*
const e,
const V*
const v,
double t)
const {
257 template<
class E,
class V>
271 if (std::find(myProhibited.begin(), myProhibited.end(),
edge) != myProhibited.end()) {
274 return edge->prohibits(vehicle);
278 myProhibited = toProhibit;
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.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
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.
EdgeInfo & operator=(const EdgeInfo &s)=delete
Invalidated assignment operator.
void updateViaEdgeCost(const E *viaEdge, const V *const v, double &time, double &effort, double &length) const
bool visited
The previous edge.
bool isProhibited(const E *const edge, const V *const vehicle) const
double leaveTime
The time the vehicle leaves the edge.
void prohibit(const std::vector< E *> &toProhibit)
SUMOAbstractRouter(const std::string &type, bool unbuildIsWarning, Operation operation=nullptr, Operation ttOperation=nullptr)
Constructor.
void updateViaCost(const E *const prev, const E *const e, const V *const v, double &time, double &effort, double &length) const
virtual ~SUMOAbstractRouterPermissions()
Destructor.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double recomputeCosts(const std::vector< const E *> &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
bool myBulkMode
whether we are currently operating several route queries in a bulk
MsgHandler *const myErrorMsgHandler
the handler for routing errors
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...
Operation myOperation
The object's operation to perform.
long long int myQueryStartTime
the time spent querying in milliseconds
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...
double effort
Effort to reach the edge.
SUMOAbstractRouterPermissions(const std::string &type, bool unbuildIsWarning, typename SUMOAbstractRouter< E, V >::Operation operation=nullptr, typename SUMOAbstractRouter< E, V >::Operation ttOperation=nullptr)
Constructor.
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
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
EdgeInfo(const E *const e)
Constructor.
void endQuery(int visits)
double heuristicEffort
Estimated effort to reach the edge (effort + lower bound on remaining effort)
virtual SUMOAbstractRouter * clone()=0
static long getCurrentMillis()
Returns the current time in milliseconds.
#define WRITE_MESSAGE(msg)
const EdgeInfo * prev
The previous edge.
const std::string myType
the type of this router
vehicles ignoring classes
void setBulkMode(const bool mode)
const E *const edge
The current edge.