NEML2 2.0.0
Loading...
Searching...
No Matches
NewtonWithTrustRegion Class Reference

The nonlinear solver solves a nonlinear system of equations. More...

Detailed Description

The nonlinear solver solves a nonlinear system of equations.

The Newton-Raphson method is used to iteratively update the initial guess until the residual becomes zero within specified tolerances.

Each update step is obtained by solving a trust-region subproblem, i.e. a quadratic bound-constrained problem.

The trust-region outer loop is implemented following Nocedal and Wright, section 4.1.

The subproblem implemented here is an alternative linearization of the original subproblem, introduced in

‍Yuan, Ya-xiang. Trust region algorithms for nonlinear equations. Hong Kong Baptist University, Department of Mathematics, 1994.

#include <NewtonWithTrustRegion.h>

Inheritance diagram for NewtonWithTrustRegion:

Public Member Functions

 NewtonWithTrustRegion (const OptionSet &options)
 
- Public Member Functions inherited from Newton
 Newton (const OptionSet &options)
 
Result solve (NonlinearSystem &system, const NonlinearSystem::Sol< false > &x0) override
 Solve the given nonlinear system.
 
- Public Member Functions inherited from NonlinearSolver
 NonlinearSolver (const OptionSet &options)
 Construct a new NonlinearSolver object.
 
- Public Member Functions inherited from Solver
 Solver (const OptionSet &options)
 Construct a new Solver object.
 
- Public Member Functions inherited from NEML2Object
 NEML2Object ()=delete
 
 NEML2Object (NEML2Object &&)=delete
 
 NEML2Object (const NEML2Object &)=delete
 
NEML2Objectoperator= (const NEML2Object &)=delete
 
NEML2Objectoperator= (NEML2Object &&)=delete
 
virtual ~NEML2Object ()=default
 
 NEML2Object (const OptionSet &options)
 Construct a new NEML2Object object.
 
const OptionSetinput_options () const
 
virtual void setup ()
 Setup this object.
 
const std::string & name () const
 A readonly reference to the object's name.
 
const std::string & type () const
 A readonly reference to the object's type.
 
const std::string & path () const
 A readonly reference to the object's path.
 
const std::string & doc () const
 A readonly reference to the object's docstring.
 
template<typename T = NEML2Object>
const T * host () const
 Get a readonly pointer to the host.
 
template<typename T = NEML2Object>
T * host ()
 Get a writable pointer to the host.
 

Static Public Member Functions

static OptionSet expected_options ()
 
- Static Public Member Functions inherited from Newton
static OptionSet expected_options ()
 
- Static Public Member Functions inherited from NonlinearSolver
static OptionSet expected_options ()
 
- Static Public Member Functions inherited from Solver
static OptionSet expected_options ()
 
- Static Public Member Functions inherited from NEML2Object
static OptionSet expected_options ()
 

Protected Member Functions

OptionSet subproblem_options (const OptionSet &) const
 Extract options for the subproblem.
 
OptionSet subproblem_solver_options (const OptionSet &) const
 Extract options for the subproblem solver.
 
void prepare (const NonlinearSystem &system, const NonlinearSystem::Sol< true > &x) override
 Prepare solver internal data before the iterative update.
 
void update (NonlinearSystem &system, NonlinearSystem::Sol< true > &x, const NonlinearSystem::Res< true > &r, const NonlinearSystem::Jac< true > &J) override
 Update trial solution.
 
NonlinearSystem::Sol< truesolve_direction (const NonlinearSystem::Res< true > &r, const NonlinearSystem::Jac< true > &J) override
 Find the current update direction.
 
Scalar merit_function_reduction (const NonlinearSystem::Res< true > &r, const NonlinearSystem::Jac< true > &J, const NonlinearSystem::Sol< true > &p) const
 Reduction in the merit function.
 
- Protected Member Functions inherited from Newton
virtual bool converged (size_t itr, const torch::Tensor &nR, const torch::Tensor &nR0) const
 Check for convergence. The current iteration is said to be converged if the residual norm is below the absolute tolerance or or the ratio between the residual norm and the initial residual norm is below the relative tolerance.
 
virtual void final_update (NonlinearSystem &system, NonlinearSystem::Sol< true > &x, const NonlinearSystem::Res< true > &r, const NonlinearSystem::Jac< true > &J)
 Do a final update to track AD function graph.
 

Protected Attributes

TrustRegionSubProblem _subproblem
 Trust-region subproblem.
 
Newton _subproblem_solver
 Solver used to solver the trust-region subproblem.
 
Scalar _delta
 The trust region radius.
 
Real _delta_0
 Initial size of the trust region.
 
Real _delta_max
 Maximum size of the trust region.
 
Real _reduce_criteria
 Criteria for reducing the trust region.
 
Real _expand_criteria
 Criteria for expanding the trust region.
 
Real _reduce_factor
 Cutback factor if we do reduce the trust region.
 
Real _expand_factor
 Expansion factor if we do increase the trust region.
 
Real _accept_criteria
 Acceptance criteria for a step.
 

Additional Inherited Members

- Public Types inherited from NonlinearSolver
enum class  RetCode { SUCCESS = 0 , MAXITER = 1 , FAILURE = 2 }
 
- Public Attributes inherited from NonlinearSolver
Real atol
 Absolute tolerance.
 
Real rtol
 Relative tolerance.
 
unsigned int miters
 Maximum number of iterations.
 
- Public Attributes inherited from Solver
const bool verbose
 Whether to print additional (debugging) information during the solve.
 

Constructor & Destructor Documentation

◆ NewtonWithTrustRegion()

Member Function Documentation

◆ expected_options()

OptionSet expected_options ( )
static

◆ merit_function_reduction()

Scalar merit_function_reduction ( const NonlinearSystem::Res< true > & r,
const NonlinearSystem::Jac< true > & J,
const NonlinearSystem::Sol< true > & p ) const
protected

Reduction in the merit function.

◆ prepare()

void prepare ( const NonlinearSystem & ,
const NonlinearSystem::Sol< true > &  )
overrideprotectedvirtual

Prepare solver internal data before the iterative update.

Reimplemented from Newton.

◆ solve_direction()

NonlinearSystem::Sol< true > solve_direction ( const NonlinearSystem::Res< true > & r,
const NonlinearSystem::Jac< true > & J )
overrideprotectedvirtual

Find the current update direction.

Reimplemented from Newton.

◆ subproblem_options()

OptionSet subproblem_options ( const OptionSet & ) const
protected

Extract options for the subproblem.

◆ subproblem_solver_options()

OptionSet subproblem_solver_options ( const OptionSet & options) const
protected

Extract options for the subproblem solver.

◆ update()

void update ( NonlinearSystem & system,
NonlinearSystem::Sol< true > & x,
const NonlinearSystem::Res< true > & r,
const NonlinearSystem::Jac< true > & J )
overrideprotectedvirtual

Update trial solution.

Reimplemented from Newton.

Member Data Documentation

◆ _accept_criteria

Real _accept_criteria
protected

Acceptance criteria for a step.

◆ _delta

Scalar _delta
protected

The trust region radius.

◆ _delta_0

Real _delta_0
protected

Initial size of the trust region.

◆ _delta_max

Real _delta_max
protected

Maximum size of the trust region.

◆ _expand_criteria

Real _expand_criteria
protected

Criteria for expanding the trust region.

◆ _expand_factor

Real _expand_factor
protected

Expansion factor if we do increase the trust region.

◆ _reduce_criteria

Real _reduce_criteria
protected

Criteria for reducing the trust region.

◆ _reduce_factor

Real _reduce_factor
protected

Cutback factor if we do reduce the trust region.

◆ _subproblem

TrustRegionSubProblem _subproblem
protected

Trust-region subproblem.

◆ _subproblem_solver

Newton _subproblem_solver
protected

Solver used to solver the trust-region subproblem.