Skip to content

Refactor Real Life Challenges simulator - #373

Draft
j-atkins wants to merge 30 commits into
cruise-datafrom
refactor-problem-sim
Draft

Refactor Real Life Challenges simulator#373
j-atkins wants to merge 30 commits into
cruise-datafrom
refactor-problem-sim

Conversation

@j-atkins

@j-atkins j-atkins commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary of Changes

This PR refactors the problems/Real Life Challenges simulation module, execution loop, and checkpoint verification logic. Primary objectives are:

  • Decouple problem tracking from temporary JSON log files by utilizing ScheduledProblem and ActiveProblem objects as the single source of truth for problem states and resolution.
  • Unify execution, problem loading/selection, reporting, and expedition uniqueness checks directly into ProblemSimulator class rather than spreading the logic across _run.py.
  • Also move Checkpoint verification checks, whereas before there was too much problems module associated logic handled by Checkpoint.
  • Account for Port waypoints (see Timedeltas and arrival/departure ports from MFP export #372) when communicating waypoint numbers to the user via a new helper utility _get_public_wp()
  • Refactor_run.py: more helper functions, clean up.

Detailed Changes

problems/simulator.py

  • New ScheduledProblem dataclass (pairs a problem with its waypoint index and resolution state) and SelectedProblems dataclass as a container for managing problem states and iteration through problems.
  • Move/new execute_for_instrument(), verify_problem_resolution(), and create_post_expedition_report() methods directly to ProblemSimulator.
  • Updated problem logging, checkpoint handling, and report generation to map raw waypoint indices to public numbers using _get_public_wp().
  • Removed writing and reading separate problem_<hash>.json files per problem occurrence. Replaced with structured caching of SelectedProblems in the ProblemSimulator.

_run.py

  • Refactored _run() function by extracting steps into helper methods.
  • Moved problem initialisation/resolution checks entirely to ProblemSimulator.

checkpoint.py

  • Introduced ActiveProblem to track runtime problem states (delay duration, problem waypoint index, and resolution status).
  • Refactored Checkpoint.verify() into verify_past_schedule(), focusing solely on ensuring past waypoints are untouched and decoupling from problems logic.

expedition.py & utils.py

  • New _get_public_wp() in utils.py to translate raw/internal schedules into user-facing waypoint numbers. Helps ensure consistency and over-reliance on plus-one indexing in all cases.
  • Updated schedule validation error messages in expedition.py to use public waypoint numbers correctly.

Closes #283, closes #303

…m core checkpoint model, move away from reliance on problem-specific tracking via json tmp files
…m core checkpoint model, move away from reliance on problem-specific tracking via json tmp files
…e single source of truth for resolved status
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.

1 participant