gemseo.algos.base_algorithm_library module#

Base class for algorithm libraries to handle a BaseProblem.

class AlgorithmDescription(algorithm_name, internal_algorithm_name, library_name='', description='', website='', Settings=<class 'gemseo.algos.base_algorithm_settings.BaseAlgorithmSettings'>)[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 "".

  • Settings (type[BaseAlgorithmSettings]) --

    By default it is set to <class 'gemseo.algos.base_algorithm_settings.BaseAlgorithmSettings'>.

Settings#

The Pydantic model for the settings.

alias of BaseAlgorithmSettings

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 BaseAlgorithmLibrary(algo_name)[source]#

Bases: object

Base class for algorithm libraries to handle a BaseProblem.

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.

Parameters:

algo_name (str) -- The algorithm name.

Raises:

KeyError -- When the algorithm is not in the library.

execute(problem, settings_model=None, **settings)[source]#

Solve a problem with an algorithm from this library.

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

  • settings_model (BaseAlgorithmSettings | None) -- The algorithm settings as a Pydantic model. If None, use **settings.

  • **settings (Any) -- The algorithm settings. These arguments are ignored when settings_model is not None.

Returns:

The solution found by the algorithm.

Return type:

Any

classmethod filter_adapted_algorithms(problem)[source]#

Filter the algorithms capable of solving the problem.

Parameters:

problem (BaseProblem) -- The problem to be solved.

Returns:

The names of the algorithms adapted to this problem.

Return type:

list[str]

classmethod is_algorithm_suited(algorithm_description, problem)[source]#

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

Parameters:
Returns:

Whether the algorithm is suited to the problem.

Return type:

bool

ALGORITHM_INFOS: ClassVar[dict[str, AlgorithmDescription]] = {}#

The description of the algorithms contained in the library.

property algo_name: str#

The name of the algorithm.