Anderson Acceleration of Fixed Point/Richardson Iteration for the nonlinear equation \( f(x) = b\).
More...
|
| AndersonAcceleration ()=default |
| Allocate nothing, Call construct method before usage. More...
|
|
| AndersonAcceleration (const ContainerType ©able) |
| Allocate memory for Fixed point iteration. More...
|
|
| AndersonAcceleration (const ContainerType ©able, unsigned mMax) |
| Allocate memory for the object. More...
|
|
template<class ... Params> |
void | construct (Params &&...ps) |
| Perfect forward parameters to one of the constructors. More...
|
|
const ContainerType & | copyable () const |
| Return an object of same size as the object used for construction. More...
|
|
void | set_throw_on_fail (bool throw_on_fail) |
| Set or unset a throw on failure-to-converge. More...
|
|
template<class MatrixType , class ContainerType0 , class ContainerType1 , class ContainerType2 > |
unsigned | solve (MatrixType &&f, ContainerType0 &x, const ContainerType1 &b, const ContainerType2 &weights, value_type rtol, value_type atol, unsigned max_iter, value_type damping, unsigned restart, bool verbose) |
| Solve the system \( f(x) = b \) in the given norm. More...
|
|
template<class ContainerType>
struct dg::AndersonAcceleration< ContainerType >
Anderson Acceleration of Fixed Point/Richardson Iteration for the nonlinear equation \( f(x) = b\).
This class implements the Anderson acceleration of the fixed point iteration algorithm described by https://users.wpi.edu/~walker/Papers/Walker-Ni,SINUM,V49,1715-1735.pdf with implementation details in //https://users.wpi.edu/~walker/Papers/anderson_accn_algs_imps.pdf As recommended by https://arxiv.org/pdf/1803.06673.pdf we periodically restart the acceleration to improve convergence behaviour.
const double eps = 1e-6;
std::cout << "Number of iterations "<< acc.solve( A, x, b, w2d, eps, eps, max_iter, damping, restart, true)<<std::endl;
A 2d negative elliptic differential operator .
Definition: elliptic.h:231
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
Evaluate a 1d function on grid coordinates.
Definition: evaluation.h:67
MPI_Vector< thrust::host_vector< real_type > > weights(const aRealMPITopology2d< real_type > &g)
Nodal weight coefficients.
Definition: mpi_weights.h:22
thrust::host_vector< double > HVec
Host Vector.
Definition: typedefs.h:19
Anderson Acceleration of Fixed Point/Richardson Iteration for the nonlinear equation .
Definition: andersonacc.h:61
- Template Parameters
-
ContainerType | Any class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag . Among others
dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them |
- See also
- See The dg dispatch system for a detailed explanation of our type dispatch system
template<class ContainerType >
template<class MatrixType , class ContainerType0 , class ContainerType1 , class ContainerType2 >
Solve the system \( f(x) = b \) in the given norm.
Iterates until \( ||f(x)-b|| < a_{\mathrm{tol}} + r_{\mathrm{tol}} ||b||\)
- Parameters
-
f | The function y=f(x) in the form f(x,y) . The first argument is the input and the second the output. |
x | Contains an initial guess on input and the solution on output. |
b | The right hand side vector. |
weights | The weights define the norm for the stopping condition of the solver and the scalar product in which the least square problem is computed |
rtol | Relative error condition with respect to b |
atol | Absolute error condition |
max_iter | Maxmimum number of iterations |
damping | Paramter to prevent too large jumps around the actual solution. Hard to determine in general but values between 1e-2 and 1e-4 are good values to begin with. This is the parameter that appears in Richardson iteration. It is beter to have it too small than too large (where it can lead to divergence of the solver) |
restart | Number >= mMax that indicates after how many iterations to restart the acceleration. Periodic restarts are important for this method. Per default it should be the same value as mMax but mMax+1 or higher could be valuable to consider (but usually are worse than mMax ). Lower values restart<mMax are equivalent to setting mMax=restart . |
verbose | If true writes intermediate errors to std::cout |
- Returns
- Number of iterations used to achieve desired precision
- Note
- The method will throw
dg::Fail
if the desired accuracy is not reached within max_iterations
You can unset this behaviour with the set_throw_on_fail
member
- Template Parameters
-
MatrixType | Any class for which a specialization of TensorTraits exists and defines a tensor_category derived from AnyMatrixTag . Furthermore, any functor/lambda type with signature void operator()( const ContainerType0&, ContainerType1&) . For example
In case of SelfMadeMatrixTag only those blas2 functions that have a corresponding member function in the Matrix class (e.g. symv( const ContainerType0&, ContainerType1&); ) can be called. If a Container has the RecursiveVectorTag , then the matrix is applied to each of the elements unless the type has the SelfMadeMatrixTag or is a Functor type. |
ContainerType | Any class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag . Among others
dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them |
- See also
- See The dg dispatch system for a detailed explanation of our type dispatch system