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()Optional[pathlib.Path][source]

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

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

checkpoint_init(step_attrib: str = 'current_step', every: int = 1, folder: Optional[Union[str, pathlib.Path]] = None, filename: Optional[str] = None, info: Optional[Dict[str, Any]] = None, exist_ok: bool = True, single: bool = True)[source]

Initializes the object to automatically save a checkpoint

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

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

  • folder – The directory to store checkpoints under

  • filename – 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 – Any extra information to save in the json file associated with each checkpoint

  • exist_ok – Override existing files if any

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

Remarks:

  • single_checkpoint implies exist_ok

checkpoint_on_step_started()Optional[pathlib.Path][source]

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

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