Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External simulation: Providing information about next tick of MobSim #777

Merged
merged 25 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8b973ad
Providing detailed information about next tick per agent
sebastian-peter Mar 22, 2024
7c482ea
Removing unused scheduleKey
sebastian-peter Mar 22, 2024
3cd05a8
Towards a functioning ExtEvDataService...
sebastian-peter Mar 22, 2024
6fc8187
Removing PhaseSwitch implementation and utilization
sebastian-peter Mar 22, 2024
a49c0ff
Merge branch 'dev' into sp/#776-ext-sim-next-tick
sebastian-peter Apr 2, 2024
19bed20
More implementation & cleanup
sebastian-peter Apr 2, 2024
2ac0ceb
Adapting to changes in simonaAPI interface
sebastian-peter Apr 9, 2024
cf8237f
Merge branch 'refs/heads/dev' into sp/#776-ext-sim-next-tick
sebastian-peter Jun 21, 2024
b862035
Adapting changelog to changed issue
sebastian-peter Jun 21, 2024
54963e1
Merge branch 'refs/heads/dev' into sp/#776-ext-sim-next-tick
sebastian-peter Jul 23, 2024
46e5cbb
Merge branch 'refs/heads/dev' into sp/#776-ext-sim-next-tick
sebastian-peter Jul 23, 2024
500bc4d
Providing test for empty arrivals
sebastian-peter Jul 24, 2024
5d32101
Merge branch 'refs/heads/dev' into sp/#776-ext-sim-next-tick
sebastian-peter Aug 8, 2024
2d32cf3
Adapt to changed ev protocol
sebastian-peter Aug 8, 2024
a5753d5
Handling requests also in case activation has already arrived
sebastian-peter Aug 9, 2024
cfde81d
Merge branch 'refs/heads/dev' into sp/#776-ext-sim-next-tick
sebastian-peter Aug 9, 2024
1da5700
Explanatory commentary
sebastian-peter Aug 9, 2024
2b40f2e
Updating simonaAPI to release version 0.5
sebastian-peter Aug 9, 2024
1f0a885
Refactoring old EvMovement classes
sebastian-peter Aug 12, 2024
22450d0
Updating UML documentation related to mobility simulation (class diag…
sebastian-peter Aug 12, 2024
98a2016
Merge branch 'refs/heads/dev' into sp/#776-ext-sim-next-tick
sebastian-peter Aug 12, 2024
f74c24a
Improved format
sebastian-peter Aug 12, 2024
99d94e1
Merge branch 'refs/heads/dev' into sp/#776-ext-sim-next-tick
sebastian-peter Aug 14, 2024
fe0512a
Merge branch 'dev' into sp/#776-ext-sim-next-tick
danielfeismann Aug 15, 2024
d4308df
Merge branch 'refs/heads/dev' into sp/#776-ext-sim-next-tick
danielfeismann Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Merged `HpModelTestData` with `HpTestData` to `HpInputTestData` [#872](https://github.com/ie3-institute/simona/issues/872)
- Harmonised both methods that check the inner temperature of thermal house against the boundaries [#880](https://github.com/ie3-institute/simona/issues/880)
- Convert all `eval-rst` instances in rtd to myst syntax [#901](https://github.com/ie3-institute/simona/issues/901)
- External simulation should provide information about next tick of MobSim [#776](https://github.com/ie3-institute/simona/issues/776)

### Fixed
- Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ dependencies {
exclude group: 'edu.ie3'
}

implementation('com.github.ie3-institute:simonaAPI:0.4.0') {
implementation('com.github.ie3-institute:simonaAPI:0.5.0') {
exclude group: 'org.apache.logging.log4j'
exclude group: 'org.slf4j'
/* Exclude our own nested dependencies */
Expand Down
34 changes: 17 additions & 17 deletions docs/uml/main/ExtEvSimulationClasses.puml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ package ev-simulation {
package simona-api {
' MIDDLE PART
class ExtEvData {
~ LinkedBlockingQueue<ExtEvResponseMessage> receiveTriggerQueue
~ LinkedBlockingQueue<EvDataResponseMessageToExt> receiveTriggerQueue
- ActorRef dataService
- ActorRef extSimAdapter
+ List<UUID> requestAvailablePublicEvCs()
Expand Down Expand Up @@ -119,33 +119,33 @@ package simona-api {
EvModelImpl --|> EvModel


interface ExtEvMessage
interface EvDataMessageFromExt
class EvMovementsMessage {
- Map<UUID, List<EvMovement>> movements
}
class RequestEvcsFreeLots
RequestEvcsFreeLots --|> ExtEvMessage
EvMovementsMessage --|> ExtEvMessage
RequestEvcsFreeLots --|> EvDataMessageFromExt
EvMovementsMessage --|> EvDataMessageFromExt
RequestEvcsFreeLots -[hidden]> EvMovementsMessage

interface ExtEvResponseMessage
interface EvDataResponseMessageToExt
class AllDepartedEvsRepsonse {
- Map<UUID, List<EvMovement>> movements
}
class ProvideEvcsFreeLots
ProvideEvcsFreeLots --|> ExtEvResponseMessage
AllDepartedEvsRepsonse --|> ExtEvResponseMessage
ExtEvData -> ExtEvMessage
ExtEvData -> ExtEvResponseMessage
ProvideEvcsFreeLots --|> EvDataResponseMessageToExt
AllDepartedEvsRepsonse --|> EvDataResponseMessageToExt
ExtEvData -> EvDataMessageFromExt
ExtEvData -> EvDataResponseMessageToExt
EvMovement -[hidden]-> RequestEvcsFreeLots
ExtEvMessage -[hidden]> ExtEvResponseMessage
EvDataMessageFromExt -[hidden]> EvDataResponseMessageToExt
EvMovementsMessage -[hidden]> ProvideEvcsFreeLots
ProvideEvcsFreeLots -[hidden]> AllDepartedEvsRepsonse

class ScheduleDataServiceMessage {
- ExtEvDataService dataService
}
ExtEvResponseMessage -[hidden]> ScheduleDataServiceMessage
EvDataResponseMessageToExt -[hidden]> ScheduleDataServiceMessage
ExtEvData -> ScheduleDataServiceMessage


Expand All @@ -158,10 +158,10 @@ package simona-api {
ExtLink --|> ExtLinkInterface

interface ExtTrigger
class ActivityStartTrigger {
class ActivationMessage {
- Long tick
}
ActivityStartTrigger --|> ExtTrigger
ActivationMessage --|> ExtTrigger

interface ExtTriggerResponse
class CompletionMessage {
Expand All @@ -188,7 +188,7 @@ package simona {

class SimonaSim

class SimScheduler
class Scheduler

class SimonaStandaloneSetup

Expand All @@ -198,12 +198,12 @@ package simona {

class ExtEvDataService

SimScheduler -- SimonaSim
Scheduler -- SimonaSim
SimonaSim *- SimonaStandaloneSetup
SimonaStandaloneSetup *- ExtSimLoader

ExtSimAdapter -- SimScheduler
ExtEvDataService -- SimScheduler
ExtSimAdapter -- Scheduler
ExtEvDataService -- Scheduler

SecondaryData <|-- EvMovementData

Expand Down
218 changes: 161 additions & 57 deletions docs/uml/protocol/ExtEvSimulationSequence.puml
Original file line number Diff line number Diff line change
Expand Up @@ -2,97 +2,201 @@

!theme plain

participant Scheduler
participant ExtSimAdapter
participant ExtSimulation
participant ExtEvDataService
participant EvcsAgent1
participant EvcsAgent2

==Init==
SimScheduler -> ExtSimAdapter: <font color=red>!</font> <font color=green>ActivityStartTrigger(-1L)</font>
Scheduler -> EvcsAgent1: <font color=red>!</font> Activation(-1)
activate EvcsAgent1

EvcsAgent1 -> ExtEvDataService: <font color=red>!</font> RegisterForEvDataMessage
deactivate EvcsAgent1

Scheduler -> EvcsAgent2: <font color=red>!</font> Activation(-1)
activate EvcsAgent2

EvcsAgent2 -> ExtEvDataService: <font color=red>!</font> RegisterForEvDataMessage
deactivate EvcsAgent2

Scheduler -> ExtSimAdapter: <font color=red>!</font> <font color=green>Activation(-1)</font>
activate ExtSimAdapter

ExtSimAdapter -> ExtSimulation: queue(ActivityStartTrigger(-1L))
ExtSimAdapter -> ExtSimulation: queue(ActivationMessage(-1))
deactivate ExtSimAdapter
activate ExtSimulation

... Initialize external mobility simulation ...
ExtSimulation -> ExtEvDataService: ProvideArrivingEvs(_, t1)

ExtSimulation -> ExtSimAdapter: <font color=red>!</font> CompletionMessage(newTriggers)
deactivate ExtSimulation
ExtSimulation -> ExtSimAdapter: <font color=red>!</font> ScheduleDataServiceMessage(\n\tdataServiceRef\n)
activate ExtSimAdapter

ExtSimAdapter -> SimScheduler: <font color=red>!</font> <font color=green>CompletionMessage(newTriggers)</font>
ExtSimAdapter -> Scheduler: <font color=red>!</font> ScheduleActivation(\n\t_, dataServiceRef)
deactivate ExtSimAdapter
activate Scheduler

Scheduler -> ExtEvDataService: <font color=red>!</font> Activation(t1)
deactivate Scheduler
activate ExtEvDataService

==Sim==
SimScheduler -> ExtSimAdapter: <font color=red>!</font> <font color=green>ActivityStartTrigger(tick)</font>
ExtSimulation -> ExtSimAdapter: <font color=red>!</font> CompletionMessage(newTriggers)
deactivate ExtSimulation
activate ExtSimAdapter

ExtSimAdapter -> ExtSimulation: queue(ActivityStartTrigger(tick))
ExtSimAdapter -> Scheduler: <font color=red>!</font> <font color=green>Completion(newTriggers)</font>
deactivate ExtSimAdapter

activate ExtSimulation
ExtSimulation -> ExtEvDataService: <font color=red>!</font> RequestEvcsFreeLots
ExtSimulation -> ExtSimAdapter: <font color=red>!</font> ScheduleDataServiceMessage(\n\tdataServiceRef\n)

activate ExtSimAdapter
ExtSimAdapter -> SimScheduler: <font color=red>!</font> ScheduleTriggerMessage(\n\t_, dataServiceRef)
deactivate ExtSimAdapter
ExtEvDataService -> EvcsAgent1: <font color=red>!</font> RegistrationSuccessfulMessage(t1)
activate EvcsAgent1

activate SimScheduler
SimScheduler -> ExtEvDataService: <font color=red>!</font> ActivityStartTrigger(tick)
deactivate SimScheduler
EvcsAgent1 -> Scheduler: <font color=red>!</font> Completion(t1)
deactivate EvcsAgent1

activate ExtEvDataService
ExtEvDataService -> EvcsAgent1: <font color=red>!</font> EvFreeLotsRequest(tick)
activate EvcsAgent1
ExtEvDataService -> EvcsAgent2: <font color=red>!</font> EvFreeLotsRequest(tick)
ExtEvDataService -> EvcsAgent2: <font color=red>!</font> RegistrationSuccessfulMessage(t1)
activate EvcsAgent2

ExtEvDataService -> SimScheduler: <font color=red>!</font> CompletionMessage(None)

EvcsAgent2 -> ExtEvDataService: <font color=red>!</font> FreeLotsResponse(_, _)
EvcsAgent2 -> Scheduler: <font color=red>!</font> Completion(t1)
deactivate EvcsAgent2
EvcsAgent1 -> ExtEvDataService: <font color=red>!</font> FreeLotsResponse(_, _)
deactivate EvcsAgent1
ExtEvDataService -> ExtSimulation: queue(ProvideEvcsFreeLots(_))

ExtEvDataService -> Scheduler: <font color=red>!</font> Completion(None)
deactivate ExtEvDataService

... Running external mobility simulation,\n determining EV positions ...
ExtSimulation -> ExtEvDataService: <font color=red>!</font> EvMovementsMessage(_)
ExtSimulation -> ExtSimAdapter: <font color=red>!</font> ScheduleDataServiceMessage(\n\tdataServiceRef\n)
==Simulation==
Scheduler -> EvcsAgent1: <font color=red>!</font> Activation(t1)
Scheduler -> EvcsAgent2: <font color=red>!</font> Activation(t1)

Scheduler -> ExtSimAdapter: <font color=red>!</font> <font color=green>Activation(t1)</font>
activate ExtSimAdapter
ExtSimAdapter -> SimScheduler: <font color=red>!</font> ScheduleTriggerMessage(\n\t_, dataServiceRef)

ExtSimAdapter -> ExtSimulation: queue(ActivationMessage(t1))
deactivate ExtSimAdapter
activate ExtSimulation

activate SimScheduler
SimScheduler -> ExtEvDataService: <font color=red>!</font> ActivityStartTrigger(tick)
deactivate SimScheduler
group Request free lots
ExtSimulation -> ExtEvDataService: <font color=red>!</font> RequestEvcsFreeLots

activate ExtEvDataService
ExtEvDataService -> EvcsAgent1: <font color=red>!</font> ProvideEvDataMessage(\n\ttick, _)
ExtEvDataService -> EvcsAgent2: <font color=red>!</font> ProvideEvDataMessage(\n\ttick, _)
ExtEvDataService -> SimScheduler: <font color=red>!</font> CompletionMessage(evcsTriggers)
deactivate ExtEvDataService
ExtSimulation -> ExtSimAdapter: <font color=red>!</font> ScheduleDataServiceMessage(\n\tdataServiceRef\n)
activate ExtSimAdapter

activate SimScheduler
SimScheduler -> EvcsAgent1: <font color=red>!</font> ActivityStartTrigger(tick)
activate EvcsAgent1
SimScheduler -> EvcsAgent2: <font color=red>!</font> ActivityStartTrigger(tick)
deactivate SimScheduler
ExtSimAdapter -> Scheduler: <font color=red>!</font> ScheduleActivation(\n\t_, dataServiceRef)
deactivate ExtSimAdapter
activate Scheduler

activate EvcsAgent2
EvcsAgent1 -> SimScheduler: <font color=red>!</font> CompletionMessage(None)
deactivate EvcsAgent1
Scheduler -> ExtEvDataService: <font color=red>!</font> Activation(t1)
deactivate Scheduler
activate ExtEvDataService

EvcsAgent2 -> ExtEvDataService: <font color=red>!</font> DepartedEvsResponse(_, _)
activate ExtEvDataService
EvcsAgent2 -> SimScheduler: <font color=red>!</font> CompletionMessage(None)
deactivate EvcsAgent2
ExtEvDataService -> EvcsAgent1: <font color=red>!</font> EvFreeLotsRequest(t1)
activate EvcsAgent1

ExtEvDataService -> ExtSimulation: queue(AllDepartedEvsResponse(_))
deactivate ExtEvDataService
ExtEvDataService -> EvcsAgent2: <font color=red>!</font> EvFreeLotsRequest(t1)
activate EvcsAgent2

ExtSimulation -> ExtSimAdapter: <font color=red>!</font> CompletionMessage(newTriggers)
deactivate ExtSimulation
ExtEvDataService -> Scheduler: <font color=red>!</font> Completion(None)

EvcsAgent2 -> ExtEvDataService: <font color=red>!</font> FreeLotsResponse(_, _)
deactivate EvcsAgent2

EvcsAgent1 -> ExtEvDataService: <font color=red>!</font> FreeLotsResponse(_, _)
deactivate EvcsAgent1

ExtEvDataService -> ExtSimulation: queue(ProvideEvcsFreeLots(_))
deactivate ExtEvDataService
end

group Request current prices (dummy implementation)
ExtSimulation -> ExtEvDataService: <font color=red>!</font> RequestCurrentPrices

ExtSimulation -> ExtSimAdapter: <font color=red>!</font> ScheduleDataServiceMessage(\n\tdataServiceRef\n)
activate ExtSimAdapter

ExtSimAdapter -> Scheduler: <font color=red>!</font> ScheduleActivation(\n\t_, dataServiceRef)
deactivate ExtSimAdapter
activate Scheduler

Scheduler -> ExtEvDataService: <font color=red>!</font> Activation(t1)
deactivate Scheduler
activate ExtEvDataService

ExtEvDataService -> ExtSimulation: queue(ProvideCurrentPrices(_))

ExtEvDataService -> Scheduler: <font color=red>!</font> Completion(None)

deactivate ExtEvDataService
end

group Request departing EVs
ExtSimulation -> ExtEvDataService: <font color=red>!</font> RequestDepartingEvs

ExtSimulation -> ExtSimAdapter: <font color=red>!</font> ScheduleDataServiceMessage(\n\tdataServiceRef\n)
activate ExtSimAdapter

ExtSimAdapter -> Scheduler: <font color=red>!</font> ScheduleActivation(\n\t_, dataServiceRef)
deactivate ExtSimAdapter
activate Scheduler

Scheduler -> ExtEvDataService: <font color=red>!</font> Activation(t1)
deactivate Scheduler
activate ExtEvDataService

ExtEvDataService -> EvcsAgent1: <font color=red>!</font> DepartingEvsRequest(t1)
activate EvcsAgent1

ExtEvDataService -> EvcsAgent2: <font color=red>!</font> DepartingEvsRequest(t1)
activate EvcsAgent2

ExtEvDataService -> Scheduler: <font color=red>!</font> Completion(None)

EvcsAgent2 -> ExtEvDataService: <font color=red>!</font> DepartingEvsResponse(_, _)
deactivate EvcsAgent2

EvcsAgent1 -> ExtEvDataService: <font color=red>!</font> DepartingEvsResponse(_, _)
deactivate EvcsAgent1

ExtEvDataService -> ExtSimulation: queue(ProvideDepartingEvs(_))
deactivate ExtEvDataService
end

... Running external mobility simulation,\n determining EV positions ...

group Provide arriving EVs
ExtSimulation -> ExtEvDataService: <font color=red>!</font> ProvideArrivingEvs(_)
ExtSimulation -> ExtSimAdapter: <font color=red>!</font> ScheduleDataServiceMessage(\n\tdataServiceRef\n)
activate ExtSimAdapter

ExtSimAdapter -> Scheduler: <font color=red>!</font> ScheduleActivation(\n\t_, dataServiceRef)
deactivate ExtSimAdapter
activate Scheduler

Scheduler -> ExtEvDataService: <font color=red>!</font> Activation(t1)
deactivate Scheduler
activate ExtEvDataService

ExtEvDataService -> EvcsAgent1: <font color=red>!</font> ProvideEvDataMessage(evs, t2)
activate EvcsAgent1

ExtEvDataService -> EvcsAgent2: <font color=red>!</font> ProvideEvDataMessage(evs, t2)
activate EvcsAgent2

ExtEvDataService -> Scheduler: <font color=red>!</font> Completion(None)
deactivate ExtEvDataService

EvcsAgent1 -> Scheduler: <font color=red>!</font> Completion(t2)
deactivate EvcsAgent1

EvcsAgent2 -> Scheduler: <font color=red>!</font> Completion(t2)
deactivate EvcsAgent2
end

ExtSimulation -> ExtSimAdapter: <font color=red>!</font> CompletionMessage(t2)
deactivate ExtSimulation
activate ExtSimAdapter
ExtSimAdapter -> SimScheduler: <font color=red>!</font> <font color=green>CompletionMessage(newTriggers)</font>

ExtSimAdapter -> Scheduler: <font color=red>!</font> <font color=green>Completion(t2)</font>
deactivate ExtSimAdapter

@enduml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import edu.ie3.simona.agent.EnvironmentRefs
import edu.ie3.simona.agent.em.EmAgent
import edu.ie3.simona.agent.participant.ParticipantAgent.ParticipantMessage
import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService.{
ActorEvMovementsService,
ActorExtEvDataService,
ActorWeatherService,
}
import edu.ie3.simona.agent.participant.evcs.EvcsAgent
Expand Down Expand Up @@ -666,7 +666,7 @@ class GridAgentController(
modelConfiguration,
primaryServiceProxy,
Iterable(
ActorEvMovementsService(
ActorExtEvDataService(
evMovementsService
)
),
Expand Down
Loading