Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDevice_StationFinder.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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/****************************************************************************/
19// A device which triggers rerouting to nearby charging stations
20/****************************************************************************/
21#pragma once
22#include <config.h>
23
26#include "MSVehicleDevice.h"
27
28
29#define DEFAULT_SOC_INTERVAL 0.1
30#define DEFAULT_ENERGY_PER_DISTANCE 200 // Wh/km
31#define DEFAULT_AVG_WAITING_TIME 900. // s
32#define DEFAULT_CHARGINGSTATION_VIEW_DIST 10 // m
33#define DEFAULT_CONSUMPTION_ESTIMATE_HISTORY 10 // s
34
35// ===========================================================================
36// class declarations
37// ===========================================================================
39class MSStoppingPlace;
40
41
42// ===========================================================================
43// class definitions
44// ===========================================================================
56public:
63
69
75
84
87 static void insertOptions(OptionsCont& oc);
88
89
102 static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
103
109
112
115
130 bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed) override;
131
141 bool notifyIdle(SUMOTrafficObject& veh) override;
142
144
149 void saveState(OutputDevice& out) const override;
150
155 void loadState(const SUMOSAXAttributes& attrs) override;
156
158 const std::string deviceName() const override {
159 return "stationfinder";
160 }
161
163 const std::string getChargingStrategy() const {
165 return "none";
167 return "balanced";
168 } else {
169 return "latest";
170 }
171 }
172
179 void generateOutput(OutputDevice* tripinfoOut) const override;
180
182 myBattery = battery;
183 }
184
185 std::string getParameter(const std::string& key) const override;
186
188 void setParameter(const std::string& key, const std::string& value) override;
189
205 bool evaluateCustomComponents(SUMOVehicle& veh, double brakeGap, bool newDestination,
206 MSStoppingPlace* alternative, double occupancy, double prob,
208 ConstMSEdgeVector& newRoute,
209 ConstMSEdgeVector& stoppingPlaceApproach,
210 StoppingPlaceParamMap_t& maxValues,
211 StoppingPlaceParamMap_t& addInput) override;
212
214 bool validComponentValues(StoppingPlaceParamMap_t& stoppingPlaceValues) override;
215
217 bool useStoppingPlace(MSStoppingPlace* stoppingPlace) override;
218
221
223 double getStoppingPlaceOccupancy(MSStoppingPlace* stoppingPlace) override;
224
226 double getLastStepStoppingPlaceOccupancy(MSStoppingPlace* stoppingPlace) override;
227
229 double getStoppingPlaceCapacity(MSStoppingPlace* stoppingPlace) override;
230
232 void rememberBlockedStoppingPlace(SUMOVehicle& veh, const MSStoppingPlace* stoppingPlace, bool blocked) override;
233
235 void rememberStoppingPlaceScore(SUMOVehicle& veh, MSStoppingPlace* place, const std::string& score) override;
236
238 void resetStoppingPlaceScores(SUMOVehicle& veh) override;
239
241 SUMOTime sawBlockedStoppingPlace(SUMOVehicle& veh, MSStoppingPlace* place, bool local) override;
242
245
247 void setNumberStoppingPlaceReroutes(SUMOVehicle& veh, int value) override;
248
249protected:
254 const double frontOnLane,
255 const double timeOnLane,
256 const double meanSpeedFrontOnLane,
257 const double meanSpeedVehicleOnLane,
258 const double travelledDistanceFrontOnLane,
259 const double travelledDistanceVehicleOnLane,
260 const double meanLengthOnLane) override;
261
262private:
273 MSChargingStation* findChargingStation(SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, double expectedConsumption, StoppingPlaceParamMap_t& scores, bool constrainTT = true, bool skipVisited = true, bool skipOccupied = false);
274
275
281 bool rerouteToChargingStation(bool replace = false);
282
286
294 double estimateConsumption(const MSEdge* target = nullptr, const bool includeEmptySoC = true, const double stopDiscount = 0.) const;
295
302
308
311 void initRescueCommand();
312
316
319 SUMOTime updateChargeLimit(const SUMOTime currentTime);
320
323 void implementChargingStrategy(SUMOTime begin, SUMOTime end, const double plannedCharge, const MSChargingStation* cs);
324
325private:
328
331
334
337
340
342 std::vector<std::pair<SUMOTime, double>> myChargeLimits;
343
346
349
352
355
358
361
364
367
370
373
376
379
382
385
388
391
394
397
400
403
406
407private:
410
413};
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
std::vector< MSEdge * > MSEdgeVector
Definition MSEdge.h:73
Battery device for electric vehicles.
A device which triggers rerouting to nearby charging stations.
double myUpdateSoC
SoC the last time the station finder algorithm was run completely.
void resetStoppingPlaceScores(SUMOVehicle &veh) override
forget all stopping place score for this vehicle
void setParameter(const std::string &key, const std::string &value) override
try to set the given parameter for this device. Throw exception for unsupported key
void notifyMoveInternal(const SUMOTrafficObject &veh, const double frontOnLane, const double timeOnLane, const double meanSpeedFrontOnLane, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane, const double meanLengthOnLane) override
Internal notification about the vehicle moves, see MSMoveReminder::notifyMoveInternal()
void rememberBlockedStoppingPlace(SUMOVehicle &veh, const MSStoppingPlace *stoppingPlace, bool blocked) override
store the blocked stopping place in the vehicle
WrappingCommand< MSDevice_StationFinder > * myRescueCommand
The command responsible for rescue actions.
void implementChargingStrategy(SUMOTime begin, SUMOTime end, const double plannedCharge, const MSChargingStation *cs)
ChargingStrategy myChargingStrategy
The chosen charging strategy.
SUMOTime teleportToChargingStation(const SUMOTime currentTime)
search for a charging station and teleport the vehicle there as a rescue measure
double myDistanceToOriginalStop
The distance in meters to the original stop replaced by the charging stop (models charging close to t...
MSVehicle & myVeh
myHolder cast to needed type
double getStoppingPlaceOccupancy(MSStoppingPlace *stoppingPlace) override
Return the number of occupied places of the StoppingPlace.
MSDevice_StationFinder & operator=(const MSDevice_StationFinder &)
Invalidated assignment operator.
MSStoppingPlace * myChargingStation
To which station we are currently travelling.
WrappingCommand< MSDevice_StationFinder > * myChargeLimitCommand
The command responsible for limiting the charging rate (~ implement charging strategies)
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_StationFinder-options.
int getNumberStoppingPlaceReroutes(SUMOVehicle &veh) override
ask how many times already the vehicle has been rerouted to another stopping place
const std::string getChargingStrategy() const
return the string representation of the chosen charging strategy
double myTargetSoC
The target state of charge where the vehicle stops charging.
const std::string deviceName() const override
return the name for this type of device
std::string getParameter(const std::string &key) const override
try to retrieve the given parameter from this device. Throw exception for unsupported key
bool rerouteToChargingStation(bool replace=false)
reroute to a charging station
double myRescueTime
The time to wait for a rescue vehicle in case the battery is empty.
SUMOTime myLastChargeCheck
Last time the SoC was checked.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
void initRescueCommand()
create the event command for teleporting in case of brake-down
bool useStoppingPlace(MSStoppingPlace *stoppingPlace) override
Whether the stopping place should be included in the search (can be used to add an additional filter)
double getLastStepStoppingPlaceOccupancy(MSStoppingPlace *stoppingPlace) override
Return the number of occupied places of the StoppingPlace from the previous time step.
double getStoppingPlaceCapacity(MSStoppingPlace *stoppingPlace) override
Return the number of places the StoppingPlace provides.
void rememberStoppingPlaceScore(SUMOVehicle &veh, MSStoppingPlace *place, const std::string &score) override
store the stopping place score in the vehicle
void saveState(OutputDevice &out) const override
Saves the state of the device.
SUMOTime myWaitForCharge
Accepted waiting time at the charging station before a place becomes available.
SUMOTime myLastSearch
Last time charging stations have been searched.
void setNumberStoppingPlaceReroutes(SUMOVehicle &veh, int value) override
update the number of reroutes for the vehicle
SUMOTime sawBlockedStoppingPlace(SUMOVehicle &veh, MSStoppingPlace *place, bool local) override
ask the vehicle when it has seen the stopping place
double mySearchSoC
The state of charge at which the vehicle starts looking for charging stations.
SUMOTime myArrivalAtChargingStation
Arrival time in the vicinity of the target charging station (to track the waiting time before accessi...
double myEmptySoC
The state of charge threshold below which rescue mode is activated.
double myMaxEuclideanDistance
The maximum euclidean distance between the vehicle and the charging station (-1 deactivates the condi...
bool validComponentValues(StoppingPlaceParamMap_t &stoppingPlaceValues) override
Whether the stopping place should be discarded due to its results from the component evaluation.
bool notifyIdle(SUMOTrafficObject &veh) override
Computes idling emission values and adds them to the emission sums.
void generateOutput(OutputDevice *tripinfoOut) const override
Called on writing tripinfo output.
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouter(SUMOVehicle &veh, const MSEdgeVector &prohibited) override
Provide the router to use (MSNet::getRouterTT or MSRoutingEngine)
MSDevice_Battery * myBattery
The corresponding battery device.
MSChargingStation * findChargingStation(SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, double expectedConsumption, StoppingPlaceParamMap_t &scores, bool constrainTT=true, bool skipVisited=true, bool skipOccupied=false)
central search function for close charging stations
ChargeType myChargeType
The type of charging permitted by the battery (charging, bidirectional, battery exchange)
void setBattery(MSDevice_Battery *battery)
bool alreadyPlannedCharging()
adopt a planned charging stop outside of the device
double freeSpaceAtChargingStation(MSChargingStation *cs) const
compute the free space at a charging station
std::vector< std::pair< SUMOTime, double > > myChargeLimits
The next charging rates to set via myChargingRateCommand.
SUMOTime myRadius
The max travel time to the next charging station.
SearchState mySearchState
The current state of the charging search (remember for decision logic)
SUMOTime myRepeatInterval
Time interval to search again for a charging station if the first attempt failed.
bool evaluateCustomComponents(SUMOVehicle &veh, double brakeGap, bool newDestination, MSStoppingPlace *alternative, double occupancy, double prob, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, StoppingPlaceParamMap_t &stoppingPlaceValues, ConstMSEdgeVector &newRoute, ConstMSEdgeVector &stoppingPlaceApproach, StoppingPlaceParamMap_t &maxValues, StoppingPlaceParamMap_t &addInput) override
Compute some custom target function components.
SUMOTime updateChargeLimit(const SUMOTime currentTime)
update the maximum charge rate of the battery to simulate charging strategies
double myMaxChargePower
The maximum charging speed of the vehicle battery in W.
double myReplacePlannedStop
The share of stopping time a charging stop should take from the next regulr (non-charging) stop under...
RescueAction myRescueAction
What to do when the state of charge gets very low.
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed) override
Computes current emission values and adds them to their sums.
void loadState(const SUMOSAXAttributes &attrs) override
Loads the state of the device from the given description.
SUMOTime myCheckInterval
Time interval after which the SoC has to be checked.
double myReserveFactor
The safety buffer when calculating expected consumption.
MSDevice_StationFinder(const MSDevice_StationFinder &)
Invalidated copy constructor.
void initChargeLimitCommand()
create the event command for changing charging rates
double estimateConsumption(const MSEdge *target=nullptr, const bool includeEmptySoC=true, const double stopDiscount=0.) const
estimate the energy needed for the planned route / up to a target edge
A road/street connecting two junctions.
Definition MSEdge.h:77
A lane area vehicles can halt at.
std::map< std::string, double > StoppingPlaceParamMap_t
Abstract in-vehicle device.
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
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
A wrapper for a Command function.