43 template<
class E,
class V>
55 :
edge(e),
effort(std::numeric_limits<double>::max()),
82 effort = std::numeric_limits<double>::max();
94 typedef double(*
Operation)(
const E*
const,
const V*
const, double);
98 const bool havePermissions,
const bool haveRestrictions) :
139 virtual void reset(
const V*
const vehicle) {
149 virtual bool compute(
const E* from,
const E* to,
const V*
const vehicle,
150 SUMOTime msTime, std::vector<const E*>& into,
bool silent =
false) = 0;
158 const E* from,
double fromPos,
159 const E* to,
double toPos,
160 const V*
const vehicle,
161 SUMOTime msTime, std::vector<const E*>& into,
bool silent =
false) {
162 if (from != to || fromPos <= toPos) {
163 return compute(from, to, vehicle, msTime, into, silent);
165 return computeLooped(from, to, vehicle, msTime, into, silent);
172 inline bool computeLooped(
const E* from,
const E* to,
const V*
const vehicle,
173 SUMOTime msTime, std::vector<const E*>& into,
bool silent =
false) {
175 return compute(from, to, vehicle, msTime, into, silent);
177 double minEffort = std::numeric_limits<double>::max();
178 std::vector<const E*> best;
180 for (
const std::pair<const E*, const E*>& follower : from->getViaSuccessors(vClass)) {
181 std::vector<const E*> tmp;
182 compute(follower.first, to, vehicle, msTime, tmp,
true);
183 if (tmp.size() > 0) {
185 if (effort < minEffort) {
191 if (minEffort != std::numeric_limits<double>::max()) {
192 into.push_back(from);
193 std::copy(best.begin(), best.end(), std::back_inserter(into));
201 inline bool isProhibited(
const E*
const edge,
const V*
const vehicle)
const {
207 inline double getTravelTime(
const E*
const e,
const V*
const v,
const double t,
const double effort)
const {
208 return myTTOperation ==
nullptr ? effort : (*myTTOperation)(e, v, t);
211 inline void updateViaEdgeCost(
const E* viaEdge,
const V*
const v,
double& time,
double& effort,
double& length)
const {
212 while (viaEdge !=
nullptr && viaEdge->isInternal()) {
213 const double viaEffortDelta = this->
getEffort(viaEdge, v, time);
215 effort += viaEffortDelta;
216 length += viaEdge->getLength();
217 viaEdge = viaEdge->getViaSuccessors().front().second;
221 inline void updateViaCost(
const E*
const prev,
const E*
const e,
const V*
const v,
double& time,
double& effort,
double& length)
const {
222 if (prev !=
nullptr) {
223 for (
const std::pair<const E*, const E*>& follower : prev->getViaSuccessors()) {
224 if (follower.first == e) {
230 const double effortDelta = this->
getEffort(e, v, time);
231 effort += effortDelta;
233 length += e->getLength();
237 inline double recomputeCosts(
const std::vector<const E*>& edges,
const V*
const v,
SUMOTime msTime,
double* lengthp =
nullptr)
const {
241 if (lengthp ==
nullptr) {
246 const E* prev =
nullptr;
247 for (
const E*
const e : edges) {
258 inline double recomputeCosts(
const std::vector<const E*>& edges,
const V*
const v,
double fromPos,
double toPos,
SUMOTime msTime,
double* lengthp =
nullptr)
const {
260 if (!edges.empty()) {
263 effort -= firstEffort * fromPos / edges.front()->getLength();
264 effort -= lastEffort * (edges.back()->getLength() - toPos) / edges.back()->getLength();
270 inline double getEffort(
const E*
const e,
const V*
const v,
double t)
const {
#define WRITE_MESSAGE(msg)
std::string elapsedMs2string(long long int t)
convert ms to string for log output
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
#define UNUSED_PARAMETER(x)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void informf(const std::string &format, T value, Targs... Fargs)
adds a new formatted message
bool visited
whether the edge was already evaluated
EdgeInfo(const E *const e)
Constructor.
const E *const edge
The current edge.
double leaveTime
The time the vehicle leaves the edge.
double effort
Effort to reach the edge.
bool prohibited
whether the edge is currently not allowed
const EdgeInfo * prev
The previous edge.
double heuristicEffort
Estimated effort to reach the edge (effort + lower bound on remaining effort)
EdgeInfo & operator=(const EdgeInfo &s)=delete
Invalidated assignment operator.
virtual SUMOAbstractRouter * clone()=0
Operation myTTOperation
The object's operation to perform for travel times.
long long int myNumQueries
MsgHandler *const myErrorMsgHandler
the handler for routing errors
const std::string & getType() const
std::vector< E * > myProhibited
bool isProhibited(const E *const edge, const V *const vehicle) const
const bool myHavePermissions
whether edge permissions need to be considered
bool myBulkMode
whether we are currently operating several route queries in a bulk
long long int myQueryVisits
counters for performance logging
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 recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
long long int myQueryStartTime
the time spent querying in milliseconds
SUMOAbstractRouter & operator=(const SUMOAbstractRouter &s)
Invalidated assignment operator.
bool compute(const E *from, double fromPos, const E *to, double toPos, 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,...
SUMOAbstractRouter(SUMOAbstractRouter *other)
Copy Constructor.
double(* Operation)(const E *const, const V *const, double)
Type of the function that is used to retrieve the edge effort.
Operation myOperation
The object's operation to perform.
double getTravelTime(const E *const e, const V *const v, const double t, const double effort) const
long long int myQueryTimeSum
void updateViaCost(const E *const prev, const E *const e, const V *const v, double &time, double &effort, double &length) const
virtual void reset(const V *const vehicle)
reset internal caches, used by CHRouter
double getEffort(const E *const e, const V *const v, double t) const
SUMOAbstractRouter(const std::string &type, bool unbuildIsWarning, Operation operation, Operation ttOperation, const bool havePermissions, const bool haveRestrictions)
Constructor.
void updateViaEdgeCost(const E *viaEdge, const V *const v, double &time, double &effort, double &length) const
double recomputeCosts(const std::vector< const E * > &edges, const V *const v, double fromPos, double toPos, SUMOTime msTime, double *lengthp=nullptr) const
void setAutoBulkMode(const bool mode)
virtual void prohibit(const std::vector< E * > &)
const bool myHaveRestrictions
whether edge restrictions need to be considered
void setBulkMode(const bool mode)
bool myAutoBulkMode
whether we are currently trying to detect bulk mode automatically
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...
void endQuery(int visits)
virtual ~SUMOAbstractRouter()
Destructor.
const std::string myType
the type of this router
static long getCurrentMillis()
Returns the current time in milliseconds.