Skip to main content
Version: 🚧 Alpha 🚧

Save and Restore simulations

GAMA provides built-in support for saving and restoring simulation state. This enables two main features:

  • The possibility to save the state of a simulation
  • The possibility to restore a simulation from this file.
  • The possibility to go backward to an older state of a simulation.

Saving a simulation state during a simulation​

You can save the simulation state at any point in your model using the save statement:

experiment saveSimu type: gui {

reflex store when: cycle = 5 {
write "================ START SAVE + self " + " - " + cycle ;
save simulation to: 'saveSimu.gsim' format: 'xml';
write "================ END SAVE + self " + " - " + cycle ;
}
}

Note: The saved simulation file (.gsim) can be restored later using the restore statement or the GAMA UI's "Restore Simulation" feature.

Restoring a simulation​

There are several ways to restore a saved simulation:

1. From within a model using the restore statement​

experiment reloadSavedSimuOnly type: gui {

action _init_() {
// Load the simulation state from a file
simulation s <- restore simulation from: file('saveSimu.gsim');
}

output {
display main_display {
}
}
}

2. Using the GAMA UI​

GAMA provides a built-in "Restore Simulation" command in the Experiment menu, allowing you to load a previously saved .gsim file and continue from the saved state.

3. Saving model snapshots​

In batch experiments, you can use the save statement with the output facet to automatically save simulation state at each step:

output {
simulation type: 'gsim' to: 'results/saved_step';
}