 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
17 #ifndef IntermodalRouter_h
18 #define IntermodalRouter_h
53 template<
class E,
class L,
class N,
class V>
108 bool compute(
const E* from,
const E* to,
const double departPos,
const double arrivalPos,
109 const std::string stopID,
const double speed,
111 std::vector<TripItem>& into,
const double externalFactor = 0.) {
113 _IntermodalTrip trip(from, to, departPos, arrivalPos, speed, msTime, 0, vehicle, modeSet,
myExternalEffort, externalFactor);
114 std::vector<const _IntermodalEdge*> intoEdges;
118 &trip, msTime, intoEdges);
120 std::string lastLine =
"";
126 if (iEdge->includeInRoute(
false)) {
127 if (iEdge->getLine() ==
"!stop") {
128 if (into.size() > 0) {
130 into.back().destStop = iEdge->
getID();
134 if (lastLine ==
"!ped") {
140 into.push_back(TripItem(
"!stop"));
141 into.back().destStop = iEdge->getID();
144 if (iEdge->getLine() != lastLine) {
145 lastLine = iEdge->getLine();
146 if (lastLine ==
"!car") {
147 into.push_back(TripItem(vehicle->getID()));
148 into.back().vType = vehicle->getParameter().vtypeid;
149 }
else if (lastLine ==
"!ped") {
150 into.push_back(TripItem());
152 into.push_back(TripItem(lastLine));
153 into.back().depart = iEdge->getIntended(time, into.back().intended);
155 into.back().departPos = iEdge->getStartPos();
157 if (into.back().edges.empty() || into.back().edges.back() != iEdge->getEdge()) {
158 into.back().edges.push_back(iEdge->getEdge());
159 into.back().arrivalPos = iEdge->getEndPos();
163 const double prevTime = time, prevEffort = effort, prevLength = length;
167 into.back().traveltime += time - prevTime;
168 into.back().cost += effort - prevEffort;
169 into.back().length += length - prevLength;
173 #ifdef IntermodalRouter_DEBUG_ROUTES
178 std::cout << iEdge->getID() <<
"(" << iEdge->getLine() <<
"): " << edgeEffort << std::endl;
180 std::cout <<
TIME2STEPS(msTime) <<
" trip from " << from->getID() <<
" to " << (to !=
nullptr ? to->getID() : stopID)
195 SUMOTime, std::vector<const E*>&,
bool) {
201 std::vector<_IntermodalEdge*> toProhibitPE;
202 for (
typename std::vector<E*>::const_iterator it = toProhibit.begin(); it != toProhibit.end(); ++it) {
228 dev.
writeAttr(
"traveltime", e->getTravelTime(&trip, 0.));
229 dev.
writeAttr(
"effort", e->getEffort(&trip, 0.));
281 std::vector<std::string> edgeLines;
283 edgeLines.push_back(e->getLine());
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 writeNetwork(OutputDevice &dev)
void(* CreateNetCallback)(IntermodalRouter< E, L, N, V > &)
_IntermodalEdge * getStopEdge(const std::string &stopId) const
Returns the associated stop edge.
static double getEffortAggregated(const _IntermodalEdge *const edge, const _IntermodalTrip *const trip, double time)
const _IntermodalEdge * getDepartEdge(const E *e, const double pos) const
Returns the departing intermodal edge.
Static storage of an output device and its base (abstract) implementation.
_InternalRouter * myInternalRouter
SUMOAbstractRouter< _IntermodalEdge, _IntermodalTrip > _InternalRouter
_IntermodalEdge * getCarEdge(const E *e) const
Returns the associated car edge.
static double getTravelTimeStaticRandomized(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, double time)
double getEffort(const E *const e, const V *const v, double t) const
virtual std::string output(const int edge) const =0
virtual double getTravelTime(const IntermodalTrip< E, N, V > *const, double) const
@ SVC_BICYCLE
vehicle is a bicycle
const std::string myRoutingAlgorithm
Network * myIntermodalNet
the base edge type that is given to the internal router (SUMOAbstractRouter)
void updateViaCost(const E *const prev, const E *const e, const V *const v, double &time, double &effort, double &length) const
virtual bool hasEffort() const
static double getEffortStatic(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, double time)
bool compute(const E *, const E *, const _IntermodalTrip *const, SUMOTime, std::vector< const E * > &, bool)
Builds the route between the given edges using the minimum effort at the given time The definition of...
Computes the shortest path through a network using the Dijkstra algorithm.
IntermodalNetwork< E, L, N, V > Network
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
double gWeightsRandomFactor
void addCarEdges(const std::vector< E * > &edges)
CreateNetCallback myCallback
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
const int myCarWalkTransfer
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 prohibit(const std::vector< E * > &toProhibit)
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
static double getTravelTimeStatic(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, double time)
const double DEFAULT_PEDESTRIAN_SPEED
int getNumericalID() const
TripItem(const std::string &_line="")
EffortCalculator * getExternalEffort() const
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
IntermodalEdge< E, L, N, V > _IntermodalEdge
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
virtual void init(const std::vector< std::string > &edges)=0
_IntermodalEdge * getArrivalEdge(const E *e, const double pos) const
Returns the arriving intermodal edge.
IntermodalRouter(Network *net, const int carWalkTransfer, const std::string &routingAlgorithm, const int routingMode, EffortCalculator *calc)
const EffortCalculator *const calc
virtual void prohibit(const std::vector< E * > &)
const std::vector< _IntermodalEdge * > & getAllEdges()
DijkstraRouter< _IntermodalEdge, _IntermodalTrip > _InternalDijkstra
SUMOAbstractRouter< E, _IntermodalTrip > * clone()
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void writeWeights(OutputDevice &dev)
virtual ~IntermodalRouter()
Destructor.
the intermodal network storing edges, connections and the mappings to the "real" edges
const EdgePair & getBothDirections(const E *e) const
Returns the pair of forward and backward edge.
static double getCombined(const _IntermodalEdge *const edge, const _IntermodalTrip *const trip, double time)
const double INVALID_DOUBLE
Computes the shortest path through a network using the A* algorithm.
the effort calculator interface
@ SVC_BUS
vehicle is a bus
EffortCalculator *const myExternalEffort
IntermodalTrip< E, N, V > _IntermodalTrip
std::vector< const E * > edges
AStarRouter< _IntermodalEdge, _IntermodalTrip > _InternalAStar
IntermodalRouter & operator=(const IntermodalRouter &s)
Invalidated assignment operator.
@ SVC_IGNORING
vehicles ignoring classes
const std::string & getID() const
Returns the id.
IntermodalRouter(CreateNetCallback callback, const int carWalkTransfer, const std::string &routingAlgorithm, const int routingMode=0, EffortCalculator *calc=nullptr)
Constructor.
the "vehicle" type that is given to the internal router (SUMOAbstractRouter)
virtual double getEffort(const IntermodalTrip< E, N, V > *const, double) const
const double externalFactor
Network * getNetwork() const
virtual double getEffort(const int numericalID) const =0