 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
18 #ifndef IntermodalRouter_h
19 #define IntermodalRouter_h
54 template<
class E,
class L,
class N,
class V>
109 bool compute(
const E* from,
const E* to,
const double departPos,
const double arrivalPos,
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;
119 &trip, msTime, intoEdges);
121 std::string lastLine =
"";
127 if (iEdge->includeInRoute(
false)) {
128 if (iEdge->getLine() ==
"!stop") {
129 if (into.size() > 0) {
131 into.back().destStop = iEdge->
getID();
135 if (lastLine ==
"!ped") {
142 into.back().destStop = iEdge->getID();
145 if (iEdge->getLine() != lastLine) {
146 lastLine = iEdge->getLine();
147 if (lastLine ==
"!car") {
148 into.push_back(
TripItem(vehicle->getID()));
149 into.back().vType = vehicle->getParameter().vtypeid;
150 }
else if (lastLine ==
"!ped") {
154 into.back().depart = iEdge->getIntended(time, into.back().intended);
156 into.back().departPos = iEdge->getStartPos();
158 if (into.back().edges.empty() || into.back().edges.back() != iEdge->getEdge()) {
159 into.back().edges.push_back(iEdge->getEdge());
160 into.back().arrivalPos = iEdge->getEndPos();
164 const double prevTime = time, prevEffort = effort, prevLength = length;
168 into.back().traveltime += time - prevTime;
169 into.back().cost += effort - prevEffort;
170 into.back().length += length - prevLength;
174 #ifdef IntermodalRouter_DEBUG_ROUTES
179 std::cout << iEdge->getID() <<
"(" << iEdge->getLine() <<
"): " << edgeEffort << std::endl;
181 std::cout <<
TIME2STEPS(msTime) <<
" trip from " << from->getID() <<
" to " << (to !=
nullptr ? to->getID() : stopID)
196 SUMOTime, std::vector<const E*>&,
bool) {
202 std::vector<_IntermodalEdge*> toProhibitPE;
203 for (
typename std::vector<E*>::const_iterator it = toProhibit.begin(); it != toProhibit.end(); ++it) {
229 dev.
writeAttr(
"traveltime", e->getTravelTime(&trip, 0.));
230 dev.
writeAttr(
"effort", e->getEffort(&trip, 0.));
282 std::vector<std::string> edgeLines;
284 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...
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...
EffortCalculator *const myExternalEffort
SUMOAbstractRouterPermissions< _IntermodalEdge, _IntermodalTrip > _InternalRouter
_IntermodalEdge * getStopEdge(const std::string &stopId) const
Returns the associated stop edge.
const _IntermodalEdge * getDepartEdge(const E *e, const double pos) const
Returns the departing intermodal edge.
static double getEffortAggregated(const _IntermodalEdge *const edge, const _IntermodalTrip *const trip, double time)
Static storage of an output device and its base (abstract) implementation.
IntermodalRouter & operator=(const IntermodalRouter &s)
Invalidated assignment operator.
static double getCombined(const _IntermodalEdge *const edge, const _IntermodalTrip *const trip, double time)
void writeNetwork(OutputDevice &dev)
_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
DijkstraRouter< _IntermodalEdge, _IntermodalTrip, _InternalRouter > _InternalDijkstra
virtual ~IntermodalRouter()
Destructor.
virtual double getTravelTime(const IntermodalTrip< E, N, V > *const, double) const
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)
Computes the shortest path through a network using the Dijkstra algorithm.
IntermodalTrip< E, N, V > _IntermodalTrip
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)
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
CreateNetCallback myCallback
IntermodalRouter(Network *net, const int carWalkTransfer, const std::string &routingAlgorithm, const int routingMode, EffortCalculator *calc)
void(* CreateNetCallback)(IntermodalRouter< E, L, N, V > &)
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
IntermodalRouter(CreateNetCallback callback, const int carWalkTransfer, const std::string &routingAlgorithm, const int routingMode=0, EffortCalculator *calc=nullptr)
Constructor.
TripItem(const std::string &_line="")
static double getTravelTimeStatic(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, double time)
const double DEFAULT_PEDESTRIAN_SPEED
int getNumericalID() const
AStarRouter< _IntermodalEdge, _IntermodalTrip, _InternalRouter > _InternalAStar
vehicle is a passenger car (a "normal" car)
begin/end of the description of an edge
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.
const EffortCalculator *const calc
const std::string myRoutingAlgorithm
const std::vector< _IntermodalEdge * > & getAllEdges()
void prohibit(const std::vector< E * > &toProhibit)
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Network * myIntermodalNet
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.
SUMOAbstractRouter< E, _IntermodalTrip > * clone()
_InternalRouter * myInternalRouter
const double INVALID_DOUBLE
Computes the shortest path through a network using the A* algorithm.
the effort calculator interface
void writeWeights(OutputDevice &dev)
std::vector< const E * > edges
const int myCarWalkTransfer
IntermodalEdge< E, L, N, V > _IntermodalEdge
void prohibit(const std::vector< E * > &toProhibit)
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...
Network * getNetwork() const
vehicles ignoring classes
EffortCalculator * getExternalEffort() const
const std::string & getID() const
Returns the id.
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
IntermodalNetwork< E, L, N, V > Network
virtual double getEffort(const int numericalID) const =0