CheckpointMixin

class negmas.checkpoints.CheckpointMixin[source]

Bases: object

Adds the ability to save checkpoints to a NamedObject

Methods Summary

checkpoint_final_step()

Should be called at the end of the simulation to save the final state

checkpoint_init([step_attrib, every, ...])

Initializes the object to automatically save a checkpoint

checkpoint_on_step_started()

Should be called on every step to save checkpoints as needed.

Methods Documentation

checkpoint_final_step()[source]

Should be called at the end of the simulation to save the final state

Return type:

Path | None

Remarks:
  • Should be called after all processing of the final step is conducted.

checkpoint_init(step_attrib='current_step', every=1, folder=None, filename=None, info=None, exist_ok=True, single=True)[source]

Initializes the object to automatically save a checkpoint

Parameters:
  • step_attrib (str) – The attribute that defines the current step. If None, there is no step concept

  • every (int) – Number of steps per checkpoint. If < 1 no checkpoints will be saved

  • folder (PathLike | Path | str | None) – The directory to store checkpoints under

  • filename (str | None) – Name of the file to save the checkpoint under. If None, a unique name will be chosen. If single_checkpoint was False, then multiple files will be used prefixed with the step number

  • info (dict[str, Any] | None) – Any extra information to save in the json file associated with each checkpoint

  • exist_ok (bool) – Override existing files if any

  • single (bool) – If True, only the most recent checkpoint will be kept

Remarks:

  • single_checkpoint implies exist_ok

checkpoint_on_step_started()[source]

Should be called on every step to save checkpoints as needed.

Return type:

Path | None

Returns:

The path on which the checkpoint is stored if one is stored. None otherwise.

Remarks:

  • Should be called at the BEGINNING of every step before any processing takes place