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#define DEFAULT_OPPORTUNITY_INTERVAL 1800 // s
35
36// ===========================================================================
37// class declarations
38// ===========================================================================
40class MSStoppingPlace;
41
42
43// ===========================================================================
44// class definitions
45// ===========================================================================
57public:
64
70
76
85
88 static void insertOptions(OptionsCont& oc);
89
90
103 static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
104
110
113
116
131 bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed) override;
132
142 bool notifyIdle(SUMOTrafficObject& veh) override;
143
145
150 void saveState(OutputDevice& out) const override;
151
156 void loadState(const SUMOSAXAttributes& attrs) override;
157
159 const std::string deviceName() const override {
160 return "stationfinder";
161 }
162
164 const std::string getChargingStrategy() const {
166 return "none";
168 return "balanced";
169 } else {
170 return "latest";
171 }
172 }
173
180 void generateOutput(OutputDevice* tripinfoOut) const override;
181
183 myBattery = battery;
184 }
185
186 std::string getParameter(const std::string& key) const override;
187
189 void setParameter(const std::string& key, const std::string& value) override;
190
206 bool evaluateCustomComponents(SUMOVehicle& veh, double brakeGap, bool newDestination,
207 MSStoppingPlace* alternative, double occupancy, double prob,
209 ConstMSEdgeVector& newRoute,
210 ConstMSEdgeVector& stoppingPlaceApproach,
211 StoppingPlaceParamMap_t& maxValues,
212 StoppingPlaceParamMap_t& addInput) override;
213
215 bool validComponentValues(StoppingPlaceParamMap_t& stoppingPlaceValues) override;
216
218 bool useStoppingPlace(MSStoppingPlace* stoppingPlace) override;
219
222
224 double getStoppingPlaceOccupancy(MSStoppingPlace* stoppingPlace) override;
225
227 double getLastStepStoppingPlaceOccupancy(MSStoppingPlace* stoppingPlace) override;
228
230 double getStoppingPlaceCapacity(MSStoppingPlace* stoppingPlace) override;
231
233 void rememberBlockedStoppingPlace(SUMOVehicle& veh, const MSStoppingPlace* stoppingPlace, bool blocked) override;
234
236 void rememberStoppingPlaceScore(SUMOVehicle& veh, MSStoppingPlace* place, const std::string& score) override;
237
239 void resetStoppingPlaceScores(SUMOVehicle& veh) override;
240
242 SUMOTime sawBlockedStoppingPlace(SUMOVehicle& veh, MSStoppingPlace* place, bool local) override;
243
246
248 void setNumberStoppingPlaceReroutes(SUMOVehicle& veh, int value) override;
249
250protected:
255 const double frontOnLane,
256 const double timeOnLane,
257 const double meanSpeedFrontOnLane,
258 const double meanSpeedVehicleOnLane,
259 const double travelledDistanceFrontOnLane,
260 const double travelledDistanceVehicleOnLane,
261 const double meanLengthOnLane) override;
262
263private:
276 SUMOVehicle>& router,
277 double expectedConsumption,
279 bool constrainTT = true, bool skipVisited = true, bool skipOccupied = false, bool visible = false);
280
281
287 bool rerouteToChargingStation(bool replace = false);
288
289
295
296
300
308 double estimateConsumption(const MSEdge* target = nullptr, const bool includeEmptySoC = true, const double stopDiscount = 0.) const;
309
316
322
325 void initRescueCommand();
326
330
333 SUMOTime updateChargeLimit(const SUMOTime currentTime);
334
337 void implementChargingStrategy(SUMOTime begin, SUMOTime end, const double plannedCharge, const MSChargingStation* cs);
338
339private:
342
345
348
351
354
356 std::vector<std::pair<SUMOTime, double>> myChargeLimits;
357
360
363
366
369
372
375
378
381
384
387
390
393
396
399
402
405
408
411
414
417
420
423
426
429
430private:
433
436};
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)
SUMOTime myLastOpportunisticSearch
Last time charging stations have been searched for opportunistic charging.
ChargingStrategy myChargingStrategy
The chosen charging strategy.
MSChargingStation * findChargingStation(SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, double expectedConsumption, StoppingPlaceParamMap_t &scores, bool constrainTT=true, bool skipVisited=true, bool skipOccupied=false, bool visible=false)
central search function for close charging stations
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
double myOpportunitySoC
The state of charge at/below which the vehicle is interested in charging although it may still be suf...
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.
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.
bool planOpportunisticCharging()
check which stop is suited for opportunistic charging and try to plan charging stops
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.
SUMOTime myMinOpportunisticTime
Minimal expected stop duration to allow for opportunistic charging (not needed to complete the route)
double myReplacePlannedStop
The share of stopping time a charging stop should take from the next regular (non-charging) stop unde...
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.