Clarification on save/load_checkpoint() and populate_from_csv!()

Dear all,

I’m working on a relatively large agent-based model (ABM) for fish populations, without explicit spatial structure, using Agents.jl. The model includes individual stochasticity in parameter values and uses multi-threading. To ensure reproducibility, all stochastic processes are driven using rand(abmrng(model)) .

I’ve structured my simulation in two phases:

  1. Spin-up phase: The model runs under climatological (reference) environmental conditions, allowing the population to reach a stable structure.
  2. Scenario phase: Starting from the stable state, I want to apply three different temporal environmental scenarios.

Atm, the environmental timeseries (e.g. temperature ) are passed at initialization as vectors included in model.properties, so they cover both the spin-up period and the subsequent scenario period.

I would like to run the spin-up period once, save the model state at the end using save_checkpoint(model), and then reload it using load_checkpoint(...) to apply the three different environmental scenarios from the same population structure.

However, from the documentation I understand that:

  • save_checkpoint() and load_checkpoint() do not save or reload function references to step the simulation.
  • It is not possible to change model.properties** after reloading from a checkpoint. This means I cannot swap the environmental forcing vectors from spin-up only values to perturbation scenarios.

My questions:

  1. Is it correct that model.properties cannot be modified after loading from a checkpoint?
  2. After loading a checkpoint, how does the model know how to step?
  3. Is it better to save only the agent data (adata) and use populate_from_csv!) after the spin-up to reinitialize a new model using the desired environmental vectors and the same agent population?
  4. Since all random calls use abmrng(model), I assume that running the spin-up again as part of the full timeseries vector (spin-up + scenario) would produce identical results to loading from the saved checkpoint. Is this assumption correct? or is multi-threading challenging this assumption?

Thank you in advace!
Elisa

1 Like