Primary algorithm

TODO

Sanitizing wrapper of main algorithm

Performs checks and organizes required transformations of points.

class orion.core.worker.primary_algo.SpaceTransformAlgoWrapper(space: orion.algo.space.Space, algorithm: orion.core.worker.primary_algo.AlgoType)[source]

Perform checks on points and transformations. Wrap the primary algorithm.

1. Checks requirements on the parameter space from algorithms and create the appropriate transformations. Apply transformations before and after methods of the primary algorithm. 2. Checks whether incoming and outcoming points are compliant with a space.

Parameters
algorithm: instance of `BaseAlgorithm`

Algorithm to be wrapped.

spaceorion.algo.space.Space

The original definition of a problem’s parameters space.

algorithm_configdict

Configuration for the algorithm.

Attributes
configuration

Return tunable elements of this algorithm in a dictionary form appropriate for saving.

fidelity_index

Compute the index of the space where fidelity is.

is_done

Return True if the wrapper or the wrapped algorithm is done.

n_observed

Number of completed trials observed by the algorithm.

n_suggested

Number of trials suggested by the algorithm

original_space

The original space (before transformations).

space

Domain of problem associated with this algorithm’s instance.

state_dict

Return a state dict that can be used to reset the state of the algorithm.

transformed_space

The transformed space (after transformations).

Methods

has_observed(trial)

Whether the algorithm has observed a given trial.

has_suggested(trial)

Whether the algorithm has suggested a given trial.

judge(trial, measurements)

Inform an algorithm about online measurements of a running trial.

observe(trials)

Observe evaluated trials.

score(trial)

Allow algorithm to evaluate point based on a prediction about this parameter set's performance.

seed_rng(seed)

Seed the state of the algorithm's random number generator.

set_state(state_dict)

Reset the state of the algorithm based on the given state_dict

should_suspend(trial)

Allow algorithm to decide whether a particular running trial is still worth to complete its evaluation, based on information provided by the judge method.

suggest(num)

Suggest a num of new sets of parameters.

property configuration: dict

Return tunable elements of this algorithm in a dictionary form appropriate for saving.

property fidelity_index: str | None

Compute the index of the space where fidelity is.

Returns None if there is no fidelity dimension.

has_observed(trial: orion.core.worker.trial.Trial) bool[source]

Whether the algorithm has observed a given trial.

has_suggested(trial: orion.core.worker.trial.Trial) bool[source]

Whether the algorithm has suggested a given trial.

property is_done: bool

Return True if the wrapper or the wrapped algorithm is done.

judge(trial: Trial, measurements: Any) dict | None[source]

Inform an algorithm about online measurements of a running trial.

The algorithm can return a dictionary of data which will be provided as a response to the running environment. Default is None response.

property n_observed: int

Number of completed trials observed by the algorithm.

property n_suggested: int

Number of trials suggested by the algorithm

observe(trials: list[Trial]) None[source]

Observe evaluated trials.

property original_space: orion.algo.space.Space

The original space (before transformations). This is exposed to the outside, but not to the wrapped algorithm.

score(trial: orion.core.worker.trial.Trial) float[source]

Allow algorithm to evaluate point based on a prediction about this parameter set’s performance. Return a subjective measure of expected performance.

By default, return the same score any parameter (no preference).

seed_rng(seed: int | Sequence[int] | None) None[source]

Seed the state of the algorithm’s random number generator.

set_state(state_dict: dict) None[source]

Reset the state of the algorithm based on the given state_dict

Parameters

state_dict – Dictionary representing state of an algorithm

should_suspend(trial: orion.core.worker.trial.Trial) bool[source]

Allow algorithm to decide whether a particular running trial is still worth to complete its evaluation, based on information provided by the judge method.

property space: orion.algo.space.Space

Domain of problem associated with this algorithm’s instance.

Note

Redefining property here without setter, denies base class’ setter.

property state_dict: dict

Return a state dict that can be used to reset the state of the algorithm.

suggest(num: int) list[Trial][source]

Suggest a num of new sets of parameters.

Parameters
num: int

Number of trials to suggest. The algorithm may return less than the number of trials requested.

Returns
list of trials

A list of trials representing values suggested by the algorithm. The algorithm may opt out if it cannot make a good suggestion at the moment (it may be waiting for other trials to complete), in which case it will return an empty list.

Notes

New parameters must be compliant with the problem’s domain orion.algo.space.Space.

property transformed_space: orion.core.worker.transformer.TransformedSpace

The transformed space (after transformations). This is only exposed to the wrapped algo, not to classes outside of this.

orion.core.worker.primary_algo.create_algo(algo_type: type[AlgoType], space: Space, **algo_kwargs) SpaceTransformAlgoWrapper[AlgoType][source]

Creates an algorithm of the given type, taking care of transforming the space if needed.