# Runtime interface¶

The compile-time configuration of the solvers used in AMGCL is not always convenient, especially if the solvers are used inside a software package or another library. That is why AMGCL provides runtime interface, which allows to postpone the configuration until, well, runtime. The classes inside amgcl::runtime namespace correspond to their compile-time alternatives, but the only template parameter they have is the backend to use.

Since there is no way of knowing the parameter structure at compile time, the runtime classes accept parameters only in form of boost::property_tree::ptree. The actual components of the method are set through the parameter tree as well. The runtime interface provides some enumerations for this purpose. For example, to select smoothed aggregation for coarsening, we could do this:

boost::property_tree::ptree prm;
prm.put("precond.coarsening.type", amgcl::runtime::coarsening::smoothed_aggregation);


The enumerations provide functions for converting to/from strings, so the following would work as well:

prm.put("precond.coarsening.type", "smoothed_aggregation");


Here is an example of using a runtime-configurable solver:

#include <amgcl/backend/builtin.hpp>
#include <amgcl/runtime.hpp>

...

boost::property_tree::ptree prm;
prm.put("precond.coarsening.type", amgcl::runtime::coarsening::smoothed_aggregation);
prm.put("precond.relaxation.type", amgcl::runtime::relaxation::spai0);
prm.put("solver.type",             amgcl::runtime::solver::gmres);

amgcl::make_solver<
amgcl::runtime::amg<Backend>,
amgcl::runtime::iterative_solver<Backend>
> solve(A, prm);


## Classes¶

### AMG preconditioner¶

Warning

doxygenclass: Cannot find class “amgcl::runtime::amg” in doxygen xml output for project “AMGCL” from directory: xml

enum amgcl::runtime::coarsening::type

Values:

amgcl::runtime::coarseningruge_stuben

Ruge-Stueben coarsening.

amgcl::runtime::coarseningaggregation

Aggregation.

amgcl::runtime::coarseningsmoothed_aggregation

Smoothed aggregation.

amgcl::runtime::coarseningsmoothed_aggr_emin

Smoothed aggregation with energy minimization.

enum amgcl::runtime::relaxation::type

Relaxation schemes.

Values:

amgcl::runtime::relaxationgauss_seidel

Gauss-Seidel smoothing.

amgcl::runtime::relaxationilu0

Incomplete LU with zero fill-in.

amgcl::runtime::relaxationiluk

Level-based incomplete LU.

amgcl::runtime::relaxationilut

Incomplete LU with thresholding.

amgcl::runtime::relaxationdamped_jacobi

Damped Jacobi.

amgcl::runtime::relaxationspai0

Sparse approximate inverse of 0th order.

amgcl::runtime::relaxationspai1

Sparse approximate inverse of 1st order.

amgcl::runtime::relaxationchebyshev

Chebyshev relaxation.

### Iterative solver¶

Warning

doxygenclass: Cannot find class “amgcl::runtime::iterative_solver” in doxygen xml output for project “AMGCL” from directory: xml

enum amgcl::runtime::solver::type

Values:

amgcl::runtime::solvercg

amgcl::runtime::solverbicgstab

amgcl::runtime::solverbicgstabl

BiCGStab(ell)

amgcl::runtime::solvergmres

GMRES.

amgcl::runtime::solverlgmres

LGMRES.

amgcl::runtime::solverfgmres

FGMRES.

amgcl::runtime::solveridrs

IDR(s)