Optimist  0.0.0
A C++ library for optimization
Loading...
Searching...
No Matches
Optimist::RootFinder::Bracketing< Real, DerivedSolver > Class Template Reference

Class container for the Bracketing algorithms. More...

#include <Bracketing.hh>

Inherits Optimist::RootFinder::RootFinder< Real, 1, DerivedSolver >.

Public Member Functions

 Bracketing ()
std::string name_impl () const
void tolerance_bracketing (Real t_tolerance)
template<typename FunctionLambda>
bool solve_impl (FunctionLambda &&function, Real, Real &x_sol)
template<typename FunctionLambda>
Real find_root (FunctionLambda &&function)
Public Member Functions inherited from Optimist::RootFinder::RootFinder< Real, 1, DerivedSolver >
 RootFinder ()
std::string name () const
template<typename FunctionLambda>
bool solve (FunctionLambda &&function, Real x_ini, Real &x_sol)
template<typename FunctionLambda, typename FirstDerivativeLambda>
bool solve (FunctionLambda &&function, FirstDerivativeLambda &&first_derivative, Real x_ini, Real &x_sol)
template<typename FunctionLambda, typename FirstDerivativeLambda, typename SecondDerivativeLambda>
bool solve (FunctionLambda &&function, FirstDerivativeLambda &&first_derivative, SecondDerivativeLambda &&second_derivate, Real x_ini, Real &x_sol)
Integer jacobian_evaluations () const
Integer max_jacobian_evaluations () const
Integer hessian_evaluations () const
Integer max_hessian_evaluations () const
Public Member Functions inherited from Optimist::SolverBase< Real, N, N, DerivedSolver, false >
 SolverBase ()
InputType const & lower_bound () const
InputType const & upper_bound () const
void bounds (InputType const &t_lower_bound, InputType const &t_upper_bound)
constexpr Integer input_dimension () const
constexpr Integer output_dimension () const
Integer function_evaluations () const
void max_function_evaluations (Integer t_max_function_evaluations)
Integer iterations () const
Integer max_iterations () const
Real alpha () const
Integer relaxations () const
Integer max_relaxations () const
Real tolerance () const
void verbose_mode (bool t_verbose)
void enable_verbose_mode ()
void disable_verbose_mode ()
void damped_mode (bool t_damped)
void enable_damped_mode ()
void disable_damped_mode ()
std::string task () const
bool converged () const
const TraceTypetrace () const
std::ostream & ostream () const
bool solve (FunctionLambda &&function, InputType const &x_ini, InputType &x_sol)
bool rootfind (FunctionBase< Real, FunInDim, FunOutDim, DerivedFunction, ForceEigen &&FunOutDim==1 > const &function, InputType const &x_ini, InputType &x_sol)
bool optimize (FunctionBase< Real, FunInDim, FunOutDim, DerivedFunction, ForceEigen &&FunOutDim==1 > const &function, InputType const &x_ini, InputType &x_sol)
std::string name () const
Public Member Functions inherited from Optimist::SolverBase< Real, 1, 1, DerivedSolver >
 SolverBase ()
InputType const & lower_bound () const
InputType const & upper_bound () const
void bounds (InputType const &t_lower_bound, InputType const &t_upper_bound)
constexpr Integer input_dimension () const
constexpr Integer output_dimension () const
Integer function_evaluations () const
void max_function_evaluations (Integer t_max_function_evaluations)
Integer iterations () const
Integer max_iterations () const
Real alpha () const
Integer relaxations () const
Integer max_relaxations () const
Real tolerance () const
void verbose_mode (bool t_verbose)
void enable_verbose_mode ()
void disable_verbose_mode ()
void damped_mode (bool t_damped)
void enable_damped_mode ()
void disable_damped_mode ()
std::string task () const
bool converged () const
const TraceTypetrace () const
std::ostream & ostream () const
bool solve (FunctionLambda &&function, InputType const &x_ini, InputType &x_sol)
bool rootfind (FunctionBase< Real, FunInDim, FunOutDim, DerivedFunction, false &&FunOutDim==1 > const &function, InputType const &x_ini, InputType &x_sol)
bool optimize (FunctionBase< Real, FunInDim, FunOutDim, DerivedFunction, false &&FunOutDim==1 > const &function, InputType const &x_ini, InputType &x_sol)
std::string name () const

Protected Attributes

Real m_tolerance_bracketing {100*EPSILON}
Real m_mu {0.5}
Real m_interval_shink {0.025}
Real m_a {0.0}
Real m_fa {0.0}
Real m_b {0.0}
Real m_fb {0.0}
Real m_c {0.0}
Real m_fc {0.0}
Real m_d {0.0}
Real m_fd {0.0}
Real m_e {0.0}
Real m_fe {0.0}
Protected Attributes inherited from Optimist::SolverBase< Real, N, N, DerivedSolver, false >
InputType m_lower_bound
InputType m_upper_bound
Integer m_function_evaluations
Integer m_first_derivative_evaluations
Integer m_second_derivative_evaluations
Integer m_max_function_evaluations
Integer m_max_first_derivative_evaluations
Integer m_max_second_derivative_evaluations
Integer m_iterations
Integer m_max_iterations
Real m_alpha
Integer m_relaxations
Integer m_max_relaxations
Real m_tolerance
bool m_verbose
bool m_damped
std::ostream * m_ostream
std::string m_task
bool m_converged
TraceType m_trace
Protected Attributes inherited from Optimist::SolverBase< Real, 1, 1, DerivedSolver >
InputType m_lower_bound
InputType m_upper_bound
Integer m_function_evaluations
Integer m_first_derivative_evaluations
Integer m_second_derivative_evaluations
Integer m_max_function_evaluations
Integer m_max_first_derivative_evaluations
Integer m_max_second_derivative_evaluations
Integer m_iterations
Integer m_max_iterations
Real m_alpha
Integer m_relaxations
Integer m_max_relaxations
Real m_tolerance
bool m_verbose
bool m_damped
std::ostream * m_ostream
std::string m_task
bool m_converged
TraceType m_trace

Additional Inherited Members

Public Types inherited from Optimist::RootFinder::RootFinder< Real, 1, DerivedSolver >
using Vector
using Matrix
using Tensor
Public Types inherited from Optimist::SolverBase< Real, N, N, DerivedSolver, false >
using InputType
using OutputType
using TraceType
using FirstDerivativeType
using SecondDerivativeType
Public Types inherited from Optimist::SolverBase< Real, 1, 1, DerivedSolver >
using InputType
using OutputType
using TraceType
using FirstDerivativeType
using SecondDerivativeType
Static Public Attributes inherited from Optimist::RootFinder::RootFinder< Real, 1, DerivedSolver >
static constexpr bool is_rootfinder {true}
static constexpr bool is_optimizer {false}
Protected Member Functions inherited from Optimist::RootFinder::RootFinder< Real, 1, DerivedSolver >
bool evaluate_jacobian (JacobianLambda &&jacobian, Vector const &x, Matrix &out)
bool evaluate_hessian (HessianLambda &&hessian, Vector const &x, Matrix &out)
Protected Member Functions inherited from Optimist::SolverBase< Real, N, N, DerivedSolver, false >
Integer first_derivative_evaluations () const
Integer max_first_derivative_evaluations () const
Integer second_derivative_evaluations () const
Integer max_second_derivative_evaluations () const
void reset ()
bool evaluate_function (FunctionLambda &&function, InputType const &x, OutputType &out)
bool evaluate_first_derivative (FirstDerivativeLambda &&function, InputType const &x, FirstDerivativeType &out)
bool evaluate_second_derivative (SecondDerivativeLambda &&function, InputType const &x, SecondDerivativeType &out)
void store_trace (InputType const &x)
bool damp (FunctionLambda &&function, InputType const &x_old, InputType const &function_old, InputType const &step_old, InputType &x_new, InputType &function_new, InputType &step_new)
void header ()
void bottom ()
void info (Real residuals, std::string const &notes="-")
Protected Member Functions inherited from Optimist::SolverBase< Real, 1, 1, DerivedSolver >
Integer first_derivative_evaluations () const
Integer max_first_derivative_evaluations () const
Integer second_derivative_evaluations () const
Integer max_second_derivative_evaluations () const
void reset ()
bool evaluate_function (FunctionLambda &&function, InputType const &x, OutputType &out)
bool evaluate_first_derivative (FirstDerivativeLambda &&function, InputType const &x, FirstDerivativeType &out)
bool evaluate_second_derivative (SecondDerivativeLambda &&function, InputType const &x, SecondDerivativeType &out)
void store_trace (InputType const &x)
bool damp (FunctionLambda &&function, InputType const &x_old, InputType const &function_old, InputType const &step_old, InputType &x_new, InputType &function_new, InputType &step_new)
void header ()
void bottom ()
void info (Real residuals, std::string const &notes="-")

Detailed Description

template<typename Real, typename DerivedSolver>
class Optimist::RootFinder::Bracketing< Real, DerivedSolver >

The Bracketing algorithms allow to find the roots of a scalar function \(f(x)\) in a given interval \([a, b]\).

Template Parameters
RealScalar number type.

Constructor & Destructor Documentation

◆ Bracketing()

template<typename Real, typename DerivedSolver>
Optimist::RootFinder::Bracketing< Real, DerivedSolver >::Bracketing ( )
inline

Class constructor for the Algorithm 748.

Member Function Documentation

◆ find_root()

template<typename Real, typename DerivedSolver>
template<typename FunctionLambda>
Real Optimist::RootFinder::Bracketing< Real, DerivedSolver >::find_root ( FunctionLambda && function)
inline

Finds either an exact solution or an approximate solution of the equation \(f(x) = 0\) in the interval \([a, b]\).

Template Parameters
FunctionLambdaThe lambda function type.
Parameters
[in]functionFunction lambda.
Returns
The approximate root.

◆ name_impl()

template<typename Real, typename DerivedSolver>
std::string Optimist::RootFinder::Bracketing< Real, DerivedSolver >::name_impl ( ) const
inline

Get the Algorithm 748 solver name.

Returns
The Algorithm 748 solver name.

◆ solve_impl()

template<typename Real, typename DerivedSolver>
template<typename FunctionLambda>
bool Optimist::RootFinder::Bracketing< Real, DerivedSolver >::solve_impl ( FunctionLambda && function,
Real ,
Real & x_sol )
inline

Solve the nonlinear equation \( f(x) = 0 \), with \( f: \mathbb{R} \rightarrow \mathbb{R} \).

Template Parameters
FunctionLambdaThe lambda function type.
Parameters
[in]functionFunction lambda.
[in]x_iniInitialization point (not used).
[out]x_solSolution point.
Returns
The convergence boolean flag.

◆ tolerance_bracketing()

template<typename Real, typename DerivedSolver>
void Optimist::RootFinder::Bracketing< Real, DerivedSolver >::tolerance_bracketing ( Real t_tolerance)
inline

Set the tolerance for the Algorithm 748 solver.

Parameters
[in]t_toleranceThe input value at which the tolerance is computed.
Note
To accurately find polynomial roots, the tolerance should be set to \( 100\epsilon(0) \).

Member Data Documentation

◆ m_a

template<typename Real, typename DerivedSolver>
Real Optimist::RootFinder::Bracketing< Real, DerivedSolver >::m_a {0.0}
protected

◆ m_b

template<typename Real, typename DerivedSolver>
Real Optimist::RootFinder::Bracketing< Real, DerivedSolver >::m_b {0.0}
protected

◆ m_c

template<typename Real, typename DerivedSolver>
Real Optimist::RootFinder::Bracketing< Real, DerivedSolver >::m_c {0.0}
protected

◆ m_d

template<typename Real, typename DerivedSolver>
Real Optimist::RootFinder::Bracketing< Real, DerivedSolver >::m_d {0.0}
protected

◆ m_e

template<typename Real, typename DerivedSolver>
Real Optimist::RootFinder::Bracketing< Real, DerivedSolver >::m_e {0.0}
protected

◆ m_fa

template<typename Real, typename DerivedSolver>
Real Optimist::RootFinder::Bracketing< Real, DerivedSolver >::m_fa {0.0}
protected

◆ m_fb

template<typename Real, typename DerivedSolver>
Real Optimist::RootFinder::Bracketing< Real, DerivedSolver >::m_fb {0.0}
protected

◆ m_fc

template<typename Real, typename DerivedSolver>
Real Optimist::RootFinder::Bracketing< Real, DerivedSolver >::m_fc {0.0}
protected

◆ m_fd

template<typename Real, typename DerivedSolver>
Real Optimist::RootFinder::Bracketing< Real, DerivedSolver >::m_fd {0.0}
protected

◆ m_fe

template<typename Real, typename DerivedSolver>
Real Optimist::RootFinder::Bracketing< Real, DerivedSolver >::m_fe {0.0}
protected

◆ m_interval_shink

template<typename Real, typename DerivedSolver>
Real Optimist::RootFinder::Bracketing< Real, DerivedSolver >::m_interval_shink {0.025}
protected

Interval shrinking factor.

◆ m_mu

template<typename Real, typename DerivedSolver>
Real Optimist::RootFinder::Bracketing< Real, DerivedSolver >::m_mu {0.5}
protected

Parameter \( \mu \).

◆ m_tolerance_bracketing

template<typename Real, typename DerivedSolver>
Real Optimist::RootFinder::Bracketing< Real, DerivedSolver >::m_tolerance_bracketing {100*EPSILON}
protected

Tolerance for the Algorithm 748 solver.


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