gemseo / algos

# algo_lib module¶

Base class for algorithm libraries.

Classes:

 Abstract class for algorithms libraries interfaces.
class gemseo.algos.algo_lib.AlgoLib[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.

Return type

None

lib_dict

The properties of the algorithm in terms of requirements on the properties of the problem to be solved.

Type

Dict[str, Dict[str, Union[str, bool]]]

algo_name

The name of the algorithm used currently.

Type

str

internal_algo_name

The name of the algorithm used currently as defined in the used library.

Type

str

problem

The problem to be solved.

Type

Any

Attributes:

 INTERNAL_NAME LIB OPTIONS_DIR OPTIONS_MAP PROBLEM_TYPE algorithms The available algorithms.

Methods:

 driver_has_option(option_key) Check if the option key exists. execute(problem[, algo_name]) Executes the driver. filter_adapted_algorithms(problem) Filter the algorithms capable of solving the problem. init_options_grammar(algo_name) Initialize the options grammar. is_algorithm_suited(algo_dict, problem) Check if the algorithm is suited to the problem according to algo_dict.
INTERNAL_NAME = 'internal_algo_name'
LIB = 'lib'
OPTIONS_DIR = 'options'
OPTIONS_MAP = {}
PROBLEM_TYPE = 'problem_type'
property algorithms

The available algorithms.

driver_has_option(option_key)[source]

Check if the option key exists.

Parameters

option_key (str) – The name of the option.

Returns

Whether the option is in the grammar.

Return type

bool

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

Executes the driver.

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

• algo_name (Optional[str]) –

The name of the algorithm> If None, use the algo_name attribute which may have been set by the factory.

By default it is set to None.

• options – The options dict for the algorithm.

• **options (Any) –

Return type

None

Filter the algorithms capable of solving the problem.

Parameters

problem (Any) – The opt_problem to be solved.

Returns

The list of adapted algorithms names.

Return type

bool

init_options_grammar(algo_name)[source]

Initialize the options grammar.

Parameters

algo_name (str) – The name of the algorithm.

Return type

gemseo.core.grammars.json_grammar.JSONGrammar

static is_algorithm_suited(algo_dict, problem)[source]

Check if the algorithm is suited to the problem according to algo_dict.

Parameters
• algo_dict (Mapping[str, bool]) – the algorithm characteristics

• problem (Any) – the opt_problem to be solved

Return type

bool