Skip to content

Fix bug in simulator result file#89

Merged
FelixStege merged 2 commits intomainfrom
79-fix-simulatir-results-file
Feb 26, 2026
Merged

Fix bug in simulator result file#89
FelixStege merged 2 commits intomainfrom
79-fix-simulatir-results-file

Conversation

@FelixStege
Copy link
Contributor

Closes #79

@FelixStege FelixStege self-assigned this Feb 25, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the simulator’s result logging to better align input snapshots with communication-step timestamps, addressing Issue #79 where result files could end up with incorrect/undesired time indexing/row alignment.

Changes:

  • Always logs inputs at communication-step boundaries (in addition to logging when inputs change) to keep result rows consistent.
  • Minor comment formatting cleanup in the simulation loop.

Comment on lines +592 to +595
current_time = self.env.time
# Track if a communication step is reached.
# At communication times, the inputs are always saved
full_comm_step = ((current_time - self._last_communication_time) == 0)
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

full_comm_step relies on exact float equality ((current_time - self._last_communication_time) == 0). With env.time advancing via floating-point additions, this can fail due to rounding and prevent inputs from being logged at communication boundaries (leaving the most recent output row’s inputs as None). Consider using a tolerant comparison (e.g., math.isclose with an abs_tol) or a step-index based check (e.g., i == 0 for the first sub-step of each communication interval).

Suggested change
current_time = self.env.time
# Track if a communication step is reached.
# At communication times, the inputs are always saved
full_comm_step = ((current_time - self._last_communication_time) == 0)
# Track if this is the first simulation sub-step within the current
# communication interval. At communication boundaries, the inputs are
# always saved to ensure they are associated with the correct outputs.
full_comm_step = (i == 0)

Copilot uses AI. Check for mistakes.
@FelixStege FelixStege merged commit 60c16a7 into main Feb 26, 2026
20 checks passed
@FelixStege FelixStege deleted the 79-fix-simulatir-results-file branch February 26, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New simulator results file has wrong index

3 participants