Resolve DataRecorder off-by-one timestamp error#3299
Merged
Conversation
ef270a4 to
12b3b67
Compare
quaquel
approved these changes
Feb 13, 2026
|
Performance benchmarks:
|
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.
Summary
This PR fixes the "off-by-one" recording error in the experimental
DataRecorder(introduced in #3145) by correctly aligning the recorded data with its actual chronological timestamp.Bug / Issue
In the new Discrete Event Simulation (DES) architecture, the
DataRecorderexhibits a bug where it permanently captures the "past" state of the model, but tags it with the "future" timestamp.The root cause lies in the execution order of the DES engine:
self.time = event.time).event.execute()).Because
model.timeis anObservable, updating the clock in step 2 instantly broadcasts aCHANGEDsignal. TheDataRecorderreacts to this signal and takes a snapshot of the agents before they are actually allowed to execute their logic in step 3.Previously, the recorder was tagging this snapshot with the$t=1.0$ , the $t=1.0$ state was labeled as $t=2.0$ , and so on, permanently shifting the data one step out of alignment.
newtime signal. This meant the initial state was being recorded and labeled asImplementation
This PR resolves the timestamp misalignment by extracting the pre-transition time from the
Observablesignal by changing the timestamp assignment in_on_time_changeto usecurrent_time = signal.additional_kwargs.get("old").Fixes #3297