Checkpointing is a useful mechanism for mitigating the effects of crashes when software is run in an unstable environment, particularly for long run times. Checkpoints are saved regularly with a user-chosen frequency. Optimizations can then be resumed from a given checkpoint after a crash.
For saving checkpoints to disk,
FileCheckpoint is provided.
Checkpoint trait other checkpointing approaches can be implemented.
CheckpointingFrequency defines how often checkpoints are saved and can be chosen to be
Always (every iteration),
Every(u64) (every Nth iteration) or
The following example shows how the
checkpointing method is used to activate checkpointing.
If no checkpoint is available on disk, an optimization will be started from scratch. If the run
crashes and a checkpoint is found on disk, then it will resume from the checkpoint.
// [...] let checkpoint = FileCheckpoint::new( ".checkpoints", "optim", CheckpointingFrequency::Every(20) ); let res = Executor::new(my_optimization_problem, solver) .configure(|config| config.param(init_param).max_iters(iters)) .checkpointing(checkpoint) .run()?; // [...]
- Handles saving a checkpoint to disk as a binary file.
- Defines at which intervals a checkpoint is saved.
- An interface for checkpointing methods