pytams.fmodel ============= .. py:module:: pytams.fmodel .. autoapi-nested-parse:: A base class for the stochastic forward model. Classes ------- .. autoapisummary:: pytams.fmodel.ForwardModelBaseClass Module Contents --------------- .. py:class:: ForwardModelBaseClass(params: dict[Any, Any], ioprefix: str | None = None, workdir: pathlib.Path | None = None) 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. :ivar _noise: the noise to be used in the next model step :ivar _step: the current stochastic step counter :ivar _time: the current stochastic time :ivar _workdir: the working directory .. py:method:: advance(dt: float, need_end_state: bool) -> float 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. :param dt: the time step size over which to advance :param 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 .. py:method:: get_noise() -> Any Return the model's latest noise increment. .. py:method:: set_noise(a_noise: Any) -> None Set the model's next noise increment. .. py:method:: clear() -> None Destroy internal data. .. py:method:: set_workdir(workdir: pathlib.Path) -> None Setter of the model working directory. :param workdir: the new working directory .. py:method:: get_current_state() -> Any :abstractmethod: Return the current state of the model. .. py:method:: set_current_state(state: Any) -> Any :abstractmethod: Set the current state of the model. .. py:method:: score() -> float :abstractmethod: Return the model's current state score. .. py:method:: make_noise() -> Any :abstractmethod: Return the model's latest noise increment. .. py:method:: post_trajectory_branching_hook(step: int, time: float) -> None Model post trajectory branching hook. :param step: the current step counter :param time: the time of the simulation .. py:method:: post_trajectory_restore_hook(step: int, time: float) -> None Model post trajectory restore hook. :param step: the current step counter :param time: the time of the simulation .. py:method:: check_convergence(step: int, time: float, current_score: float, target_score: float) -> bool 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. :param step: the current step counter :param time: the time of the simulation :param current_score: the current score :param target_score: the target score .. py:method:: name() -> str :classmethod: Return a the model name.