20 #ifndef IntermodalRouter_h 21 #define IntermodalRouter_h 57 template<
class E,
class L,
class N,
class V,
class INTERNALROUTER = DijkstraRouterTT<IntermodalEdge<E, L, N, V>, IntermodalTrip<E, N, V>, prohibited_withPermissions<IntermodalEdge<E, L, N, V>, IntermodalTrip<E, N, V> > > >
93 int splitEdge(_IntermodalEdge*
const toSplit, _IntermodalEdge* afterSplit,
const SUMOReal pos,
94 _IntermodalEdge*
const fwdConn, _IntermodalEdge*
const backConn = 0) {
96 std::vector<_IntermodalEdge*>& splitList =
myAccessSplits[toSplit];
97 if (splitList.empty()) {
98 splitList.push_back(toSplit);
100 typename std::vector<_IntermodalEdge*>::iterator splitIt = splitList.begin();
102 while (splitIt != splitList.end() && totalLength + (*splitIt)->getLength() +
POSITION_EPS < pos) {
103 totalLength += (*splitIt)->getLength();
107 assert(splitIt != splitList.end());
108 _IntermodalEdge*
const beforeSplit = *splitIt;
109 if (fabs(totalLength - pos) <
POSITION_EPS && splitIt + 1 != splitList.end()) {
112 afterSplit = *(splitIt + 1);
116 beforeSplit->clearSuccessors();
117 beforeSplit->addSuccessor(afterSplit);
118 afterSplit->
setLength(totalLength - pos);
119 beforeSplit->setLength(beforeSplit->getLength() - afterSplit->
getLength());
120 splitList.insert(splitIt + 1, afterSplit);
125 beforeSplit->addSuccessor(access);
135 beforeSplit->addSuccessor(backward);
142 assert(stopEdge != 0);
148 const L* lane = getSidewalk<E, L>(stopEdge);
152 const int splitIndex =
splitEdge(pair.first, fwdSplit, pos, stopConn);
155 if (splitIndex >= 0) {
156 _IntermodalEdge* carSplit = 0;
165 _IntermodalEdge*
const depConn =
new _IntermodalEdge(stopEdge->
getID() +
"_depart_connector" +
toString(pos), myNumericalID++, stopEdge,
"!connector");
174 _IntermodalEdge*
const arrConn =
new _IntermodalEdge(stopEdge->getID() +
"_arrival_connector" +
toString(pos), myNumericalID++, stopEdge,
"!connector");
187 std::vector<SUMOVehicleParameter::Stop> validStops;
188 for (std::vector<SUMOVehicleParameter::Stop>::const_iterator s = pars.
stops.begin(); s != pars.
stops.end(); ++s) {
190 validStops.push_back(*s);
191 lastUntil = s->until;
194 if (validStops.size() < 2) {
195 WRITE_WARNING(
"Ignoring public transport line '" + pars.
line +
"' with less than two usable stops.");
199 typename std::vector<_PTEdge*>& lineEdges =
myPTLines[pars.
line];
200 if (lineEdges.empty()) {
201 _IntermodalEdge* lastStop = 0;
203 for (std::vector<SUMOVehicleParameter::Stop>::const_iterator s = validStops.begin(); s != validStops.end(); ++s) {
211 lineEdges.push_back(newEdge);
217 if (validStops.size() != lineEdges.size() + 1) {
218 WRITE_WARNING(
"Number of stops for public transport line '" + pars.
line +
"' does not match earlier definitions, ignoring schedule.");
221 if (lineEdges.front()->getEntryStop() !=
myStopConnections[validStops.front().busstop]) {
222 WRITE_WARNING(
"Different stop for '" + pars.
line +
"' compared to earlier definitions, ignoring schedule.");
225 typename std::vector<_PTEdge*>::const_iterator lineEdge = lineEdges.begin();
226 typename std::vector<SUMOVehicleParameter::Stop>::const_iterator s = validStops.begin() + 1;
227 for (; s != validStops.end(); ++s, ++lineEdge) {
229 WRITE_WARNING(
"Different stop for '" + pars.
line +
"' compared to earlier definitions, ignoring schedule.");
233 SUMOTime lastTime = validStops.front().until;
234 for (lineEdge = lineEdges.begin(), s = validStops.begin() + 1; lineEdge != lineEdges.end(); ++lineEdge, ++s) {
245 std::vector<TripItem>& into) {
247 _IntermodalTrip trip(from, to, departPos, arrivalPos, speed, msTime, 0, vehicle, modeSet);
248 std::vector<const _IntermodalEdge*> intoPed;
251 &trip, msTime, intoPed);
253 std::string lastLine =
"";
254 for (
int i = 0; i < (int)intoPed.size(); ++i) {
255 if (intoPed[i]->includeInRoute(
false)) {
256 if (intoPed[i]->getLine() ==
"!stop") {
257 into.back().destStop = intoPed[i]->getID();
259 if (intoPed[i]->getLine() != lastLine) {
260 lastLine = intoPed[i]->getLine();
261 if (lastLine ==
"!car") {
262 into.push_back(
TripItem(vehicle->getID()));
263 }
else if (lastLine ==
"!ped") {
269 if (into.back().edges.empty() || into.back().edges.back() != intoPed[i]->getEdge()) {
270 into.back().edges.push_back(intoPed[i]->getEdge());
276 #ifdef IntermodalRouter_DEBUG_ROUTES 278 for (
int i = 0; i < intoPed.size(); ++i) {
281 std::cout <<
TIME2STEPS(msTime) <<
" trip from " << from->getID() <<
" to " << to->getID()
282 <<
" departPos=" << departPos
283 <<
" arrivalPos=" << arrivalPos
294 bool compute(
const E*,
const E*,
const _IntermodalTrip*
const,
304 std::vector<_IntermodalEdge*> toProhibitPE;
305 for (
typename std::vector<E*>::const_iterator it = toProhibit.begin(); it != toProhibit.end(); ++it) {
316 myInternalRouter(
new INTERNALROUTER(net->getAllEdges(), true, &_IntermodalEdge::getTravelTimeStatic)),
320 for (
typename std::vector<E*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
321 const E*
const edge = *i;
322 if (!edge->isInternal()) {
327 for (
typename std::vector<E*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
328 const E*
const edge = *i;
329 if (!edge->isInternal()) {
333 const std::vector<E*>& successors = edge->getSuccessors();
334 for (
typename std::vector<E*>::const_iterator it = successors.begin(); it != successors.end(); ++it) {
355 typename std::map<const E*, _IntermodalEdge*>::const_iterator it =
myCarLookup.find(e);
357 throw ProcessError(
"Car edge '" + e->getID() +
"' not found in pedestrian network.");
373 std::map<std::string, std::vector<_PTEdge*> >
myPTLines;
394 template<
class E,
class L,
class N,
class V>
400 : myVehRouter(vehRouter), myPedRouter(pedRouter), myInterRouter(interRouter) {}
403 : myVehRouter(original.getVehicleRouter().
clone()),
405 myInterRouter(static_cast<
IntermodalRouter<E, L, N, V>*>(original.myInterRouter == 0 ? 0 : original.getIntermodalRouter().
clone())) {}
416 return *myInterRouter;
422 delete myInterRouter;
SUMOReal getLength() const
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
bool compute(const E *from, const E *to, SUMOReal departPos, SUMOReal arrivalPos, SUMOReal speed, const V *const vehicle, const SVCPermissions modeSet, SUMOTime msTime, std::vector< TripItem > &into)
Builds the route between the given edges using the minimum effort at the given time The definition of...
IntermodalRouter & operator=(const IntermodalRouter &s)
Invalidated assignment operator.
std::map< const E *, _IntermodalEdge * > myCarLookup
retrieve the car edge for the given input edge E
void addSchedule(const SUMOTime begin, const SUMOTime end, const SUMOTime period, const SUMOReal travelTimeSec)
const std::vector< _IntermodalEdge * > & getAllEdges()
RouterProvider(const RouterProvider &original)
virtual ~RouterProvider()
SUMOAbstractRouter< E, V > *const myVehRouter
void addEdge(_IntermodalEdge *edge)
void(* CreateNetCallback)(IntermodalRouter< E, L, N, V, INTERNALROUTER > &)
_IntermodalEdge * getDepartEdge(const E *e, const SUMOReal pos=-1.)
Returns the departing Intermodal edge.
AccessEdge< E, L, N, V > _AccessEdge
void addSuccessor(IntermodalEdge *s)
_IntermodalNetwork * myIntermodalNet
std::map< _IntermodalEdge *, std::vector< _IntermodalEdge * > > myAccessSplits
retrieve the splitted edges for the given "original"
the car edge type that is given to the internal router (SUMOAbstractRouter)
std::map< std::string, std::vector< _PTEdge * > > myPTLines
retrieve the public transport edges for the given line
void addAccess(const std::string &stopId, const E *stopEdge, const SUMOReal pos)
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...
TripItem(const std::string &_line="")
#define WRITE_WARNING(msg)
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
void removeSuccessor(const IntermodalEdge *const edge)
_IntermodalEdge * getArrivalEdge(const E *e, const SUMOReal pos=-1.)
Returns the arriving Intermodal edge.
PedestrianRouterDijkstra< E, L, N, V > & getPedestrianRouter() const
std::vector< Stop > stops
List of the stops the vehicle will make.
PublicTransportEdge< E, L, N, V > _PTEdge
const std::string & getID() const
Returns the id.
CreateNetCallback myCallback
int splitEdge(_IntermodalEdge *const toSplit, _IntermodalEdge *afterSplit, const SUMOReal pos, _IntermodalEdge *const fwdConn, _IntermodalEdge *const backConn=0)
IntermodalRouter(_IntermodalNetwork *net)
void prohibit(const std::vector< E * > &toProhibit)
IntermodalTrip< E, N, V > _IntermodalTrip
SUMOAbstractRouter< E, _IntermodalTrip > * clone()
SUMOTime depart
The vehicle's departure time.
the "vehicle" type that is given to the internal router (SUMOAbstractRouter)
IntermodalRouter(CreateNetCallback callback)
Constructor.
SUMOAbstractRouter< E, V > & getVehicleRouter() const
std::vector< const E * > edges
_IntermodalEdge * getCarEdge(const E *e)
Returns the associated car edge.
const E * getEdge() const
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
PedestrianRouterDijkstra< E, L, N, V > *const myPedRouter
the pedestrian network storing edges, connections and the mappings to the "real" edges ...
void addSchedule(const SUMOVehicleParameter &pars)
std::string line
The vehicle's line (mainly for public transport)
the base edge type that is given to the internal router (SUMOAbstractRouter)
INTERNALROUTER * myInternalRouter
std::map< std::string, _IntermodalEdge * > myStopConnections
retrieve the connecting edges for the given "bus" stop
IntermodalNetwork< E, L, N, V > _IntermodalNetwork
Structure representing possible vehicle parameter.
IntermodalEdge< E, L, N, V > _IntermodalEdge
virtual ~IntermodalRouter()
Destructor.
the public transport edge type connecting the stop edges
const EdgePair & getBothDirections(const E *e)
Returns the pair of forward and backward edge.
IntermodalRouter< E, L, N, V > *const myInterRouter
IntermodalRouter< E, L, N, V > & getIntermodalRouter() const
static SUMOReal getTravelTimeStatic(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, SUMOReal time)
void setLength(const SUMOReal length)
the pedestrian edge type that is given to the internal router (SUMOAbstractRouter) ...
SUMOReal recomputeCosts(const std::vector< const E * > &, const _IntermodalTrip *const, SUMOTime) const
void setSuccessors(const std::vector< IntermodalEdge * > &edges)
void addCarEdges(const std::vector< E * > &edges)
RouterProvider(SUMOAbstractRouter< E, V > *vehRouter, PedestrianRouterDijkstra< E, L, N, V > *pedRouter, IntermodalRouter< E, L, N, V > *interRouter)
void addConnectors(_IntermodalEdge *const depConn, _IntermodalEdge *const arrConn, const int splitIndex)
the stop edge type representing bus and train stops
vehicles ignoring classes
the access edge connecting diferent modes that is given to the internal router (SUMOAbstractRouter) ...