Skip to content

[FEATURE] Build an Event queue system #50

@Jamesflynn1

Description

@Jamesflynn1

Is your feature request related to a problem? Please describe.
I want to be able to move the time variables into a unified system with other time series. I want to be able to read a time series that specifies model variables. I want to be able calculate the time to next model variable change - for skipping ahead in model solvers.

Describe the solution you'd like
Different frequencies of repetition - daily, monthly, weekly, yearly, one off.
Each frequency has its own queue - this reduces the time to find the next event(s) to only linear in the number of frequencies rather than log(events) (which is the best possible with a self-sorting data structure).

We can maintain an order queue if events are processed through in order.

We maintain the invariant that max element in the queue is the last removed min element (min_time + repetition_interval > all other times). This invariant is true if all event are within repetition_interval of the minimum time. - REWORD

We can infact use an array, and cycle through the array continually. This will remove the need to add/remove elements from the queue and improve performance at the cost of keeping an index for each "queue".

Additionally, we will introduce a dynamic add_event. This will require a sorted data structure to ensure we know the minimum event. Using this feature will incur a performance hit. When the dynamic event is triggered, if it repeats with a frequency it will be added to the static queues as the invariant will now hold.

Describe alternatives you've considered
The current system allows global variables to change according to dynamics defined in the model state class.

However, the current system requires code changes in model state which is not ideal. The current system does not allow for imported time series from a file to dictate dynamics.

Additional context
Required to add a time series of events. #9

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions