feat(ev): EV contrib compatible with DSim#4834
Merged
Merged
Conversation
Signed-off-by: Janek Laudan <laudan@simunto.com>
…e local to the SimProcess and should be called by that process. Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
…module work with DSim and QSim Signed-off-by: Janek Laudan <laudan@simunto.com>
…ingHandler. * Before nothing would be processed, as the handler would wait for a later timestep * Add unit test to cover this edge case * Adjust existing test to new slightly higher energy consumption Signed-off-by: Janek Laudan <laudan@simunto.com>
* Compares events relevant for DriveDischarging between QSim and DSim * Verifies overall Discharge to fixed amount Signed-off-by: Janek Laudan <laudan@simunto.com>
* The current implementation modifies the state of agents queueing for a charger. Since SimProcess doesn't keep track of agents it cannot provide the MobsimAgents to the Handler. By acting as an ActivityEngine we have direct access to the agents we want to modify the plans of. I think this is a better design in terms of ownership * Bind ActivityEngineDefaultImpl as ActivityEngine, so that it becomnes injectable. We need this as the ChargingHandler delegates activity handling to the Default activity engine. * Extend ChargingListener to include QuitQueueAtCharger Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
…ation is set Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
…ault activity engine as singleton qsim component Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
# Conflicts: # contribs/ev/src/test/java/org/matsim/contrib/ev/discharging/DriveDischargingHandlerTest.java
Signed-off-by: Janek Laudan <laudan@simunto.com>
…ferences. * EVs are sent as messages and circular references are hard to serialize. Therore remove the backpointer and pass the battery into the BatteryCharging, as this is the only thing used from the EV. Signed-off-by: Janek Laudan <laudan@simunto.com>
…ferences. * EVs are sent as messages and circular references are hard to serialize. Therore remove the backpointer and pass the battery into the BatteryCharging, as this is the only thing used from the EV. Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
* Create concrete ElectricFleet implementation for QSim instead of provider/lambda construct. This is more straight forward. * Clear usages of getElectricVehicles in favor of hasVehicle/getVehicle which keeps the internal collection private Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
…ding engine type. Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
…ler.java * Cleanup module code and rename references to constants * add new expected output, as all events are shifted one second (The engine does not have a delay of one second, which is actually correct) Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
…entation for other mobsims (QSim) Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
# Conflicts: # contribs/distributed-simulation/src/test/java/org/matsim/dsim/DistributedEventsManagerTest.java # contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/insertion/extensive/MultiInsertionDetourPathCalculatorManager.java # contribs/ev/src/test/java/org/matsim/contrib/ev/extensions/battery_chargers/TestScenarioBuilder.java
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
…dule Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
Signed-off-by: Janek Laudan <laudan@simunto.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR makes the infrastructure in ev contrib compatible with DSim. It only changes the parts related to the simulation. Statistics are not touched yet and do not work correctly with DSim. This will be fixed in a separate PR.
Mostly it makes the used engines and Handlers aware of partitions. Things that had to be changed:
ChargerInfrastructureis created per simulation process: Only chargers located on the partition are added to the infrastructure collectionElectricFleet interface better schields the underlying vehicle collections and has two implementations:GlobalElectricFleetcreates all EVs at the beginning of an iteration. This variant can be used for a QSim.DistributedElectricFleetcreates EVs lazily when queried for it. It also listenes for vehicles leaving partition and transfer the charging state of the corresponding EV to the next partition. Callers are responsible for only quering EVs that are actually present on the partition. Otherwise the distributed fleet will create duplicate vehicles.DistributedDriveDischargeHandleris partition aware and sends drive state to other partitions when vehicles cross partition boundaries. The handler dispatchesDischargeEventsimmediately instead of delaying them for one second, as there are no race conditions between mobsim and event handling in DSimVehicleChargeHandleris nowChargingActivityEngine. This handler queried the mobsim for agents, which is not supported by DSim. Agents are added to this engine if they want to perform a charging activity. This way it is not necessary to query the global agent state of the mobsim. Also, the engine has ownership of agents peforming a charging activity, which is a cleaner desing, since the Engine is modifying the agent plans if they are queuing at a chargerDistributedWithinDayEvEnginemimics the behavior of theWithinDayEvEngine. Since the distributed simulation cannot give global access to agents the new engine acts as an activity engine. When agents start an activity we can be sure to have a local reference to that agent and that altering an agentś plan is save at that moment. It also is a departure handler for the same reason. Agents can find charging alternatives on departure. The engine always returnsfalsefor departures, signalling, that another engine should actually handle the agent`s leg.DistributedChargingReservationManagerprovides functionality to reserve chargers across domain boundaries. Agents can request a reservation for a charger and the manager requests the reservation from the on the partition where the charger is located. The new manager uses a callback to inform callees about the result of the reservation request, as the described roundtrip takes at least one simulation time step.Breaking changes
(dis)charging events are generated one timestep earlier compared to the original QSim code. Event handlers can be called directly from the simulation process so that it is not necessary to mitigate for race conditions between mobsim and event handling. The original code did that by delaying calculations and event dispatch by one second. I think not waiting one second is closer to the expected outcome and justifies a breaking change.
Plug- and Unplug events have different timestamps for the same reason.
Reservations may take +1 time step, as making a reservation might require a messaging roundtrip to another partion. This is also not deterministic at the moment and depends on where chargers are located.