13#ifndef OPTIMIST_ROOTFINDER_QUASINEWTON_HH
14#define OPTIMIST_ROOTFINDER_QUASINEWTON_HH
40 template <
typename Real, Integer N,
typename DerivedSolver>
72 return static_cast<const DerivedSolver *
>(
this)->
name_impl();
95 Real residuals, step_norm;
96 Vector x_old, x_new, function_old, function_new, step_old, step_new, delta_x_old, delta_x_new,
97 delta_function_old, delta_function_new;
98 Matrix jacobian_old, jacobian_new;
114 step_old = -jacobian_old * function_old;
117 residuals = function_old.norm();
118 step_norm = step_old.norm();
120 if (residuals < tolerance_residuals || step_norm < tolerance_step_norm) {
128 damped = this->
damp(function, x_old, function_old, step_old, x_new, function_new, step_new);
130 "Optimist::RootFinder::QuasiNewton::solve(...): damping failed.");
133 x_new = x_old + step_old;
138 delta_x_new = x_new - x_old;
139 delta_function_new = function_new - function_old;
141 delta_x_old, delta_function_old, jacobian_old,
142 delta_x_new, delta_function_new, function_new, jacobian_new
147 function_old = function_new;
148 delta_x_old = delta_x_new;
149 delta_function_old = delta_function_new;
151 jacobian_old = jacobian_new;
173 Vector const & delta_x_old,
Vector const & delta_function_old,
Matrix const & jacobian_old,
174 Vector const & delta_x_new,
Vector const & delta_function_new,
Vector const & function_new,
177 static_cast<DerivedSolver *
>(
this)->update_impl(
178 delta_x_old, delta_function_old, jacobian_old,
179 delta_x_new, delta_function_new, function_new, jacobian_new
#define OPTIMIST_ASSERT_WARNING(COND, MSG)
Definition Optimist.hh:60
#define OPTIMIST_BASIC_CONSTANTS(Real)
Definition Optimist.hh:70
void update(Vector const &delta_x_old, Vector const &delta_function_old, Matrix const &jacobian_old, Vector const &delta_x_new, Vector const &delta_function_new, Vector const &function_new, Matrix &jacobian_new)
Definition QuasiNewton.hh:172
QuasiNewton()
Definition QuasiNewton.hh:64
bool solve_impl(FunctionWrapper function, JacobianWrapper jacobian, Vector const &x_ini, Vector &x_sol)
Definition QuasiNewton.hh:84
Method m_method
Definition QuasiNewton.hh:58
typename RootFinder< Real, N, DerivedSolver >::FunctionWrapper FunctionWrapper
Definition QuasiNewton.hh:53
static constexpr bool requires_first_derivative
Definition QuasiNewton.hh:45
enum class Method :Integer {GOOD=0, BAD=1, COMBINED=2} Method
Definition QuasiNewton.hh:50
std::string name_impl() const
Definition QuasiNewton.hh:70
typename RootFinder< Real, N, DerivedSolver >::JacobianWrapper JacobianWrapper
Definition QuasiNewton.hh:54
typename RootFinder< Real, N, DerivedSolver >::Matrix Matrix
Definition QuasiNewton.hh:52
static constexpr bool requires_second_derivative
Definition QuasiNewton.hh:46
typename RootFinder< Real, N, DerivedSolver >::Vector Vector
Definition QuasiNewton.hh:51
static constexpr bool requires_function
Definition QuasiNewton.hh:44
RootFinder()
Definition RootFinder.hh:83
typename Solver< Real, N, N, DerivedSolver >::FirstDerivativeWrapper JacobianWrapper
Definition RootFinder.hh:77
typename Solver< Real, N, N, DerivedSolver >::InputType Vector
Definition RootFinder.hh:69
void evaluate_jacobian(JacobianWrapper jacobian, const Vector &x, Matrix &out)
Definition RootFinder.hh:140
typename Solver< Real, N, N, DerivedSolver >::FunctionWrapper FunctionWrapper
Definition RootFinder.hh:76
bool solve(FunctionWrapper function, Vector const &x_ini, Vector &x_sol)
Definition RootFinder.hh:164
typename Solver< Real, N, N, DerivedSolver >::FirstDerivativeType Matrix
Definition RootFinder.hh:72
Real m_tolerance
Definition Solver.hh:92
bool m_verbose
Definition Solver.hh:93
bool m_converged
Definition Solver.hh:99
bool m_damped
Definition Solver.hh:94
void store_trace(const InputType &x)
Definition Solver.hh:750
void header()
Definition Solver.hh:799
void reset()
Definition Solver.hh:693
bool damp(FunctionWrapper function, InputType const &x_old, InputType const &function_old, InputType const &step_old, InputType &x_new, InputType &function_new, InputType &step_new)
Definition Solver.hh:763
void bottom()
Definition Solver.hh:829
void evaluate_function(FunctionWrapper function, const InputType &x, OutputType &out)
Definition Solver.hh:710
void info(Real residuals, std::string const ¬es="-")
Definition Solver.hh:853
Integer m_iterations
Definition Solver.hh:85
Integer m_max_iterations
Definition Solver.hh:86
Namespace for the Optimist library.
Definition Optimist.hh:87
OPTIMIST_DEFAULT_INTEGER_TYPE Integer
The Integer type as used for the API.
Definition Optimist.hh:95