NOX Development
Loading...
Searching...
No Matches
NOX::Solver::AndersonAcceleration Class Reference

Nonlinear solver based on Anderson Acceleration. More...

#include <NOX_Solver_AndersonAcceleration.H>

Inheritance diagram for NOX::Solver::AndersonAcceleration:
Collaboration diagram for NOX::Solver::AndersonAcceleration:

Public Member Functions

 AndersonAcceleration (const Teuchos::RCP< NOX::Abstract::Group > &grp, const Teuchos::RCP< NOX::StatusTest::Generic > &tests, const Teuchos::RCP< Teuchos::ParameterList > &params)
 Constructor.
virtual ~AndersonAcceleration ()
 Destructor.
virtual void reset ()
 Resets the solver for another solve. This resets the counters and status only. Uses the final solution from the last solve as the initial guess for the next solve.
virtual void reset (const NOX::Abstract::Vector &initialGuess)
 Resets the solver and sets a new initial guess.
virtual void reset (const NOX::Abstract::Vector &initialGuess, const Teuchos::RCP< NOX::StatusTest::Generic > &tests)
 Resets the solver, sets a new status test, and sets a new initial guess.
virtual NOX::StatusTest::StatusType step ()
 Do one nonlinear step in the iteration sequence and return status.
virtual NOX::StatusTest::StatusType solve ()
 Solve the nonlinear problem and return final status.
virtual const NOX::Abstract::GroupgetSolutionGroup () const
 Return a reference to the current solution group.
virtual const NOX::Abstract::GroupgetPreviousSolutionGroup () const
 Return a reference to the previous solution group.
virtual NOX::StatusTest::StatusType getStatus () const
 Returns the current status of the solver.
virtual int getNumIterations () const
 Get number of iterations.
virtual const Teuchos::ParameterList & getList () const
 Return a reference to the solver parameters.
virtual double getStepSize () const
virtual Teuchos::RCP< const NOX::Abstract::GroupgetSolutionGroupPtr () const
 Return a RCP to the solution group.
virtual Teuchos::RCP< const NOX::Abstract::GroupgetPreviousSolutionGroupPtr () const
 Return a RCP to the previous solution group.
virtual Teuchos::RCP< const Teuchos::ParameterList > getListPtr () const
 Return a RCP to the solver parameters.
virtual Teuchos::RCP< const NOX::SolverStatsgetSolverStatistics () const
 Return a RCP to the solver statistics.
Public Member Functions inherited from NOX::Solver::Generic
 Generic ()
 Constructor (does nothing).
virtual ~Generic ()
 Destructor (does nothing).

Protected Member Functions

virtual void init ()
 Print out initialization information and calcuate the RHS.
virtual void printUpdate ()
 Prints the current iteration information.
void qrAdd (NOX::Abstract::Vector &newCol)
 Updates QR factors by addition of a column.
void qrDelete ()
 Updates QR factors by deletion of a column.
void reorthogonalize ()
 Reorthogonalized columns of Q and updates factorization.

Protected Attributes

Teuchos::RCP< NOX::GlobalDataglobalDataPtr
 Pointer to the global data object.
Teuchos::RCP< NOX::UtilsutilsPtr
 Utils.
Teuchos::RCP< NOX::Abstract::GroupsolnPtr
 Current solution.
Teuchos::RCP< NOX::Abstract::GroupoldSolnPtr
 Previous solution pointer.
Teuchos::RCP< NOX::StatusTest::GenerictestPtr
 Stopping test.
Teuchos::RCP< Teuchos::ParameterList > paramsPtr
 Input parameters.
Teuchos::RCP< NOX::LineSearch::GenericlineSearchPtr
 Linesearch.
bool precond
 Flag for preconditioning.
bool recomputeJacobian
 Flag to recompute Jacobian each iterate. Needed if Jacobian required to apply preconditioner.
Teuchos::RCP< NOX::Abstract::VectorworkVec
 Vector for temporary storage.
Teuchos::RCP< NOX::Abstract::VectorprecF
 Current preconditioned function value.
Teuchos::RCP< NOX::Abstract::VectoroldPrecF
 Previous preconditioned function value.
int storeParam
 Maximum storage depth.
int nStore
 Current storage depth.
double mixParam
 Mixing parameter.
double stepSize
 Current step.
std::vector< Teuchos::RCP< NOX::Abstract::Vector > > xMat
 "Matrix" of successive iterate differences
std::vector< Teuchos::RCP< NOX::Abstract::Vector > > qMat
 Q factor the for least-squares problem.
Teuchos::SerialDenseMatrix< int, double > rMat
 R factor for the least-squares problem.
int nIter
 Number of nonlinear iterations.
int orthoFrequency
 Frequency for reorthogonalization of QR factors. If nonpositive, we never reorthogonalize.
NOX::StatusTest::StatusType status
 Status of nonlinear solver.
NOX::StatusTest::CheckType checkType
 Type of check to use for status tests. See NOX::StatusTest for more details.
Teuchos::RCP< NOX::Observerobserver
 Pointer to a user defined NOX::Observer object.
std::vector< double > WORK
 Scratch space for condition number estimation using LAPACK.
std::vector< int > IWORK
 Scratch space for condition number estimation using LAPACK.
bool adjustForConditionNumber
 If true, the QR matrix will be resized if the condiiton number is greater than the dropTolerance.
double dropTolerance
 Value of the condition number above which the QR matrix is resized.
int accelerationStartIteration
 The nonlinear iteration where Anderson Acceleration will start.
bool disableChecksForUnitTesting
 Disables the storage depth size check - used for unit testing corner cases only.

Detailed Description

Nonlinear solver based on Anderson Acceleration.

Solves $F(x)=0$ using Anderson Acceleration.

This method requires a mixing parameter $\beta$ and a preconditioner $M(x)$. If preconditioning is not supported, it is taken to be the identity.

For the first iteration, the solver computes $x_1 = x_0 + \beta M(x_0)F(x_0)$.

Each iteration afterward, the solver does the following.

  • Set $m_k = \min\{m,k\}$, where $m$ is a parameter that determines the maximum number of iterates for which we store iterate and function values in addition to the current iterate. $m_k$ represents the number of previous iterates stored currently.

  • Solve the least-squares problem: $\min_{\gamma}\|\sum_{i=0}^{m_k} \alpha_iM(x_{k-i})F(x_{k-i}) \|$, such that $ \sum_{i=1}^{m_k} \alpha_i = 1 $. In this implementation, we solve an equivalent unconstrained problem for which the QR factors are stored and updated.

  • Calculate the new iterate: $x_{k+1} = \sum_{i=0}^{m_k} \alpha_i[x_{k-i} + \beta M(x_{k-i})F(x_{k-i})]$.

The iterations progress until the status tests (see NOX::StatusTest) determine either failure or convergence.

Input Parameters

The following parameter list entries are valid for this solver:

  • "Anderson Parameters" - Sublist of parameters specific to AA
  • "Line Search" - Sublist of the line search parameters, passed to the NOX::LineSearch::Manager constructor. Defaults to an empty list.
  • "Solver Options" - Sublist of general solver options.
    • "User Defined Pre/Post Operator" is supported. See NOX::Parameter::PrePostOperator for more details.

Output Parameters

Every time solve() is called, a sublist for output parameters called "Output" will be created and contain the following parameters.

"Output":

  • "Nonlinear Iterations" - Number of nonlinear iterations
  • "2-Norm of Residual" - Two-norm of final residual
Author
Alex Toth and Roger Pawlowski

Constructor & Destructor Documentation

◆ AndersonAcceleration()

NOX::Solver::AndersonAcceleration::AndersonAcceleration ( const Teuchos::RCP< NOX::Abstract::Group > & grp,
const Teuchos::RCP< NOX::StatusTest::Generic > & tests,
const Teuchos::RCP< Teuchos::ParameterList > & params )

Constructor.

See reset(NOX::Abstract::Group&, NOX::StatusTest::Generic&, Teuchos::ParameterList&) for description

References NOX::DeepCopy, globalDataPtr, init(), observer, oldPrecF, oldSolnPtr, paramsPtr, NOX::Solver::parseObserver(), precF, NOX::ShapeCopy, solnPtr, testPtr, utilsPtr, NOX::Solver::validateSolverOptionsSublist(), and workVec.

Member Function Documentation

◆ getList()

const Teuchos::ParameterList & NOX::Solver::AndersonAcceleration::getList ( ) const
virtual

Return a reference to the solver parameters.

Implements NOX::Solver::Generic.

References paramsPtr.

◆ getListPtr()

virtual Teuchos::RCP< const Teuchos::ParameterList > NOX::Solver::AndersonAcceleration::getListPtr ( ) const
inlinevirtual

Return a RCP to the solver parameters.

Implements NOX::Solver::Generic.

References paramsPtr.

◆ getNumIterations()

int NOX::Solver::AndersonAcceleration::getNumIterations ( ) const
virtual

Get number of iterations.

Implements NOX::Solver::Generic.

References nIter.

◆ getPreviousSolutionGroup()

const NOX::Abstract::Group & NOX::Solver::AndersonAcceleration::getPreviousSolutionGroup ( ) const
virtual

Return a reference to the previous solution group.

Implements NOX::Solver::Generic.

References oldSolnPtr.

◆ getPreviousSolutionGroupPtr()

virtual Teuchos::RCP< const NOX::Abstract::Group > NOX::Solver::AndersonAcceleration::getPreviousSolutionGroupPtr ( ) const
inlinevirtual

Return a RCP to the previous solution group.

Implements NOX::Solver::Generic.

References oldSolnPtr.

◆ getSolutionGroup()

const NOX::Abstract::Group & NOX::Solver::AndersonAcceleration::getSolutionGroup ( ) const
virtual

Return a reference to the current solution group.

Implements NOX::Solver::Generic.

References solnPtr.

◆ getSolutionGroupPtr()

virtual Teuchos::RCP< const NOX::Abstract::Group > NOX::Solver::AndersonAcceleration::getSolutionGroupPtr ( ) const
inlinevirtual

Return a RCP to the solution group.

Implements NOX::Solver::Generic.

References solnPtr.

◆ getSolverStatistics()

Teuchos::RCP< const NOX::SolverStats > NOX::Solver::AndersonAcceleration::getSolverStatistics ( ) const
virtual

Return a RCP to the solver statistics.

Implements NOX::Solver::Generic.

References globalDataPtr.

◆ getStatus()

NOX::StatusTest::StatusType NOX::Solver::AndersonAcceleration::getStatus ( ) const
virtual

Returns the current status of the solver.

Implements NOX::Solver::Generic.

References status.

◆ init()

◆ printUpdate()

void NOX::Solver::AndersonAcceleration::printUpdate ( )
protectedvirtual

◆ qrAdd()

void NOX::Solver::AndersonAcceleration::qrAdd ( NOX::Abstract::Vector & newCol)
protected

◆ qrDelete()

void NOX::Solver::AndersonAcceleration::qrDelete ( )
protected

Updates QR factors by deletion of a column.

References nStore, qMat, rMat, and workVec.

Referenced by step().

◆ reorthogonalize()

void NOX::Solver::AndersonAcceleration::reorthogonalize ( )
protected

Reorthogonalized columns of Q and updates factorization.

References disableChecksForUnitTesting, nStore, qMat, and rMat.

Referenced by step().

◆ reset() [1/3]

void NOX::Solver::AndersonAcceleration::reset ( )
virtual

Resets the solver for another solve. This resets the counters and status only. Uses the final solution from the last solve as the initial guess for the next solve.

NOTE: All NOX solvers will call reset() automatically at teh beginning of the solve() method. We add the reset() method to the solver interface for the application to call in case the application needs to reset counters and status manually before the next call to solve() is made.

Implements NOX::Solver::Generic.

References globalDataPtr, nIter, nStore, status, NOX::StatusTest::Unconverged, and workVec.

Referenced by solve().

◆ reset() [2/3]

void NOX::Solver::AndersonAcceleration::reset ( const NOX::Abstract::Vector & initial_guess)
virtual

Resets the solver and sets a new initial guess.

Implements NOX::Solver::Generic.

References globalDataPtr, nIter, nStore, solnPtr, status, NOX::StatusTest::Unconverged, and workVec.

◆ reset() [3/3]

void NOX::Solver::AndersonAcceleration::reset ( const NOX::Abstract::Vector & initial_guess,
const Teuchos::RCP< NOX::StatusTest::Generic > & test )
virtual

Resets the solver, sets a new status test, and sets a new initial guess.

Implements NOX::Solver::Generic.

References globalDataPtr, nIter, nStore, solnPtr, status, stepSize, testPtr, NOX::StatusTest::Unconverged, and workVec.

◆ solve()

NOX::StatusTest::StatusType NOX::Solver::AndersonAcceleration::solve ( )
virtual

Solve the nonlinear problem and return final status.

By "solve", we call iterate() until the NOX::StatusTest value is either NOX::StatusTest::Converged or NOX::StatusTest::Failed.

Implements NOX::Solver::Generic.

References nIter, observer, paramsPtr, reset(), solnPtr, status, step(), and NOX::StatusTest::Unconverged.

◆ step()

Member Data Documentation

◆ accelerationStartIteration

int NOX::Solver::AndersonAcceleration::accelerationStartIteration
protected

The nonlinear iteration where Anderson Acceleration will start.

Referenced by init(), and step().

◆ adjustForConditionNumber

bool NOX::Solver::AndersonAcceleration::adjustForConditionNumber
protected

If true, the QR matrix will be resized if the condiiton number is greater than the dropTolerance.

Referenced by init(), and step().

◆ checkType

NOX::StatusTest::CheckType NOX::Solver::AndersonAcceleration::checkType
protected

Type of check to use for status tests. See NOX::StatusTest for more details.

Referenced by init(), and step().

◆ disableChecksForUnitTesting

bool NOX::Solver::AndersonAcceleration::disableChecksForUnitTesting
protected

Disables the storage depth size check - used for unit testing corner cases only.

Referenced by init(), qrAdd(), and reorthogonalize().

◆ dropTolerance

double NOX::Solver::AndersonAcceleration::dropTolerance
protected

Value of the condition number above which the QR matrix is resized.

Referenced by init(), and step().

◆ globalDataPtr

Teuchos::RCP<NOX::GlobalData> NOX::Solver::AndersonAcceleration::globalDataPtr
protected

Pointer to the global data object.

Referenced by AndersonAcceleration(), getSolverStatistics(), init(), reset(), reset(), reset(), and step().

◆ IWORK

std::vector<int> NOX::Solver::AndersonAcceleration::IWORK
protected

Scratch space for condition number estimation using LAPACK.

Referenced by step().

◆ lineSearchPtr

Teuchos::RCP<NOX::LineSearch::Generic> NOX::Solver::AndersonAcceleration::lineSearchPtr
protected

Linesearch.

Referenced by init(), and step().

◆ mixParam

double NOX::Solver::AndersonAcceleration::mixParam
protected

Mixing parameter.

Referenced by init(), and step().

◆ nIter

int NOX::Solver::AndersonAcceleration::nIter
protected

Number of nonlinear iterations.

Referenced by getNumIterations(), init(), printUpdate(), reset(), reset(), reset(), solve(), and step().

◆ nStore

int NOX::Solver::AndersonAcceleration::nStore
protected

Current storage depth.

Referenced by init(), qrAdd(), qrDelete(), reorthogonalize(), reset(), reset(), reset(), and step().

◆ observer

Teuchos::RCP<NOX::Observer> NOX::Solver::AndersonAcceleration::observer
protected

Pointer to a user defined NOX::Observer object.

Referenced by AndersonAcceleration(), solve(), and step().

◆ oldPrecF

Teuchos::RCP<NOX::Abstract::Vector> NOX::Solver::AndersonAcceleration::oldPrecF
protected

Previous preconditioned function value.

Referenced by AndersonAcceleration(), and step().

◆ oldSolnPtr

Teuchos::RCP<NOX::Abstract::Group> NOX::Solver::AndersonAcceleration::oldSolnPtr
protected

◆ orthoFrequency

int NOX::Solver::AndersonAcceleration::orthoFrequency
protected

Frequency for reorthogonalization of QR factors. If nonpositive, we never reorthogonalize.

Referenced by init(), and step().

◆ paramsPtr

Teuchos::RCP<Teuchos::ParameterList> NOX::Solver::AndersonAcceleration::paramsPtr
protected

Input parameters.

Referenced by AndersonAcceleration(), getList(), getListPtr(), init(), solve(), and step().

◆ precF

Teuchos::RCP<NOX::Abstract::Vector> NOX::Solver::AndersonAcceleration::precF
protected

Current preconditioned function value.

Referenced by AndersonAcceleration(), and step().

◆ precond

bool NOX::Solver::AndersonAcceleration::precond
protected

Flag for preconditioning.

Referenced by init(), and step().

◆ qMat

std::vector< Teuchos::RCP<NOX::Abstract::Vector> > NOX::Solver::AndersonAcceleration::qMat
protected

Q factor the for least-squares problem.

Referenced by init(), qrAdd(), qrDelete(), reorthogonalize(), and step().

◆ recomputeJacobian

bool NOX::Solver::AndersonAcceleration::recomputeJacobian
protected

Flag to recompute Jacobian each iterate. Needed if Jacobian required to apply preconditioner.

Referenced by init(), and step().

◆ rMat

Teuchos::SerialDenseMatrix<int,double> NOX::Solver::AndersonAcceleration::rMat
protected

R factor for the least-squares problem.

Referenced by qrAdd(), qrDelete(), reorthogonalize(), and step().

◆ solnPtr

Teuchos::RCP<NOX::Abstract::Group> NOX::Solver::AndersonAcceleration::solnPtr
protected

◆ status

NOX::StatusTest::StatusType NOX::Solver::AndersonAcceleration::status
protected

Status of nonlinear solver.

Referenced by getStatus(), init(), printUpdate(), reset(), reset(), reset(), solve(), and step().

◆ stepSize

double NOX::Solver::AndersonAcceleration::stepSize
protected

Current step.

Referenced by init(), printUpdate(), reset(), and step().

◆ storeParam

int NOX::Solver::AndersonAcceleration::storeParam
protected

Maximum storage depth.

Referenced by init(), and step().

◆ testPtr

Teuchos::RCP<NOX::StatusTest::Generic> NOX::Solver::AndersonAcceleration::testPtr
protected

Stopping test.

Referenced by AndersonAcceleration(), printUpdate(), reset(), and step().

◆ utilsPtr

Teuchos::RCP<NOX::Utils> NOX::Solver::AndersonAcceleration::utilsPtr
protected

◆ WORK

std::vector<double> NOX::Solver::AndersonAcceleration::WORK
protected

Scratch space for condition number estimation using LAPACK.

Referenced by step().

◆ workVec

Teuchos::RCP<NOX::Abstract::Vector> NOX::Solver::AndersonAcceleration::workVec
protected

Vector for temporary storage.

Referenced by AndersonAcceleration(), init(), qrDelete(), reset(), reset(), reset(), and step().

◆ xMat

std::vector< Teuchos::RCP<NOX::Abstract::Vector> > NOX::Solver::AndersonAcceleration::xMat
protected

"Matrix" of successive iterate differences

Referenced by init(), and step().


The documentation for this class was generated from the following files: