odatse.algorithm.mapper_mpi_base module#
- class odatse.algorithm.mapper_mpi_base.Algorithm(info: Info, runner: Runner | None = None, run_mode: str = 'initial', iterator=None)[source]#
Bases:
AlgorithmBaseBase class of mapper-type algorithms that evaluate the objective function over a sequence of points supplied by an iterator. Inherits from odatse.algorithm.AlgorithmBase.
The set of points to evaluate is provided by an iterator object (a subclass of odatse.algorithm._iterator.IteratorBase). Subclasses such as mapper_mpi and random_search construct a suitable iterator from the input parameters and assign it to self._iter. Alternatively, a custom point sequence can be supplied programmatically through the iterator parameter of this class.
Initialize the Algorithm instance.
- Parameters:
info (Info) – Information object containing algorithm parameters.
runner (Runner) – Optional runner object for submitting tasks.
run_mode (str) – Mode to run the algorithm, defaults to “initial”.
iterator (IteratorBase) – Iterator that yields (index, coordinates) pairs of the points to evaluate. Subclasses usually build one from the input parameters and set self._iter themselves; pass an iterator here to evaluate a custom point sequence directly.
- __init__(info: Info, runner: Runner | None = None, run_mode: str = 'initial', iterator=None) None[source]#
Initialize the Algorithm instance.
- Parameters:
info (Info) – Information object containing algorithm parameters.
runner (Runner) – Optional runner object for submitting tasks.
run_mode (str) – Mode to run the algorithm, defaults to “initial”.
iterator (IteratorBase) – Iterator that yields (index, coordinates) pairs of the points to evaluate. Subclasses usually build one from the input parameters and set self._iter themselves; pass an iterator here to evaluate a custom point sequence directly.
- _apply_state(data: dict, mode: str = 'resume', restore_rng: bool = True) None[source]#
Restore algorithm state from a checkpoint snapshot.
Delegates MPI validation, timer restore, and parameter check to the base class, applies the mapper-specific fields, then restores the iterator position.
- Parameters:
data (dict) – Snapshot previously produced by
__getstate__.mode (str) –
"resume", or"continue"when the subclass declares_continuable = True(the subclass is then responsible for extending the iterator after this method returns); otherwise"continue"raisesRuntimeError.restore_rng (bool) – Forwarded to the base class and to the iterator’s state restore (e.g. RandomIterator restores its RNG state when this is True).
- _post() dict[source]#
Post-process the results and gather data from all MPI ranks.
- Returns:
Dictionary with the optimal point:
x(coordinates of the minimum),fx(function value at the minimum), andindex(mesh index of the minimum).xandindexareNoneif no point was evaluated.- Return type:
dict