gemseo / algos / linear_solvers

linear_solver_lib module

Base wrapper for all linear solvers.

class gemseo.algos.linear_solvers.linear_solver_lib.LinearSolverDescription(algorithm_name, internal_algorithm_name, library_name='', description='', website='', lhs_must_be_symmetric=False, lhs_must_be_positive_definite=False, lhs_must_be_linear_operator=False)[source]

Bases: gemseo.algos.algo_lib.AlgorithmDescription

The description of a linear solver.

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 .

  • lhs_must_be_symmetric (bool) –

    By default it is set to False.

  • lhs_must_be_positive_definite (bool) –

    By default it is set to False.

  • lhs_must_be_linear_operator (bool) –

    By default it is set to False.

Return type

None

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.

lhs_must_be_linear_operator: bool = False

Whether the left-hand side matrix must be a linear operator.

lhs_must_be_positive_definite: bool = False

Whether the left-hand side matrix must be positive definite.

lhs_must_be_symmetric: bool = False

Whether the left-hand side matrix must be symmetric.

library_name: str = ''

The name of the wrapped library.

website: str = ''

The website of the wrapped library or algorithm.

class gemseo.algos.linear_solvers.linear_solver_lib.LinearSolverLib[source]

Bases: gemseo.algos.algo_lib.AlgoLib

Abstract class for libraries of linear solvers.

Return type

None

driver_has_option(option_name)

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)

Execute the driver.

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

  • algo_name (Optional[str]) –

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

    By default it is set to None.

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

Return type

None

filter_adapted_algorithms(problem)

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)

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(algorithm_description, problem)[source]

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

Parameters
Returns

Whether the algorithm suits.

Return type

bool

solve(linear_problem, algo_name, **options)[source]

Solve the linear system.

Parameters
Returns

The execution result.

Return type

Any

LIBRARY_NAME: ClassVar[str | None] = None

The name of the interfaced library.

OPTIONS_DIR: Final[str] = 'options'

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

OPTIONS_MAP: dict[str, str] = {}

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

SAVE_WHEN_FAIL = 'save_when_fail'
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.

save_fpath: str | None

The file path to save the linear problem.

property solution: numpy.ndarray

The solution of the problem.