pytams.fmodel¶
A base class for the stochastic forward model.
Classes¶
A base class for the stochastic forward model. |
Module Contents¶
- class ForwardModelBaseClass(params: dict[Any, Any], ioprefix: str | None = None, workdir: pathlib.Path | None = None)[source]¶
A base class for the stochastic forward model.
pyTAMS relies on a separation of the stochastic model, encapsulating the physics of interest, and the TAMS algorithm itself. The ForwardModelBaseClass defines the API the TAMS algorithm requires from the stochastic model.
Concrete model classes must implement all the abstract functions defined in this base class.
The base class handles some components needed by TAMS, so that the user does not have to ensure compatibility with TAMS requirements.
- Variables:
_noise – the noise to be used in the next model step
_step – the current stochastic step counter
_time – the current stochastic time
_workdir – the working directory
- advance(dt: float, need_end_state: bool) float [source]¶
Base class advance function of the model.
This is the advance function called by TAMS internals. It handles updating the model time and step counter, as well as reusing or generating noise only when needed. It also handles exceptions.
- Parameters:
dt – the time step size over which to advance
need_end_state – whether the step end state is needed
- Returns:
Some model will not do exactly dt (e.g. sub-stepping) return the actual dt
- set_workdir(workdir: pathlib.Path) None [source]¶
Setter of the model working directory.
- Parameters:
workdir – the new working directory
- post_trajectory_branching_hook(step: int, time: float) None [source]¶
Model post trajectory branching hook.
- Parameters:
step – the current step counter
time – the time of the simulation
- post_trajectory_restore_hook(step: int, time: float) None [source]¶
Model post trajectory restore hook.
- Parameters:
step – the current step counter
time – the time of the simulation
- check_convergence(step: int, time: float, current_score: float, target_score: float) bool [source]¶
Check if the model has converged.
This default implementation checks if the current score is greater than or equal to the target score. The user can override this method to implement a different convergence criterion.
- Parameters:
step – the current step counter
time – the time of the simulation
current_score – the current score
target_score – the target score