gemseo / algos

Hide inherited members

algorithm_library module

Base class for algorithm libraries.

class gemseo.algos.algorithm_library.AlgorithmDescription(algorithm_name, internal_algorithm_name, library_name='', description='', website='')[source]

Bases: object

The description of an algorithm.

Parameters:
  • algorithm_name (str) –

  • internal_algorithm_name (str) –

  • library_name (str) –

    By default it is set to “”.

  • description (str) –

    By default it is set to “”.

  • website (str) –

    By default it is set to “”.

algorithm_name: str

The name of the algorithm in GEMSEO.

description: str = ''

A description of the algorithm.

internal_algorithm_name: str

The name of the algorithm in the wrapped library.

library_name: str = ''

The name of the wrapped library.

website: str = ''

The website of the wrapped library or algorithm.

class gemseo.algos.algorithm_library.AlgorithmLibrary[source]

Bases: object

Abstract class for algorithms libraries interfaces.

An algorithm library solves a numerical problem (optim, doe, linear problem) using a particular algorithm from a particular family of numerical methods.

Provide the available methods in the library for the proposed problem to be solved.

To integrate an optimization package, inherit from this class and put your module in gemseo.algos.doe or gemseo.algo.opt, or gemseo.algos.linear_solver packages.

driver_has_option(option_name)[source]

Check the existence of an option.

Parameters:

option_name (str) – The name of the option.

Returns:

Whether the option exists.

Return type:

bool

execute(problem, algo_name=None, **options)[source]

Execute the driver.

Parameters:
  • problem (BaseProblem) – The problem to be solved.

  • algo_name (str | None) – The name of the algorithm. If None, use algo_name attribute which may have been set by the factory.

  • **options (Any) – The algorithm options.

Return type:

None

filter_adapted_algorithms(problem)[source]

Filter the algorithms capable of solving the problem.

Parameters:

problem (Any) – The problem to be solved.

Returns:

The names of the algorithms adapted to this problem.

Return type:

list[str]

init_options_grammar(algo_name)[source]

Initialize the options’ grammar.

Parameters:

algo_name (str) – The name of the algorithm.

Return type:

JSONGrammar

classmethod is_algorithm_suited(algorithm_description, problem)[source]

Check if an algorithm is suited to a problem according to its description.

Parameters:
  • algorithm_description (AlgorithmDescription) – The description of the algorithm.

  • problem (Any) – The problem to be solved.

Returns:

Whether the algorithm is suited to the problem.

Return type:

bool

LIBRARY_NAME: ClassVar[str | None] = None

The name of the interfaced library.

OPTIONS_DIR: ClassVar[str | Path] = 'options'

The name of the directory containing the files of the grammars of the options.

OPTIONS_MAP: ClassVar[dict[str, str]] = {}

The names of the options in GEMSEO mapping to those in the wrapped library.

algo_name: str | None

The name of the algorithm used currently.

property algorithms: list[str]

The available algorithms.

descriptions: dict[str, AlgorithmDescription]

The description of the algorithms contained in the library.

internal_algo_name: str | None

The internal name of the algorithm used currently.

It typically corresponds to the name of the algorithm in the wrapped library if any.

opt_grammar: JSONGrammar | None

The grammar defining the options of the current algorithm.

problem: Any | None

The problem to be solved.

Examples using AlgorithmLibrary

Change the seed of a DOE

Change the seed of a DOE