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: AlgorithmBase

Base 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" raises RuntimeError.

  • 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).

_initialize() None[source]#

Initialize the algorithm parameters and timer.

_output_results(results, opt_fx, opt_mesh)[source]#

Output the results to the colormap file.

_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), and index (mesh index of the minimum). x and index are None if no point was evaluated.

Return type:

dict

_prepare() None[source]#

Algorithm-specific preparation, called after dispatch.

Override in subclasses to perform setup that must happen after the checkpoint state is established (e.g. initialising timer entries).

_run() None[source]#

Execute the main algorithm process.