sammo.search_op

sammo.search_op#

This module contains a variety of search operators that can be used to define a discrete search space for GridSearch or define a set of initial candidates for other search algorithms.

Module Contents#

Functions#

one_of

Search operator for selecting one of the given candidates.

many_of

Search operator for n choose k.

permutate

Search operator for permutating a list of components.

optional

Search operator for making a component optional.

get_points_from_search_space

Materialize a number of points from a search space.

get_first_point

Return the first value of the enumerated search space.

API#

sammo.search_op.one_of(candidates: beartype.typing.Iterable, reference_id: str | None = None) beartype.typing.Any#

Search operator for selecting one of the given candidates.

Parameters:
  • candidates – The list of candidates to choose from.

  • reference_id – Identifier for later reference.

sammo.search_op.many_of(num_choices: int, candidates: beartype.typing.Iterable, reference_id: str | None = None) beartype.typing.Any#

Search operator for n choose k.

Parameters:
  • num_choices – The number of candidates to choose.

  • candidates – The list of candidates to choose from.

  • reference_id – Identifier for later reference.

sammo.search_op.permutate(candidates: beartype.typing.Iterable, reference_id: str | None = None) beartype.typing.Any#

Search operator for permutating a list of components.

Parameters:
  • candidates – The list of components to permute.

  • reference_id – Identifier for later reference.

sammo.search_op.optional(candidate, reference_id=None) beartype.typing.Any#

Search operator for making a component optional.

Parameters:
  • val – The value to include or exclude.

  • reference_id – Identifier for later reference.

sammo.search_op.get_points_from_search_space(search_space: beartype.typing.Callable | sammo.base.Component | list | dict, n_points: int, sample: bool = False, seed: int = 42, return_names: bool = False) list[sammo.base.Component]#

Materialize a number of points from a search space.

Parameters:
  • search_space – Search space, either represented as function or a single Output class.

  • n_points – Number of points to materialize.

  • sample – Whether to sample from the search space or enumerate and return first n_points.

  • seed – Random seed for sampling.

  • return_names – Whether to return the names of the points.

sammo.search_op.get_first_point(search_space: beartype.typing.Callable | sammo.base.Component | list | dict) sammo.base.Component#

Return the first value of the enumerated search space.

Parameters:

search_space – Search space, either represented as function or a single Output class.