feijoa.search.oracles package#

Subpackages#

Submodules#

feijoa.search.oracles.bayesian module#

Bayesian optimization module.

class feijoa.search.oracles.bayesian.Bayesian(search_space, *args, acq='ei', seed=0, regr='GaussianProcessRegressor', n_warmup=5, plugins=None, **kwargs)#

Bases: feijoa.search.oracles.oracle.Oracle

Bayesian optimization oracle.

Bayesian optimization is a global optimization method for an unknown function (black box) with noise. Bayesian optimization applied to hyperparameters optimization builds a stochastic model of the mapping function from hyperparameter value to an objective function applied on the test set. By iteratively applying a perspective hyperparameter configuration based on the current model and then updating it, Bayesian optimization seeks to gather as much information as possible about that function and, in particular, the location of the optimum. The method attempts to balance probing (hyperparameters for which the change is least reliably known) and exploitation (hyperparameters that are expected to be closest to the optimum). In practice, Bayesian optimization has shown better results with less computation compared to grid search and random search due to the ability to judge the quality of experiments even before they are performed.

Parameters
  • search_space (SearchSpace) – Search space instance.

  • acq (str) – Acquisition function. Can be pi, ucb, ei with Gaussian Regressor Or naive0 - experimental, lfboei, lfbopi

  • regr

    Regression model, must have
    • fit(X, y)

    • predict_proba(X)

    • predict(X)

    methods. For example, you can use regressor from sklearn package (https://scikit-learn.org/)

  • n_warmup (int) – Warmup points count.

Note

lfbopi and lfboei taked from publication:

https://arxiv.org/abs/2206.13035

Note

naive0 - experimental function.

aliases = ('BayesianOracle', 'bayesian', 'bayes')#
anchor = 'bayesian'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

opt_acquisition(n)#

Optimize acquisition function.

Parameters

n (int) –

tell(config, result)#

Tell configuration’s result.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

feijoa.search.oracles.bayesian.acquisition(model, kind, X_samples, X, y, random_state=None, **kwargs)#

Acquisition function for bayesian optimization.

Parameters
  • model – Regressor model, must be fitted. Typically, Gaussian

  • kind – Kind of acquisition function. Choices: ei, poi, ucb (only for GPR), lfboei, lfbopi, naive0 - model free.

  • X_samples (numpy.ndarray) – X samples to predict.

  • X (numpy.ndarray) – Features matrix.

  • y (numpy.ndarray) – Target values for X.

  • random_state (int | None) – Random state seed.

Returns

Value of acquisition function.

feijoa.search.oracles.finder module#

feijoa.search.oracles.finder.fetch_classes(base_class, *folders, only_anchors=False)#

Fetch oracle from specified oracles folders.

By default, uses:
  • default oracles folder

Returns

all founded oracle’s classes.

feijoa.search.oracles.finder.fetch_oracles(include_integration=False)#
feijoa.search.oracles.finder.fetch_plugins(include_integration=False)#
feijoa.search.oracles.finder.fetch_top_oracles(include_integration=False)#
feijoa.search.oracles.finder.get_algo(name)#

Get oracle class by name

feijoa.search.oracles.finder.get_plugin(name)#
feijoa.search.oracles.finder.get_top_oracle(name)#
feijoa.search.oracles.finder.maker(line, search_space, random_state=None)#
Parameters

search_space (feijoa.search.space.SearchSpace) –

feijoa.search.oracles.genetic module#

Genetic oracles with pymoo backend module.

class feijoa.search.oracles.genetic.BRKGA(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.genetic.Genetic

property algorithm_cls#
aliases: Tuple = ('brkga',)#
anchor: str = 'brkga'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

Tell configuration’s result to oracle to accumulate information model.

Parameters
  • config (Configuration) – Configuration instance.

  • result (float) – Objective result for configuration.

Note

The function signature may change in the future due to plans to implement multi&many-objective optimization.

Returns

None

Raises

AnyError – If anything bad happens.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

class feijoa.search.oracles.genetic.CMAES(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.genetic.Genetic

property algorithm_cls#
aliases: Tuple = ('cmaes',)#
anchor: str = 'cmaes'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

Tell configuration’s result to oracle to accumulate information model.

Parameters
  • config (Configuration) – Configuration instance.

  • result (float) – Objective result for configuration.

Note

The function signature may change in the future due to plans to implement multi&many-objective optimization.

Returns

None

Raises

AnyError – If anything bad happens.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

class feijoa.search.oracles.genetic.DIRECT(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.genetic.Genetic

property algorithm_cls#
aliases: Tuple = ('direct',)#
anchor: str = 'direct'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

Tell configuration’s result to oracle to accumulate information model.

Parameters
  • config (Configuration) – Configuration instance.

  • result (float) – Objective result for configuration.

Note

The function signature may change in the future due to plans to implement multi&many-objective optimization.

Returns

None

Raises

AnyError – If anything bad happens.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

class feijoa.search.oracles.genetic.DifferentialEvolution(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.genetic.Genetic

property algorithm_cls#
aliases: Tuple = ('differentialevolution', 'DE')#
anchor: str = 'de'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

Tell configuration’s result to oracle to accumulate information model.

Parameters
  • config (Configuration) – Configuration instance.

  • result (float) – Objective result for configuration.

Note

The function signature may change in the future due to plans to implement multi&many-objective optimization.

Returns

None

Raises

AnyError – If anything bad happens.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

class feijoa.search.oracles.genetic.EPPSO(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.genetic.Genetic

property algorithm_cls#
aliases: Tuple = ('eppso',)#
anchor: str = 'eppso'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

Tell configuration’s result to oracle to accumulate information model.

Parameters
  • config (Configuration) – Configuration instance.

  • result (float) – Objective result for configuration.

Note

The function signature may change in the future due to plans to implement multi&many-objective optimization.

Returns

None

Raises

AnyError – If anything bad happens.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

class feijoa.search.oracles.genetic.ES(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.genetic.Genetic

property algorithm_cls#
aliases: Tuple = ('es',)#
anchor: str = 'es'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

Tell configuration’s result to oracle to accumulate information model.

Parameters
  • config (Configuration) – Configuration instance.

  • result (float) – Objective result for configuration.

Note

The function signature may change in the future due to plans to implement multi&many-objective optimization.

Returns

None

Raises

AnyError – If anything bad happens.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

class feijoa.search.oracles.genetic.G3PCX(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.genetic.Genetic

property algorithm_cls#
aliases: Tuple = ('g3pcx',)#
anchor: str = 'g3pcx'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

Tell configuration’s result to oracle to accumulate information model.

Parameters
  • config (Configuration) – Configuration instance.

  • result (float) – Objective result for configuration.

Note

The function signature may change in the future due to plans to implement multi&many-objective optimization.

Returns

None

Raises

AnyError – If anything bad happens.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

class feijoa.search.oracles.genetic.Genetic(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.oracle.Oracle

Genetic oracles with pymoo backend. Pymoo link: https://pymoo.org/.

Parameters

algorithm_cls – Pymoo oracle class.

Raises

AnyError – If anything bad happens.

Note

This set of oracles is experimental.

algorithm_cls#

alias of pymoo.algorithms.soo.nonconvex.ga.GA

aliases: Tuple = ('Genetic', 'genetic', 'GA', 'ga')#
anchor: str = 'GA'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

Tell configuration’s result to oracle to accumulate information model.

Parameters
  • config (Configuration) – Configuration instance.

  • result (float) – Objective result for configuration.

Note

The function signature may change in the future due to plans to implement multi&many-objective optimization.

Returns

None

Raises

AnyError – If anything bad happens.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

class feijoa.search.oracles.genetic.ISRES(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.genetic.Genetic

property algorithm_cls#
aliases: Tuple = ('isres',)#
anchor: str = 'isres'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

Tell configuration’s result to oracle to accumulate information model.

Parameters
  • config (Configuration) – Configuration instance.

  • result (float) – Objective result for configuration.

Note

The function signature may change in the future due to plans to implement multi&many-objective optimization.

Returns

None

Raises

AnyError – If anything bad happens.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

class feijoa.search.oracles.genetic.NICHEGA(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.genetic.Genetic

property algorithm_cls#
aliases: Tuple = ('niche', 'nichega')#
anchor: str = 'nichega'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

Tell configuration’s result to oracle to accumulate information model.

Parameters
  • config (Configuration) – Configuration instance.

  • result (float) – Objective result for configuration.

Note

The function signature may change in the future due to plans to implement multi&many-objective optimization.

Returns

None

Raises

AnyError – If anything bad happens.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

class feijoa.search.oracles.genetic.PSO(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.genetic.Genetic

property algorithm_cls#
aliases: Tuple = ('pso',)#
anchor: str = 'pso'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

Tell configuration’s result to oracle to accumulate information model.

Parameters
  • config (Configuration) – Configuration instance.

  • result (float) – Objective result for configuration.

Note

The function signature may change in the future due to plans to implement multi&many-objective optimization.

Returns

None

Raises

AnyError – If anything bad happens.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

class feijoa.search.oracles.genetic.SRES(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.genetic.Genetic

property algorithm_cls#
aliases: Tuple = ('sres',)#
anchor: str = 'sres'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

Tell configuration’s result to oracle to accumulate information model.

Parameters
  • config (Configuration) – Configuration instance.

  • result (float) – Objective result for configuration.

Note

The function signature may change in the future due to plans to implement multi&many-objective optimization.

Returns

None

Raises

AnyError – If anything bad happens.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

feijoa.search.oracles.grid module#

Grid search class module.

class feijoa.search.oracles.grid.Grid(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.oracle.Oracle

Simple grid search.

Makes a full iteration over a manually specified subset of hyperparameter spaces of the oracle.

Raises

AnyError – If anything bad happens.

aliases = ('GridSearch', 'grid')#
anchor = 'grid'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

No needed.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

feijoa.search.oracles.oracle module#

Base class of search oracles.

class feijoa.search.oracles.oracle.Oracle(*args, seed=0, **kwargs)#

Bases: feijoa.utils.mixins.Subject, feijoa.utils.mixins.Observer

Base class of search oracles.

Have a simple ask-tell interface.

When creating the possibility of implementing oracles, it is desirable that the constructor arguments should not contain any dependencies on feijoa, except for SearchSpace. This decision is made to keep the oracles easy to use without initializing feijoa components.

All oracles must implement:

anchor:

Name of oracle, which used for dynamic searching all oracles in project.

aliases:

synonyms for oracle name.

ask(n):

Get k <= n configurations.

tell(configuration, result):

Tell oracle measured result for configuration

Raises

AnyError – If anything bad happens.

abstract property aliases#

Synonyms for oracle name.

abstract property anchor#

Name used for dynamic oracle detection.

abstract ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

abstract tell(config, result)#

Tell configuration’s result to oracle to accumulate information model.

Parameters
  • config (Configuration) – Configuration instance.

  • result (float) – Objective result for configuration.

Note

The function signature may change in the future due to plans to implement multi&many-objective optimization.

Returns

None

Raises

AnyError – If anything bad happens.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

feijoa.search.oracles.pattern module#

class feijoa.search.oracles.pattern.Pattern(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.oracle.Oracle

Pattern search implementation.

The result can be used for functions that are not its continuous or differentiable. One such search method is “convergence” (see below), based on the theory of positive reasons. The optimization turns into the best match (the solution with the smallest error value) in the multidimensional analytical possibility space.

See more: https://en.wikipedia.org/wiki/Pattern_search_(optimization)

Implementation based on: https://github.com/jansel/opentuner/blob/master/opentuner/search/patternsearch.py

Raises

AnyError – If anything bad happens.

Parameters

search_space (feijoa.search.space.SearchSpace) –

aliases = ('PatternSearch', 'pattern', 'patternsearch', 'TemplateSearch', 'templatesearch')#
anchor = 'template'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

Tell configuration’s result to oracle to accumulate information model.

Parameters
  • config (Configuration) – Configuration instance.

  • result (float) – Objective result for configuration.

Note

The function signature may change in the future due to plans to implement multi&many-objective optimization.

Returns

None

Raises

AnyError – If anything bad happens.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

feijoa.search.oracles.randomized module#

class feijoa.search.oracles.randomized.Random(search_space, *args, **kwargs)#

Bases: feijoa.search.oracles.oracle.Oracle

Simple random search.

Random search replaces the exhaustive search of all combinations with a selection of them randomly. This can easily be applied to the discrete settings above, but the method can also be generalized to continuous and mixed spaces. Random search can outperform lattice search, especially if only a small number of hyperparameters affects the performance of the oracle.

Raises

AnyError – If anything bad happens.

aliases = ('RandomSearch', 'random', 'randomized')#
anchor = 'random'#
ask(n=1)#

Get configurations from oracle.

Parameters

n (int, optional) – Preferred count of configurations.

Return type

Optional[List[feijoa.models.configuration.Configuration]]

Note

Parameter n may not affect on configuration’s count.

Returns

List of configurations, or None if configurations are over.

Raises

AnyError – If anything bad happens.

Parameters

n (int) –

Return type

Optional[List[feijoa.models.configuration.Configuration]]

attach(observer)#

Attach an observer to the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

detach(observer)#

Detach an observer from the subject.

Parameters

observer (feijoa.utils.mixins.Observer) –

Return type

None

property name#

Name of oracle.

notify(event, *args, **kwargs)#

Notify all observers about an event.

tell(config, result)#

No needed.

update(event, subject, *args, **kwargs)#

Receive update from subject.

Args:
event:

Type of event.

subject:

Subject of notification.

Returns:

None

Raises:

AnyError: If anything bad happens.

Module contents#