.. Copyright 2021 IRT Saint-Exupéry, https://www.irt-saintexupery.com This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. .. _gen_linear_solver_algos: Linear solvers ============== .. warning:: Some capabilities may require the :ref:`installation ` of |g| with :ref:`all its features ` and some others may depend on :ref:`plugins `. .. warning:: All the features of the wrapped libraries may not be exposed through |g|. .. note:: The algorithm settings can be passed to a function of the form .. code-block:: python function(..., settings_model: Base | None = None, **settings: Any) either one by one: .. code-block:: python function(..., setting_name_1=setting_name_1, setting_name_2=setting_name_2, ...) or using the argument name ``"settings"`` and the Pydantic model associated with the algorithm: .. code-block:: python settings = AlgorithmSettings(setting_name_1=setting_name_1, setting_name_2=setting_name_2, ...) function(..., settings_model=settings) .. raw:: html .. _BICG_options: BICG ---- Module: :class:`gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg` :code:`from gemseo.settings.linear_solvers import BICG_Settings` BI-Conjugate Gradient More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.bicg.html. .. raw:: html
Optional settings
  • **atol** : *, optional* The absolute tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 0.0. .. raw:: html
  • **callback** : *typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional* The user-supplied function to call after each iteration. It is called as callback(xk), where xk is the current solution vector. If ``None``, no function is called. By default it is set to None. .. raw:: html
  • **M** : *typing.Union[scipy.sparse.linalg._interface.LinearOperator, numpy.ndarray, scipy.sparse._base.sparray, NoneType], optional* The preconditioner approximating the inverse of A. By default it is set to None. .. raw:: html
  • **maxiter** : *, optional* Maximum number of iterations. By default it is set to 1000. .. raw:: html
  • **rtol** : *, optional* The relative tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 1e-12. .. raw:: html
  • **save_when_fail** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **store_residuals** : *, optional* Whether to store the residual norms at each iterations. By default it is set to False. .. raw:: html
  • **use_ilu_precond** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **x0** : *typing.Optional[numpy.ndarray], optional* Starting guess for the solution. If ``None``, start from a matrix of zeros. By default it is set to None. .. raw:: html
.. _BICGSTAB_options: BICGSTAB -------- Module: :class:`gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg` :code:`from gemseo.settings.linear_solvers import BICGSTAB_Settings` Bi-Conjugate Gradient STABilized More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.bicgstab.html. .. raw:: html
Optional settings
  • **atol** : *, optional* The absolute tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 0.0. .. raw:: html
  • **callback** : *typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional* The user-supplied function to call after each iteration. It is called as callback(xk), where xk is the current solution vector. If ``None``, no function is called. By default it is set to None. .. raw:: html
  • **M** : *typing.Union[scipy.sparse.linalg._interface.LinearOperator, numpy.ndarray, scipy.sparse._base.sparray, NoneType], optional* The preconditioner approximating the inverse of A. By default it is set to None. .. raw:: html
  • **maxiter** : *, optional* Maximum number of iterations. By default it is set to 1000. .. raw:: html
  • **rtol** : *, optional* The relative tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 1e-12. .. raw:: html
  • **save_when_fail** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **store_residuals** : *, optional* Whether to store the residual norms at each iterations. By default it is set to False. .. raw:: html
  • **use_ilu_precond** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **x0** : *typing.Optional[numpy.ndarray], optional* Starting guess for the solution. If ``None``, start from a matrix of zeros. By default it is set to None. .. raw:: html
.. _CG_options: CG -- Module: :class:`gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg` :code:`from gemseo.settings.linear_solvers import CG_Settings` Conjugate Gradient More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.cg.html. .. raw:: html
Optional settings
  • **atol** : *, optional* The absolute tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 0.0. .. raw:: html
  • **callback** : *typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional* The user-supplied function to call after each iteration. It is called as callback(xk), where xk is the current solution vector. If ``None``, no function is called. By default it is set to None. .. raw:: html
  • **M** : *typing.Union[scipy.sparse.linalg._interface.LinearOperator, numpy.ndarray, scipy.sparse._base.sparray, NoneType], optional* The preconditioner approximating the inverse of A. By default it is set to None. .. raw:: html
  • **maxiter** : *, optional* Maximum number of iterations. By default it is set to 1000. .. raw:: html
  • **rtol** : *, optional* The relative tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 1e-12. .. raw:: html
  • **save_when_fail** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **store_residuals** : *, optional* Whether to store the residual norms at each iterations. By default it is set to False. .. raw:: html
  • **use_ilu_precond** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **x0** : *typing.Optional[numpy.ndarray], optional* Starting guess for the solution. If ``None``, start from a matrix of zeros. By default it is set to None. .. raw:: html
.. _CGS_options: CGS --- Module: :class:`gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg` :code:`from gemseo.settings.linear_solvers import CGS_Settings` Conjugate Gradient Squared More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.cgs.html. .. raw:: html
Optional settings
  • **atol** : *, optional* The absolute tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 0.0. .. raw:: html
  • **callback** : *typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional* The user-supplied function to call after each iteration. It is called as callback(xk), where xk is the current solution vector. If ``None``, no function is called. By default it is set to None. .. raw:: html
  • **M** : *typing.Union[scipy.sparse.linalg._interface.LinearOperator, numpy.ndarray, scipy.sparse._base.sparray, NoneType], optional* The preconditioner approximating the inverse of A. By default it is set to None. .. raw:: html
  • **maxiter** : *, optional* Maximum number of iterations. By default it is set to 1000. .. raw:: html
  • **rtol** : *, optional* The relative tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 1e-12. .. raw:: html
  • **save_when_fail** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **store_residuals** : *, optional* Whether to store the residual norms at each iterations. By default it is set to False. .. raw:: html
  • **use_ilu_precond** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **x0** : *typing.Optional[numpy.ndarray], optional* Starting guess for the solution. If ``None``, start from a matrix of zeros. By default it is set to None. .. raw:: html
.. _DEFAULT_options: DEFAULT ------- Module: :class:`gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg` :code:`from gemseo.settings.linear_solvers import LGMRES_Settings` Default solver (LGMRES) More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.lgmres.html. .. raw:: html
Optional settings
  • **atol** : *, optional* The absolute tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 0.0. .. raw:: html
  • **callback** : *typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional* The user-supplied function to call after each iteration. It is called as callback(xk), where xk is the current solution vector. If ``None``, no function is called. By default it is set to None. .. raw:: html
  • **inner_m** : *, optional* Number of inner GMRES iterations per each outer iteration. By default it is set to 30. .. raw:: html
  • **M** : *typing.Union[scipy.sparse.linalg._interface.LinearOperator, numpy.ndarray, scipy.sparse._base.sparray, NoneType], optional* The preconditioner approximating the inverse of A. By default it is set to None. .. raw:: html
  • **maxiter** : *, optional* Maximum number of iterations. By default it is set to 1000. .. raw:: html
  • **outer_k** : *, optional* Number of vectors to carry between inner GMRES iterations. By default it is set to 3. .. raw:: html
  • **outer_v** : *list[tuple[numpy.ndarray[typing.Any, numpy.dtype[numpy.number[typing.Any]]], numpy.ndarray[typing.Any, numpy.dtype[numpy.number[typing.Any]]]]], optional* List of tuples `(v, Av)` used to augment the Krylov subspace. By default it is set to []. .. raw:: html
  • **prepend_outer_v** : *, optional* Whether to put `outer_v` augmentation vectors before Krylov iterates. By default it is set to False. .. raw:: html
  • **rtol** : *, optional* The relative tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 1e-12. .. raw:: html
  • **save_when_fail** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **store_outer_Av** : *, optional* Whether A @ v should be additionnaly stored in `outer_v` list. By default it is set to True. .. raw:: html
  • **store_residuals** : *, optional* Whether to store the residual norms at each iterations. By default it is set to False. .. raw:: html
  • **use_ilu_precond** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **x0** : *typing.Optional[numpy.ndarray], optional* Starting guess for the solution. If ``None``, start from a matrix of zeros. By default it is set to None. .. raw:: html
.. _GCROT_options: GCROT ----- Module: :class:`gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg` :code:`from gemseo.settings.linear_solvers import GCROT_Settings` Generalized Conjugate Residual with Optimal Truncation More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.gcrotmk.html. .. raw:: html
Optional settings
  • **atol** : *, optional* The absolute tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 0.0. .. raw:: html
  • **callback** : *typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional* The user-supplied function to call after each iteration. It is called as callback(xk), where xk is the current solution vector. If ``None``, no function is called. By default it is set to None. .. raw:: html
  • **CU** : *typing.Optional[collections.abc.Iterable[tuple[numpy.ndarray[typing.Any, numpy.dtype[numpy.number[typing.Any]]], numpy.ndarray[typing.Any, numpy.dtype[numpy.number[typing.Any]]]]]], optional* List of tuples `(c, u)` required to form the matrices C and U. If ``None`` start from empty matrices. By default it is set to None. .. raw:: html
  • **discard_C** : *, optional* Whether to discard the C-vectors at the end. By default it is set to True. .. raw:: html
  • **k** : *, optional* Number of vectors to carry between inner FGMRES iterations. If ``None`` use the same value as ``m``. By default it is set to 30. .. raw:: html
  • **M** : *typing.Union[scipy.sparse.linalg._interface.LinearOperator, numpy.ndarray, scipy.sparse._base.sparray, NoneType], optional* The preconditioner approximating the inverse of A. By default it is set to None. .. raw:: html
  • **m** : *, optional* Number of inner FGMRES iterations per each outer iteration. By default it is set to 30. .. raw:: html
  • **maxiter** : *, optional* Maximum number of iterations. By default it is set to 1000. .. raw:: html
  • **rtol** : *, optional* The relative tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 1e-12. .. raw:: html
  • **save_when_fail** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **store_residuals** : *, optional* Whether to store the residual norms at each iterations. By default it is set to False. .. raw:: html
  • **truncate** : *typing.Literal['oldest', 'smallest'], optional* The vectors from the previous cycle to drop. By default it is set to oldest. .. raw:: html
  • **use_ilu_precond** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **x0** : *typing.Optional[numpy.ndarray], optional* Starting guess for the solution. If ``None``, start from a matrix of zeros. By default it is set to None. .. raw:: html
.. _GMRES_options: GMRES ----- Module: :class:`gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg` :code:`from gemseo.settings.linear_solvers import GMRES_Settings` Generalized Minimum RESidual More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.gmres.html. .. raw:: html
Optional settings
  • **atol** : *, optional* The absolute tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 0.0. .. raw:: html
  • **callback** : *typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional* The user-supplied function to call after each iteration. It is called as callback(xk), where xk is the current solution vector. If ``None``, no function is called. By default it is set to None. .. raw:: html
  • **M** : *typing.Union[scipy.sparse.linalg._interface.LinearOperator, numpy.ndarray, scipy.sparse._base.sparray, NoneType], optional* The preconditioner approximating the inverse of A. By default it is set to None. .. raw:: html
  • **maxiter** : *, optional* Maximum number of iterations. By default it is set to 1000. .. raw:: html
  • **restart** : *, optional* Number of iterations between restarts. By default it is set to 20. .. raw:: html
  • **rtol** : *, optional* The relative tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 1e-12. .. raw:: html
  • **save_when_fail** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **store_residuals** : *, optional* Whether to store the residual norms at each iterations. By default it is set to False. .. raw:: html
  • **use_ilu_precond** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **x0** : *typing.Optional[numpy.ndarray], optional* Starting guess for the solution. If ``None``, start from a matrix of zeros. By default it is set to None. .. raw:: html
.. _LGMRES_options: LGMRES ------ Module: :class:`gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg` :code:`from gemseo.settings.linear_solvers import LGMRES_Settings` Loose Generalized Minimum RESidual More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.lgmres.html. .. raw:: html
Optional settings
  • **atol** : *, optional* The absolute tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 0.0. .. raw:: html
  • **callback** : *typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional* The user-supplied function to call after each iteration. It is called as callback(xk), where xk is the current solution vector. If ``None``, no function is called. By default it is set to None. .. raw:: html
  • **inner_m** : *, optional* Number of inner GMRES iterations per each outer iteration. By default it is set to 30. .. raw:: html
  • **M** : *typing.Union[scipy.sparse.linalg._interface.LinearOperator, numpy.ndarray, scipy.sparse._base.sparray, NoneType], optional* The preconditioner approximating the inverse of A. By default it is set to None. .. raw:: html
  • **maxiter** : *, optional* Maximum number of iterations. By default it is set to 1000. .. raw:: html
  • **outer_k** : *, optional* Number of vectors to carry between inner GMRES iterations. By default it is set to 3. .. raw:: html
  • **outer_v** : *list[tuple[numpy.ndarray[typing.Any, numpy.dtype[numpy.number[typing.Any]]], numpy.ndarray[typing.Any, numpy.dtype[numpy.number[typing.Any]]]]], optional* List of tuples `(v, Av)` used to augment the Krylov subspace. By default it is set to []. .. raw:: html
  • **prepend_outer_v** : *, optional* Whether to put `outer_v` augmentation vectors before Krylov iterates. By default it is set to False. .. raw:: html
  • **rtol** : *, optional* The relative tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 1e-12. .. raw:: html
  • **save_when_fail** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **store_outer_Av** : *, optional* Whether A @ v should be additionnaly stored in `outer_v` list. By default it is set to True. .. raw:: html
  • **store_residuals** : *, optional* Whether to store the residual norms at each iterations. By default it is set to False. .. raw:: html
  • **use_ilu_precond** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **x0** : *typing.Optional[numpy.ndarray], optional* Starting guess for the solution. If ``None``, start from a matrix of zeros. By default it is set to None. .. raw:: html
.. _TFQMR_options: TFQMR ----- Module: :class:`gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg` :code:`from gemseo.settings.linear_solvers import BaseSciPyLinalgSettingsBase` Transpose-Free Quasi-Minimal Residual More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.tfqmr.html. .. raw:: html
Optional settings
  • **atol** : *, optional* The absolute tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 0.0. .. raw:: html
  • **callback** : *typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional* The user-supplied function to call after each iteration. It is called as callback(xk), where xk is the current solution vector. If ``None``, no function is called. By default it is set to None. .. raw:: html
  • **M** : *typing.Union[scipy.sparse.linalg._interface.LinearOperator, numpy.ndarray, scipy.sparse._base.sparray, NoneType], optional* The preconditioner approximating the inverse of A. By default it is set to None. .. raw:: html
  • **maxiter** : *, optional* Maximum number of iterations. By default it is set to 1000. .. raw:: html
  • **rtol** : *, optional* The relative tolerance. Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol). By default it is set to 1e-12. .. raw:: html
  • **save_when_fail** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **store_residuals** : *, optional* Whether to store the residual norms at each iterations. By default it is set to False. .. raw:: html
  • **use_ilu_precond** : *, optional* Whether to use an incomplete LU factorization as preconditioner. By default it is set to False. .. raw:: html
  • **x0** : *typing.Optional[numpy.ndarray], optional* Starting guess for the solution. If ``None``, start from a matrix of zeros. By default it is set to None. .. raw:: html