Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDevice_Routing.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2007-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
20// A device that performs vehicle rerouting based on current edge speeds
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include <set>
26#include <vector>
27#include <map>
30#include <microsim/MSVehicle.h>
31#include "MSVehicleDevice.h"
32
33
34// ===========================================================================
35// class declarations
36// ===========================================================================
37class MSLane;
38
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
59public:
63 static void insertOptions(OptionsCont& oc);
64
68 static bool checkOptions(OptionsCont& oc);
69
70
86 static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
87
88
91
92
93
96
115 bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
116
118 void notifyStopEnded();
119
121
123 const std::string deviceName() const {
124 return "rerouting";
125 }
126
131 void saveState(OutputDevice& out) const;
132
137 void loadState(const SUMOSAXAttributes& attrs);
138
140 void reroute(const SUMOTime currentTime, const bool onInit = false);
141
142
151 void skipRouting(const SUMOTime currentTime) {
152 mySkipRouting = currentTime;
153 }
154
156 return myPeriod;
157 }
158
160 bool mayRerouteRailSignal() const {
161 return myRerouteRailSignal;
162 }
163
165 std::string getParameter(const std::string& key) const;
166
168 void setParameter(const std::string& key, const std::string& value);
169
170 void setActive(bool active) {
171 myActive = active;
172 }
173
175 bool sufficientSaving(double oldCost, double newCost);
176
177private:
178
186 MSDevice_Routing(SUMOVehicle& holder, const std::string& id, SUMOTime period, SUMOTime preInsertionPeriod);
187
199 SUMOTime preInsertionReroute(const SUMOTime currentTime);
200
216
219
220private:
223
226
229
232
235
238
241
244
245 // Only reroute if the new route is faster than the current route by factor
247
248 // Only reroute if the new route is faster than the current route by seconds
250
253
254private:
257
260
261
262};
long long int SUMOTime
Definition GUI.h:36
A device that performs vehicle rerouting based on current edge speeds.
const std::string deviceName() const
return the name for this type of device
void saveState(OutputDevice &out) const
Saves the state of the device.
SUMOTime getPeriod() const
void rebuildRerouteCommand(SUMOTime start)
rebuild reroute command according to period
SUMOTime wrappedRerouteCommandExecute(SUMOTime currentTime)
Performs rerouting after a period.
bool sufficientSaving(double oldCost, double newCost)
whether the change in saving is enough to trigger rerouting
SUMOTime mySkipRouting
The time for which routing may be skipped because we cannot be inserted.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Routing-options.
void setActive(bool active)
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
bool myActive
Whether the equipped vehicle may perform rerouting.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
SUMOTime myPreInsertionPeriod
The period with which a vehicle shall be rerouted before insertion.
SUMOTime myPeriod
The period with which a vehicle shall be rerouted.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
void reroute(const SUMOTime currentTime, const bool onInit=false)
initiate the rerouting, create router / thread pool on first use
bool myRerouteRailSignal
Whether the equipped vehicle may receive dispatch information at a rail signal.
bool mayRerouteRailSignal() const
return whether the equipped vehicle may receive dispatch information at a rail signal
MSDevice_Routing(const MSDevice_Routing &)
Invalidated copy constructor.
WrappingCommand< MSDevice_Routing > * myRerouteCommand
The (optional) command responsible for rerouting.
void skipRouting(const SUMOTime currentTime)
Labels the current time step as "unroutable".
~MSDevice_Routing()
Destructor.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
SUMOTime myLastLaneEntryTime
the previous time that a vehicle entered a lane
SUMOTime myLastRouting
The last time a routing took place.
void notifyStopEnded()
called to do the rerouting we missed whuile stopping
bool myRerouteAfterStop
Whether the equipped vehicle missed a reroute while stopping and should do so after the stop has ende...
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
MSDevice_Routing & operator=(const MSDevice_Routing &)
Invalidated assignment operator.
SUMOTime preInsertionReroute(const SUMOTime currentTime)
Performs rerouting before insertion into the network.
Representation of a lane in the micro simulation.
Definition MSLane.h:84
Notification
Definition of a vehicle state.
Abstract in-vehicle device.
A storage for options typed value containers)
Definition OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
Encapsulated SAX-Attributes.
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition SUMOVehicle.h:62
bool checkOptions()