gemseo / algos / linear_solvers

Hide inherited members

lib_scipy_linalg module

Wrappers for SciPy’s linear solvers.

class gemseo.algos.linear_solvers.lib_scipy_linalg.ScipyLinalgAlgos[source]

Bases: LinearSolverLibrary

Wrapper for scipy linalg sparse linear solvers.

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 (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)

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]

classmethod get_default_properties(algo_name)[source]

Return the properties of the algorithm.

It states if it requires symmetric, or positive definite matrices for instance.

Parameters:

algo_name (str) – The algorithm name.

Returns:

The properties of the solver.

Return type:

LinearSolverDescription

init_options_grammar(algo_name)

Initialize the options’ grammar.

Parameters:

algo_name (str) – The name of the algorithm.

Return type:

JSONGrammar

classmethod is_algorithm_suited(algorithm_description, problem)

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

solve(linear_problem, algo_name, **options)

Solve the linear system.

Parameters:
  • linear_problem (LinearProblem) – The problem to solve.

  • algo_name (str) – The name of the algorithm.

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

Returns:

The execution result.

Return type:

Any

BASE_INFO_MSG = 'scipy linear solver algorithm stop info: '
LGMRES_SPEC_OPTS = ('inner_m', 'outer_k', 'outer_v', 'store_outer_av', 'prepend_outer_v')
LIBRARY_NAME: ClassVar[str | None] = 'SciPy'

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]] = {'max_iter': 'maxiter', 'preconditioner': 'M', 'store_outer_av': 'store_outer_Av'}

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.

methods_map: dict[str, Callable[[ndarray, ndarray, ...], tuple[ndarray, int]]]

The mapping between the solver names and the solvers methods in scipy.sparse.

option_grammar: JSONGrammar | None

The grammar defining the options of the current algorithm.

problem: Any | None

The problem to be solved.

save_fpath: str

The path to the file to saved the problem when it is not converged and the option save_when_fail is active.

property solution: ndarray

The solution of the problem.