Skip to content

Keep cell IDs unique after resuming from saved output - #446

Open
drbergman wants to merge 1 commit into
MathCancer:developmentfrom
drbergman:fix-resume-agent-id-counter
Open

drbergman wants to merge 1 commit into
MathCancer:developmentfrom
drbergman:fix-resume-agent-id-counter

Conversation

@drbergman

Copy link
Copy Markdown
Collaborator

After resume_from_MultiCellDS(), new cells could get IDs that resumed cells already hold. recreate_sim_state() creates each saved cell with create_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 any create_cell() in custom code) reused them. This adds raise_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

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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

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.

2 participants