I would like to represent the predicted state of an element of my system in the future. The element can either be in state S1
or S2
. S1 predictions are non-overlapping intervals of the form <t_start, t_end>
where the t_
s are relative times in the future. The absence of an S1
interval implies the state is S2
and only S1
predictions are ever made. The main operations are adding predicted intervals and querying the state for an arbitrary future time. State queries will happen a couple of orders of magnitude more frequently than queries. Intervals can be added for any time in a finite horizon, in any order relative to existing intervals. The other important operation is the progress of time, which means that predictions get closer and eventually pass into the past where they can be forgotten. Predictions may be removed very infrequently, but this isn't essential. The underlying model of time could be continuous, or discretised to integer timesteps.
I already have an implementation of this using a linked list where the position in the list represents time (using time discretised to integers) and the node content is either S1
or S2
. This is great for updating as time proceeds (you just the drop the first node), and reasonably fast to query (linear in number of future time steps). However, because you're enumerating all possible timeslices it is a little ugly in terms of adding predictions, and it scales badly as you increase the time horizon or the precision of the timeslice. I am therefore looking for an alternative approach (e.g. based on interval somehow).