18 #ifndef IntermodalRouter_h 19 #define IntermodalRouter_h 54 template<
class E,
class L,
class N,
class V>
110 const std::string stopID,
const double speed,
112 std::vector<TripItem>& into,
const double externalFactor = 0.) {
114 _IntermodalTrip trip(from, to, departPos, arrivalPos, speed, msTime, 0, vehicle, modeSet,
myExternalEffort, externalFactor);
115 std::vector<const _IntermodalEdge*> intoEdges;
118 &trip, msTime, intoEdges);
120 std::string lastLine =
"";
124 const _IntermodalEdge* prev =
nullptr;
125 for (
const _IntermodalEdge* iEdge : intoEdges) {
126 if (iEdge->includeInRoute(
false)) {
127 if (iEdge->getLine() ==
"!stop") {
128 into.back().destStop = iEdge->getID();
129 if (lastLine ==
"!ped") {
133 if (iEdge->getLine() != lastLine) {
134 lastLine = iEdge->getLine();
135 if (lastLine ==
"!car") {
136 into.push_back(
TripItem(vehicle->getID()));
137 into.back().vType = vehicle->getParameter().vtypeid;
138 }
else if (lastLine ==
"!ped") {
142 into.back().depart = iEdge->getIntended(time, into.back().intended);
144 into.back().departPos = iEdge->getStartPos();
146 if (into.back().edges.empty() || into.back().edges.back() != iEdge->getEdge()) {
147 into.back().edges.push_back(iEdge->getEdge());
148 into.back().arrivalPos = iEdge->getEndPos();
152 const double prevTime = time, prevEffort = effort, prevLength =
length;
156 into.back().traveltime += time - prevTime;
157 into.back().cost += effort - prevEffort;
158 into.back().length += length - prevLength;
162 #ifdef IntermodalRouter_DEBUG_ROUTES 164 for (
const _IntermodalEdge* iEdge : intoEdges) {
167 std::cout << iEdge->getID() <<
"(" << iEdge->getLine() <<
"): " << edgeEffort << std::endl;
169 std::cout <<
TIME2STEPS(msTime) <<
" trip from " << from->getID() <<
" to " << (to !=
nullptr ? to->getID() : stopID)
182 bool compute(
const E*,
const E*,
const _IntermodalTrip*
const,
189 std::vector<_IntermodalEdge*> toProhibitPE;
190 for (
typename std::vector<E*>::const_iterator it = toProhibit.begin(); it != toProhibit.end(); ++it) {
216 dev.
writeAttr(
"traveltime", e->getTravelTime(&trip, 0.));
217 dev.
writeAttr(
"effort", e->getEffort(&trip, 0.));
227 IntermodalRouter(Network* net,
const int carWalkTransfer,
const std::string& routingAlgorithm,
230 myInternalRouter(new _InternalDijkstra(net->getAllEdges(), true, &_IntermodalEdge::getTravelTimeStatic)),
233 static inline double getEffortAggregated(
const _IntermodalEdge*
const edge,
const _IntermodalTrip*
const trip,
double time) {
237 static inline double getCombined(
const _IntermodalEdge*
const edge,
const _IntermodalTrip*
const trip,
double time) {
262 std::vector<std::string> edgeIDs;
264 edgeIDs.push_back(e->getID());
bool compute(const E *from, const E *to, const double departPos, const double arrivalPos, const std::string stopID, const double speed, const V *const vehicle, const SVCPermissions modeSet, const SUMOTime msTime, std::vector< TripItem > &into, const double externalFactor=0.)
Builds the route between the given edges using the minimum effort at the given time The definition of...
void writeWeights(OutputDevice &dev)
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
double getEffort(const E *const e, const V *const v, double t) const
const EdgePair & getBothDirections(const E *e) const
Returns the pair of forward and backward edge.
static double getEffortAggregated(const _IntermodalEdge *const edge, const _IntermodalTrip *const trip, double time)
static double getEffortStatic(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, double time)
IntermodalNetwork< E, L, N, V > Network
_IntermodalEdge * getArrivalEdge(const E *e, const double pos) const
Returns the arriving intermodal edge.
virtual ~IntermodalRouter()
Destructor.
static double getCombined(const _IntermodalEdge *const edge, const _IntermodalTrip *const trip, double time)
void writeNetwork(OutputDevice &dev)
const std::vector< _IntermodalEdge * > & getAllEdges()
static double getTravelTimeStatic(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, double time)
IntermodalRouter(Network *net, const int carWalkTransfer, const std::string &routingAlgorithm, const int routingMode, EffortCalculator *calc)
virtual void init(const std::vector< std::string > &edges)=0
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
_IntermodalEdge * getStopEdge(const std::string &stopId) const
Returns the associated stop edge.
int getNumericalID() const
Computes the shortest path through a network using the A* algorithm.
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...
EffortCalculator *const myExternalEffort
void prohibit(const std::vector< E *> &toProhibit)
const EffortCalculator *const calc
TripItem(const std::string &_line="")
void prohibit(const std::vector< E *> &toProhibit)
void updateViaCost(const E *const prev, const E *const e, const V *const v, double &time, double &effort, double &length) const
const std::string myRoutingAlgorithm
the effort calculator interface
IntermodalEdge< E, L, N, V > _IntermodalEdge
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
DijkstraRouter< _IntermodalEdge, _IntermodalTrip, _InternalRouter > _InternalDijkstra
Computes the shortest path through a network using the Dijkstra algorithm.
virtual double getEffort(const int edge) const =0
IntermodalRouter(CreateNetCallback callback, const int carWalkTransfer, const std::string &routingAlgorithm, const int routingMode=0, EffortCalculator *calc=nullptr)
Constructor.
the intermodal network storing edges, connections and the mappings to the "real" edges ...
vehicle is a passenger car (a "normal" car)
begin/end of the description of an edge
the base edge type that is given to the internal router (SUMOAbstractRouter)
_IntermodalEdge * getDepartEdge(const E *e, const double pos) const
Returns the departing intermodal edge.
virtual double getEffort(const IntermodalTrip< E, N, V > *const, double) const
CreateNetCallback myCallback
const int myCarWalkTransfer
const double DEFAULT_PEDESTRIAN_SPEED
void(* CreateNetCallback)(IntermodalRouter< E, L, N, V > &)
std::vector< const E * > edges
bool compute(const E *, const E *, const _IntermodalTrip *const, SUMOTime, std::vector< const E *> &)
Builds the route between the given edges using the minimum effort at the given time The definition of...
Network * myIntermodalNet
void addCarEdges(const std::vector< E *> &edges)
SUMOAbstractRouterPermissions< _IntermodalEdge, _IntermodalTrip > _InternalRouter
const double externalFactor
SUMOAbstractRouter< E, _IntermodalTrip > * clone()
Static storage of an output device and its base (abstract) implementation.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
_IntermodalEdge * getCarEdge(const E *e) const
Returns the associated car edge.
AStarRouter< _IntermodalEdge, _IntermodalTrip, _InternalRouter > _InternalAStar
IntermodalTrip< E, N, V > _IntermodalTrip
IntermodalRouter & operator=(const IntermodalRouter &s)
Invalidated assignment operator.
_InternalRouter * myInternalRouter
virtual bool hasEffort() const
the "vehicle" type that is given to the internal router (SUMOAbstractRouter)
vehicles ignoring classes
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Network * getNetwork() const
virtual double getTravelTime(const IntermodalTrip< E, N, V > *const, double) const