13#ifndef OPTIMIST_OPTIMIZER_HH
14#define OPTIMIST_OPTIMIZER_HH
45 template <
typename Real, Integer N,
typename DerivedSolver,
bool ForceEigen = false>
50 static_assert(N != 0,
"Have you ever heard of a zero-dimensional optimization problem?");
75 std::string
name()
const {
return static_cast<const DerivedSolver *
>(
this)->name_impl();}
128 template <
typename GradientLambda>
142 template <
typename HessianLambda>
158 #define CMD "Optimist::Optimizer::solve(...): "
160 static_assert(DerivedSolver::requires_function,
161 CMD "the solver requires the function.");
162 return static_cast<DerivedSolver *
>(
this)->solve_impl(
163 std::forward<FunctionLambda>(function),
179 template <
typename FunctionLambda,
typename GradientLambda>
180 bool solve(FunctionLambda && function, GradientLambda && gradient,
Vector const & x_ini,
Vector & x_sol)
182 #define CMD "Optimist::Optimizer::solve(...): "
184 static_assert(DerivedSolver::requires_function,
185 CMD "the solver requires the function.");
186 static_assert(DerivedSolver::requires_first_derivative,
187 CMD "the solver requires the first derivative.");
188 return static_cast<DerivedSolver *
>(
this)->solve_impl(
189 std::forward<FunctionLambda>(function),
190 std::forward<GradientLambda>(gradient),
208 template <
typename FunctionLambda,
typename GradientLambda,
typename HessianLambda>
209 bool solve(FunctionLambda && function, GradientLambda && gradient, HessianLambda && hessian,
212 #define CMD "Optimist::Optimizer::solve(...): "
214 static_assert(DerivedSolver::requires_function,
215 CMD "the solver requires the function.");
216 static_assert(DerivedSolver::requires_first_derivative,
217 CMD "the solver requires the first derivative.");
218 static_assert(DerivedSolver::requires_second_derivative,
219 CMD "the solver requires the second derivative.");
220 return static_cast<DerivedSolver *
>(
this)->solve_impl(
221 std::forward<FunctionLambda>(function),
222 std::forward<GradientLambda>(gradient),
223 std::forward<HessianLambda>(hessian),
239 template <
typename Real,
typename DerivedSolver>
259 std::string
name()
const {
return static_cast<const DerivedSolver *
>(
this)->name_impl();}
#define OPTIMIST_BASIC_CONSTANTS(Real)
Definition Optimist.hh:71
std::string name() const
Definition Optimizer.hh:259
static constexpr bool is_rootfinder
Definition Optimizer.hh:245
static constexpr bool is_optimizer
Definition Optimizer.hh:246
Optimizer()
Definition Optimizer.hh:253
Class container for the multi-dimensional optimizer.
Definition Optimizer.hh:47
Optimizer()
Definition Optimizer.hh:69
typename SolverBase< Real, N, 1, DerivedSolver, ForceEigen >::InputType Vector
Definition Optimizer.hh:60
std::string name() const
Definition Optimizer.hh:75
static constexpr bool is_rootfinder
Definition Optimizer.hh:54
Integer max_gradient_evaluations() const
Definition Optimizer.hh:87
bool solve(FunctionLambda &&function, Vector const &x_ini, Vector &x_sol)
Definition Optimizer.hh:156
static constexpr bool is_optimizer
Definition Optimizer.hh:55
typename SolverBase< Real, N, 1, DerivedSolver, ForceEigen >::FirstDerivativeType RowVector
Definition Optimizer.hh:63
bool evaluate_hessian(HessianLambda &&hessian, Vector const &x, Matrix &out)
Definition Optimizer.hh:143
Integer hessian_evaluations() const
Definition Optimizer.hh:102
Integer max_hessian_evaluations() const
Definition Optimizer.hh:108
void max_gradient_evaluations(Integer t_gradient_evaluations)
Definition Optimizer.hh:93
Integer gradient_evaluations() const
Definition Optimizer.hh:81
bool evaluate_gradient(GradientLambda &&gradient, Vector const &x, Matrix &out)
Definition Optimizer.hh:129
void max_hessian_evaluations(Integer t_hessian_evaluations)
Definition Optimizer.hh:114
typename SolverBase< Real, N, 1, DerivedSolver, ForceEigen >::SecondDerivativeType Matrix
Definition Optimizer.hh:64
bool solve(FunctionLambda &&function, GradientLambda &&gradient, Vector const &x_ini, Vector &x_sol)
Definition Optimizer.hh:180
bool solve(FunctionLambda &&function, GradientLambda &&gradient, HessianLambda &&hessian, Vector const &x_ini, Vector &x_sol)
Definition Optimizer.hh:209
bool evaluate_second_derivative(SecondDerivativeLambda &&function, InputType const &x, SecondDerivativeType &out)
Definition SolverBase.hh:801
Integer max_first_derivative_evaluations() const
Definition SolverBase.hh:289
Integer max_second_derivative_evaluations() const
Definition SolverBase.hh:312
Integer second_derivative_evaluations() const
Definition SolverBase.hh:306
SolverBase()
Definition SolverBase.hh:105
std::conditional_t< ForceEigen||(SolInDim > 1)||(SolOutDim > 1), std::conditional_t< SolInDim==1||SolOutDim==1, Eigen::Matrix< Real, SolInDim, SolInDim >, std::vector< Eigen::Matrix< Real, SolInDim, SolInDim > > >, Real > SecondDerivativeType
Definition SolverBase.hh:64
typename std::conditional_t< ForceEigen||(SolInDim > 1), Eigen::Vector< Real, SolInDim >, Real > InputType
Definition SolverBase.hh:53
std::conditional_t< ForceEigen||(SolInDim > 1)||(SolOutDim > 1), Eigen::Matrix< Real, SolOutDim, SolInDim >, Real > FirstDerivativeType
Definition SolverBase.hh:62
Integer first_derivative_evaluations() const
Definition SolverBase.hh:283
bool evaluate_first_derivative(FirstDerivativeLambda &&function, InputType const &x, FirstDerivativeType &out)
Definition SolverBase.hh:785
Namespace for the Optimist library.
Definition Optimist.hh:88
OPTIMIST_DEFAULT_INTEGER_TYPE Integer
The Integer type as used for the API.
Definition Optimist.hh:96