Add checkpoints to PopulationTrips so runs restart from the last computed iteration #261
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.
This PR adds crash-safe checkpointing and automatic resume to
PopulationTrips, improves determinism when resuming by rehydrating the congestion snapshot pointer, and introduces optional debug logging for the congestion pipeline. It also fixes a regex escape warning.Motivation
PopulationTripsruns can crash mid-iteration; restarting from scratch is expensive.Changes
Checkpointing + auto-resume
PopulationTripsnow saves a checkpoint after each completed iteration (current states, remaining sinks, RNG state).Checkpoint lifecycle integrated with remove
PopulationTrips.remove(remove_checkpoints=True)deletes output caches and the checkpoints for that specific run key (weekday + weekend).Clean resume helpers
mobility/choice_models/population_trips_resume.pyto keeppopulation_trips.pyreadable:compute_resume_plantry_load_checkpointrestore_state_or_fresh_startprune_tmp_artifactsrehydrate_congestion_snapshotDeterministic congestion resume (clean API)
PathTravelCosts.apply_flow_snapshot(flow_asset)and refactored snapshot application behind_apply_flow_snapshot(...).apply_flow_snapshot(...)instead of doing a dummyupdate(...)call with empty flows.Optional congestion debug logs
MOBILITY_DEBUG_CONGESTION=1, logs include:Minor fix
population_trips.pyby using a raw string:r"\S+/public_transport/\S+".