Repository navigation
Conversation
recreate_sim_state() creates each saved cell with create_cell(), which takes the next agent ID, then overwrites it with the saved ID. The counter therefore only advances by the number of cells read, while saved IDs can be larger when cells died before the save, so cells created after resuming could reuse IDs held by resumed cells. Add raise_max_basic_agent_ID() to BioFVM and call it with the largest saved ID + 1 after reading the cells. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change preventing cell ID reuse after restoring a saved simulation.
No open issues 🎉
What changed in this PR
Prevents newly created cells from reusing restored cell IDs after resuming a saved simulation.
Changes:
- Adds a BioFVM helper that raises the agent ID counter without lowering it.
- Tracks the largest restored cell ID and advances the counter beyond it.
| File | Description |
|---|---|
| modules/PhysiCell_MultiCellDS.cpp | Advances the ID counter after restoring cells. |
| BioFVM/BioFVM_basic_agent.h | Declares and documents the counter helper. |
| BioFVM/BioFVM_basic_agent.cpp | Implements the counter’s minimum-value update. |
Review effort: Balanced
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.
After
resume_from_MultiCellDS(), new cells could get IDs that resumed cells already hold.recreate_sim_state()creates each saved cell withcreate_cell(), which takes the next agent ID, and then overwrites it with the saved ID, so the counter only advances by the number of cells read. Saved IDs run higher than that whenever cells died before the save, so daughters (or anycreate_cell()in custom code) reused them. This addsraise_max_basic_agent_ID()to BioFVM and calls it with the largest saved ID + 1 once the cells are read. In a heterogeneity-sample run resumed at t = 2880 min, the old code reached 115 duplicated IDs; with this change there are none.🤖 Generated with Claude Code