odatse.algorithm.random_search module#
- class odatse.algorithm.random_search.Algorithm(info: Info, runner: Runner | None = None, run_mode: str = 'initial')[source]#
Bases:
AlgorithmAlgorithm class that evaluates the objective function at random points. Inherits from odatse.algorithm.mapper_mpi_base.Algorithm.
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”.
- __init__(info: Info, runner: Runner | None = None, run_mode: str = 'initial') 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”.
- _apply_state(data: dict, mode: str = 'resume', restore_rng: bool = True) None[source]#
Restore algorithm state; in continue mode also extend the run.
For
mode="continue"the point set is extended to the num_points of the new input: the previously evaluated points are kept (restored from the checkpoint) and only the additional points are evaluated. This is supported for the “random” mode and for the sobol/halton quasi-random sequences, whose point sets are nested (the first N points of a longer sequence are exactly the N points of the shorter one). It is rejected for latin, whose design is not nested.
- _check_continue(data: dict) None[source]#
Validate that the new input is a legal extension of the old run.
- _extend_points(data: dict) None[source]#
Extend the iterator with the additional points (continue mode).
- _quasi_random_iterator(info_param, seq, seed=None)[source]#
Setup a quasi-random (low-discrepancy) point sequence.
- Parameters:
info_param – Dictionary containing parameters for setting up the points.
seq (str) – Sequence type: “sobol”, “halton”, or “latin”.
seed (int, optional) – Seed for the scrambling of the sequence. The sequence is generated on the algorithm-rank-0 process only, so a single integer makes the whole point set reproducible independently of the MPI configuration. If None, the scrambling differs from run to run.