lace.Engine.update
- Engine.update(n_iters: int, *, timeout: int | None = None, checkpoint: int | None = None, transitions: str | List[StateTransition] | None = None, save_path: str | bytes | PathLike | None = None, quiet: bool = False)
Update the Engine by advancing the Markov chains.
- Parameters:
n_iters (int) – The number of iterations, or steps, to advance each chain (state)
timeout (int, optional) – The timeout in seconds, which is the maximum number of seconds any state should run. Note that if you have fewer cores than states (which is usually how it goes), then the update will run for longer than the timeout because not all the states will be able to run at the same time. If timeout is None (default), the run will stop when all requested iterations have been completed.
checkpoint (int, optional) – The number of iterations between saves. If save_path is not supplied checkpoints do nothing.
transitions (str | List[StateTransition], optional) –
List of state transitions to perform.
Possible Values: * If None (default) a defaultset is chosen. * If one of “sams”, “flat”, or “fast” to use common sets of transitions. * If a list of StateTransitions, then that sequence will be used.
save_path (pathlike, optional) – Where to save the metadata. If None (default) the engine is not saved. If checkpoint is provided, the Engine will be saved at checkpoints and at the end of the run. If checkpoint is not provided, the Engine will save only at the end of the run.
Examples
Simple update for 100 iterations
>>> from lace.examples import Animals >>> engine = Animals() >>> engine.update(100)
Perform only specific transitions and set a timeout of 30 seconds
>>> from lace import RowKernel, StateTransition >>> engine.update( ... 5, ... timeout=30, ... transitions=[ ... StateTransition.row_assignment(RowKernel.slice()), ... StateTransition.view_prior_process_params(), ... ], ... )
Use a common set of transitions by name, specifically “sams”:
>>> engine.update( ... 5, ... timeout=30, ... transitions="sams", ... )