13#ifndef OPTIMIST_SOLVER_HH
14#define OPTIMIST_SOLVER_HH
40 template <
typename Input,
typename Output,
typename DerivedSolver>
41 requires std::is_same<typename TypeTrait<Input>::Scalar,
42 typename TypeTrait<Output>::Scalar>::value &&
43 (TypeTrait<Input>::IsScalar || TypeTrait<Input>::IsEigen) &&
44 (TypeTrait<Output>::IsScalar || TypeTrait<Output>::IsEigen) &&
45 (!TypeTrait<Input>::IsFixed || TypeTrait<Input>::Dimension > 0) &&
46 (!TypeTrait<Output>::IsFixed ||
47 TypeTrait<Output>::Dimension > 0) &&
48 (!(TypeTrait<Input>::IsEigen && TypeTrait<Output>::IsEigen) ||
49 (TypeTrait<Input>::IsFixed && TypeTrait<Output>::IsFixed) ||
50 (TypeTrait<Input>::IsDynamic && TypeTrait<Output>::IsDynamic) ||
51 (TypeTrait<Input>::IsSparse && TypeTrait<Output>::IsSparse))
57 using Scalar =
typename InputTrait::Scalar;
60 static_assert(InputTrait::Dimension != 0,
61 "Input must be non-zero dimensional");
62 static_assert(OutputTrait::Dimension != 0,
63 "Output must be non-zero dimensional");
66 static_assert(std::is_same<
typename InputTrait::Scalar,
67 typename OutputTrait::Scalar>::value,
68 "Input and output scalar types must be the same.");
72 static_assert(!(InputTrait::IsEigen && OutputTrait::IsEigen) ||
73 (InputTrait::IsFixed && OutputTrait::IsFixed) ||
74 (InputTrait::IsDynamic && OutputTrait::IsDynamic) ||
75 (InputTrait::IsSparse && OutputTrait::IsSparse),
76 "Input and output Eigen types must be both fixed-size, "
77 "dynamic-size, or sparse.");
81 InputTrait::IsEigen || OutputTrait::IsEigen,
82 std::conditional_t<InputTrait::IsSparse || OutputTrait::IsSparse,
83 Eigen::SparseMatrix<Scalar>,
85 OutputTrait::Dimension,
86 InputTrait::Dimension>>,
89 InputTrait::IsEigen || OutputTrait::IsEigen,
90 std::conditional_t<InputTrait::IsSparse || OutputTrait::IsSparse,
91 std::vector<Eigen::SparseMatrix<Scalar>>,
92 std::vector<Eigen::Matrix<
Scalar,
93 OutputTrait::Dimension,
94 InputTrait::Dimension>>>,
151 template <
typename FunctionLambda>
152 SolverBase(FunctionLambda &&function,
const Input &x_ini, Input &x_sol)
154 static_cast<const DerivedSolver *
>(
this)->solve_impl(
155 std::forward<FunctionLambda>(function),
169 template <
typename FunctionLambda,
typename FirstDerivativeLambda>
171 FirstDerivativeLambda &&first_derivative,
175 static_cast<const DerivedSolver *
>(
this)->solve_impl(
176 std::forward<FunctionLambda>(function),
177 std::forward<FirstDerivativeLambda>(first_derivative),
193 template <
typename FunctionLambda,
194 typename FirstDerivativeLambda,
195 typename SecondDerivativeLambda>
197 FirstDerivativeLambda &&first_derivative,
198 SecondDerivativeLambda &&second_derivative,
202 static_cast<const DerivedSolver *
>(
this)->solve_impl(
203 std::forward<FunctionLambda>(function),
204 std::forward<FirstDerivativeLambda>(first_derivative),
205 std::forward<SecondDerivativeLambda>(second_derivative),
216 : InputTrait::Dimension) {
217#define CMD "Optimist::Solver::reset_bounds(...): "
219 if constexpr (InputTrait::IsScalar) {
220 this->m_lower_bound = -INFTY;
221 this->m_upper_bound = +INFTY;
222 }
else if constexpr (InputTrait::IsFixed) {
223 this->m_lower_bound.setConstant(-INFTY);
224 this->m_upper_bound.setConstant(+INFTY);
225 }
else if constexpr (InputTrait::IsDynamic) {
226 this->m_lower_bound.resize(n);
227 this->m_lower_bound.setConstant(-INFTY);
228 this->m_upper_bound.resize(n);
229 this->m_upper_bound.setConstant(+INFTY);
230 }
else if constexpr (InputTrait::IsSparse) {
231 this->m_lower_bound.resize(n);
232 this->m_lower_bound.reserve(n);
233 this->m_upper_bound.resize(n);
234 this->m_upper_bound.reserve(n);
235 std::vector<Eigen::Triplet<Scalar>> triplets;
237 for (
Integer i{0}; i < n; ++i) {
238 triplets.emplace_back(i, 0, -INFTY);
240 this->m_lower_bound.setFromTriplets(triplets.begin(), triplets.end());
243 for (
Integer i{0}; i < n; ++i) {
244 triplets.emplace_back(i, 0, +INFTY);
246 this->m_upper_bound.setFromTriplets(triplets.begin(), triplets.end());
259 return this->m_lower_bound;
267#define CMD "Optimist::Solver::bounds(...): "
269 if constexpr (InputTrait::IsEigen) {
270 OPTIMIST_ASSERT((this->m_upper_bound - t_lower_bound).minCoeff() <= 0.0,
271 CMD "invalid or degenarate bounds detected.");
274 CMD "invalid or degenarate bounds detected.");
276 this->m_lower_bound = t_lower_bound;
286 return this->m_upper_bound;
294#define CMD "Optimist::Solver::bounds(...): "
296 if constexpr (InputTrait::IsEigen) {
297 OPTIMIST_ASSERT((t_upper_bound - this->m_lower_bound).minCoeff() <= 0.0,
298 CMD "invalid or degenarate bounds detected.");
301 CMD "invalid or degenarate bounds detected.");
303 this->m_upper_bound = t_upper_bound;
313 void bounds(
const Input &t_lower_bound,
const Input &t_upper_bound) {
314#define CMD "Optimist::Solver::bounds(...): "
316 if constexpr (InputTrait::IsEigen) {
318 CMD "invalid or degenarate bounds detected.");
321 CMD "invalid or degenarate bounds detected.");
323 this->m_lower_bound = t_lower_bound;
324 this->m_upper_bound = t_upper_bound;
334 return InputTrait::Dimension;
342 return OutputTrait::Dimension;
350 return this->m_function_evaluations;
360 t_max_function_evaluations > 0,
361 "Optimist::Solver::max_function_evaluations(...): invalid "
363 this->m_max_function_evaluations = t_max_function_evaluations;
371 return this->m_max_function_evaluations;
380 return this->m_first_derivative_evaluations;
388 return this->m_max_first_derivative_evaluations;
397 const Integer t_first_derivative_evaluations) {
399 t_first_derivative_evaluations > 0,
400 "Optimist::Solver::max_first_derivative_evaluations(...): "
401 "invalid input detected.");
402 this->m_max_first_derivative_evaluations = t_first_derivative_evaluations;
410 return this->m_second_derivative_evaluations;
418 return this->m_max_second_derivative_evaluations;
427 const Integer t_second_derivative_evaluations) {
429 t_second_derivative_evaluations > 0,
430 "Optimist::Solver::max_second_derivative_evaluations(...): "
431 "invalid input detected.");
432 this->m_max_second_derivative_evaluations =
433 t_second_derivative_evaluations;
441 return this->m_iterations;
458 t_max_iterations > 0,
459 "Optimist::Solver::max_iterations(...): invalid input detected.");
460 this->m_max_iterations = t_max_iterations;
468 return this->m_alpha;
477 0.0 <= t_alpha && t_alpha <= 1.0,
478 "Optimist::Solver::alpha(...): invalid input detected.");
479 this->m_alpha = t_alpha;
487 return this->m_relaxations;
504 t_max_relaxations > 0,
505 "Optimist::Solver::max_relaxations(...): invalid input detected.");
506 this->m_max_relaxations = t_max_relaxations;
514 return this->m_tolerance;
525 !std::isnan(t_tolerance) && std::isfinite(t_tolerance) &&
527 "Optimist::Solver::tolerance(...): invalid input detected.");
528 this->m_tolerance = t_tolerance;
536 this->m_verbose = t_verbose;
544 return this->m_verbose;
551 this->m_verbose =
true;
558 this->m_verbose =
false;
566 this->m_damped = t_damped;
574 return this->m_damped;
581 this->m_damped =
true;
588 this->m_damped =
false;
603 void task(std::string t_task) {
604 this->m_task = t_task;
612 return this->m_converged;
620 return *this->m_ostream;
628 this->m_ostream = &t_ostream;
640 template <
typename FunctionLambda>
641 bool solve(FunctionLambda &&function,
const Input &x_ini, Input &x_sol) {
642#define CMD "Optimist::Solver::solve(...): "
644 static_assert(DerivedSolver::RequiresFunction,
645 CMD "the solver requires a function.");
646 return static_cast<DerivedSolver *
>(
this)->solve_impl(
647 std::forward<FunctionLambda>(function),
667 template <
typename FunctionLambda,
typename FirstDerivativeLambda>
668 bool solve(FunctionLambda &&function,
669 FirstDerivativeLambda &&first_derivative,
672#define CMD "Optimist::Solver::solve(...): "
674 static_assert(DerivedSolver::RequiresFunction,
675 CMD "the solver requires a function.");
676 static_assert(DerivedSolver::RequiresFirstDerivative,
677 CMD "the solver requires the first derivative.");
678 return static_cast<DerivedSolver *
>(
this)->solve_impl(
679 std::forward<FunctionLambda>(function),
680 std::forward<FirstDerivativeLambda>(first_derivative),
701 template <
typename FunctionLambda,
702 typename FirstDerivativeLambda,
703 typename SecondDerivativeLambda>
704 bool solve(FunctionLambda &&function,
705 FirstDerivativeLambda &&first_derivative,
706 SecondDerivativeLambda &&second_derivative,
709#define CMD "Optimist::Solver::solve(...): "
711 static_assert(DerivedSolver::RequiresFunction,
712 CMD "the solver requires the function.");
713 static_assert(DerivedSolver::RequiresFirstDerivative,
714 CMD "the solver requires the first derivative.");
715 static_assert(DerivedSolver::RequiresSecondDerivative,
716 CMD "the solver requires the second derivative.");
717 return static_cast<DerivedSolver *
>(
this)->solve_impl(
718 std::forward<FunctionLambda>(function),
719 std::forward<FirstDerivativeLambda>(first_derivative),
720 std::forward<SecondDerivativeLambda>(second_derivative),
736 template <
typename FunctionInput,
737 typename FunctionOutput,
738 typename DerivedFunction>
745#define CMD "Optimist::Solver::rootfind(...): "
750 static_assert(InputTrait::Dimension == FunctionInputTrait::Dimension,
752 "solver input dimension must be equal to the function "
754 static_assert(OutputTrait::Dimension == FunctionOutputTrait::Dimension ||
755 OutputTrait::Dimension == 1,
757 "solver output dimension must be equal to the function "
758 "output dimension or 1.");
760 !(InputTrait::IsScalar && DerivedSolver::IsOptimizer),
762 "one-dimensional optimizers do not support root-finding problems.");
767 (OutputTrait::Dimension != FunctionOutputTrait::Dimension) ||
768 (InputTrait::IsEigen && FunctionOutputTrait::IsScalar));
781 template <
typename FunctionInput,
782 typename FunctionOutput,
783 typename DerivedFunction>
789#define CMD "Optimist::Solver::optimize(...): "
793 static_assert(InputTrait::Dimension == FunctionInputTrait::Dimension,
795 "solver input dimension must be equal to the function "
797 static_assert(OutputTrait::Dimension == 1,
799 "solver output dimension must be equal to the function "
800 "output dimension or 1.");
805 return this->
solve(function, x_ini, x_sol,
true);
814 constexpr std::string
name()
const {
815 return static_cast<const DerivedSolver *
>(
this)->name_impl();
829 template <
typename FunctionInput,
830 typename FunctionOutput,
831 typename DerivedFunction>
838 bool is_optimization) {
839#define CMD "Optimist::Solver::solve(...): "
846 static_assert(InputTrait::Dimension == FunctionInputTrait::Dimension,
848 "solver input dimension must be equal to the function "
850 static_assert(OutputTrait::Dimension == FunctionOutputTrait::Dimension ||
851 OutputTrait::Dimension == 1,
853 "solver output dimension must be equal to the function "
854 "output dimension or a scalar.");
857 auto function_lambda = [&function, is_optimization](
const Input &x,
858 Output &out) ->
bool {
864 CMD "function evaluation failed during function computation.");
866 if (is_optimization) {
867 if constexpr (FunctionOutputTrait::Dimension == 1) {
869 }
else if constexpr (OutputTrait::Dimension !=
870 FunctionOutputTrait::Dimension) {
871 out = 0.5 * f.squaredNorm();
875 "optimization problem with inconsistent output in function.");
878 if constexpr (OutputTrait::Dimension ==
879 FunctionOutputTrait::Dimension) {
884 "root-finding problem with inconsistent output in function.");
890 auto first_derivative_lambda = [&function, is_optimization,
this](
894 typename FunctionType::FirstDerivative J;
898 "first derivative evaluation failed during "
899 "first derivative computation.");
901 if (is_optimization) {
907 "function evaluation failed during first derivative "
909 this->m_function_evaluations++;
910 if constexpr (FunctionInputTrait::IsScalar &&
911 FunctionOutputTrait::IsScalar) {
913 }
else if constexpr (OutputTrait::Dimension !=
914 FunctionOutputTrait::Dimension) {
915 out = J.transpose() * f;
918 "optimization problem inconsistent output in first "
922 if constexpr (OutputTrait::Dimension ==
923 FunctionOutputTrait::Dimension) {
927 "root-finding problem with inconsistent output in "
928 "first derivative.");
934 auto second_derivative_lambda = [&function, is_optimization,
this](
938 typename FunctionType::SecondDerivative H;
943 "function evaluation failed during second derivative computation.");
945 if (is_optimization) {
948 this->m_function_evaluations++;
951 "function evaluation failed during second derivative "
953 typename FunctionType::FirstDerivative J;
955 this->m_first_derivative_evaluations++;
958 "first derivative evaluation failed "
959 "during second derivative computation.");
960 if constexpr (FunctionInputTrait::IsScalar &&
961 FunctionOutputTrait::IsScalar) {
963 }
else if constexpr (OutputTrait::Dimension !=
964 FunctionOutputTrait::Dimension) {
965 out = J.transpose() * J;
966 for (
Integer i{0}; i < static_cast<Integer>(H.size()); ++i) {
971 "optimization problem with inconsistent output in "
972 "second derivative.");
975 if constexpr (OutputTrait::Dimension ==
976 FunctionOutputTrait::Dimension) {
980 "root-finding problem with inconsistent output in "
981 "second derivative.");
988 if constexpr (DerivedSolver::RequiresFunction &&
989 !DerivedSolver::RequiresFirstDerivative &&
990 !DerivedSolver::RequiresSecondDerivative) {
991 return static_cast<DerivedSolver *
>(
this)->solve_impl(function_lambda,
994 }
else if constexpr (DerivedSolver::RequiresFunction &&
995 DerivedSolver::RequiresFirstDerivative &&
996 !DerivedSolver::RequiresSecondDerivative) {
997 return static_cast<DerivedSolver *
>(
this)->solve_impl(
999 first_derivative_lambda,
1002 }
else if constexpr (DerivedSolver::RequiresFunction &&
1003 DerivedSolver::RequiresFirstDerivative &&
1004 DerivedSolver::RequiresSecondDerivative) {
1005 return static_cast<DerivedSolver *
>(
this)->solve_impl(
1007 first_derivative_lambda,
1008 second_derivative_lambda,
1013 "no matching function signature found for the solver.");
1023 this->m_function_evaluations = 0;
1024 this->m_first_derivative_evaluations = 0;
1025 this->m_second_derivative_evaluations = 0;
1026 this->m_iterations = 0;
1027 this->m_relaxations = 0;
1028 this->m_converged =
false;
1039 template <
typename FunctionLambda>
1045 "Optimist::" << this->
name()
1046 <<
"::evaluate_function(...): maximum allowed "
1047 "function evaluations reached.");
1048 ++this->m_function_evaluations;
1049 return function(x, out);
1060 template <
typename FirstDerivativeLambda>
1065 this->m_first_derivative_evaluations <
1066 this->m_max_first_derivative_evaluations,
1067 "Optimist::" << this->
name()
1068 <<
"::evaluate_first_derivative(...): maximum allowed "
1069 "first derivative evaluations reached.");
1070 ++this->m_first_derivative_evaluations;
1071 return function(x, out);
1081 template <
typename SecondDerivativeLambda>
1086 this->m_second_derivative_evaluations <
1087 this->m_max_second_derivative_evaluations,
1088 "Optimist::" << this->
name()
1089 <<
"::evaluate_second_derivative(...): maximum allowed "
1090 "second derivative evaluations reached.");
1091 ++this->m_second_derivative_evaluations;
1092 return function(x, out);
1108 template <
typename FunctionLambda>
1109 bool damp(FunctionLambda &&function,
1111 const Input &function_old,
1112 const Input &step_old,
1114 Input &function_new,
1116#define CMD "Optimist::Solver::damp(...): "
1118 Scalar step_norm_old, step_norm_new, residuals_old, residuals_new,
1120 for (this->m_relaxations = 0;
1121 this->m_relaxations < this->m_max_relaxations;
1122 ++this->m_relaxations) {
1124 step_new = tau * step_old;
1125 x_new = x_old + step_new;
1131 CMD "function evaluation failed during damping.");
1134 if constexpr (InputTrait::IsEigen) {
1135 step_norm_old = step_old.norm();
1136 step_norm_new = step_new.norm();
1138 step_norm_old = std::abs(step_old);
1139 step_norm_new = std::abs(step_new);
1143 if constexpr (OutputTrait::IsEigen) {
1144 residuals_old = function_old.norm();
1145 residuals_new = function_new.norm();
1147 residuals_old = std::abs(function_old);
1148 residuals_new = std::abs(function_new);
1152 if (residuals_new < residuals_old ||
1153 step_norm_new < (
Scalar(1.0) - tau /
Scalar(2.0)) * step_norm_old) {
1156 tau *= this->m_alpha;
1183 *this->m_ostream << c_tl << h_78 << c_tr << std::endl
1184 << v_ll <<
"Solver:" << std::setw(69) << this->
name()
1185 << v_rr << std::endl
1186 << v_ll <<
"Task: " << std::setw(69) << this->
task()
1187 << v_rr << std::endl
1188 << j_ll << h_7 << j_tt << h_7 << j_tt << h_7 << j_tt
1189 << h_7 << j_tt << h_7 << j_tt << h_14 << j_tt << h_23
1190 << j_rr << std::endl
1191 << v_ll <<
"#Iter" << v_lc <<
" #f" << v_lc <<
" #Df"
1192 << v_lc <<
" #DDf" << v_lc <<
" #Rlx" << v_lc
1193 <<
" ║f(x)║₂ " << v_lc <<
"Additional notes"
1194 << std::setw(9) << v_rr << std::endl
1195 << j_ll << h_7 << j_cc << h_7 << j_cc << h_7 << j_cc
1196 << h_7 << j_cc << h_7 << j_cc << h_14 << j_cc << h_23
1197 << j_rr << std::endl;
1217 *this->m_ostream << j_ll << h_7 << j_bb << h_7 << j_bb << h_7 << j_bb
1218 << h_7 << j_bb << h_7 << j_bb << h_14 << j_bb << h_23
1219 << j_rr << std::endl
1220 << v_ll << std::setw(40)
1221 << (this->m_converged ?
"CONVERGED" :
"NOT CONVERGED")
1222 << std::setw(40) << v_rr << std::endl
1223 << c_bl << h_78 << c_br << std::endl;
1235 *this->m_ostream << v_ll << std::setw(5) << this->m_iterations << v_lc
1236 << std::setw(5) << this->m_function_evaluations << v_lc
1237 << std::setw(5) << this->m_first_derivative_evaluations
1238 << v_lc << std::setw(5)
1239 << this->m_second_derivative_evaluations << v_lc
1240 << std::setw(5) << this->m_relaxations << v_lc
1241 << std::setw(12) << std::scientific
1242 << std::setprecision(6) << residuals << v_lc << notes
1243 << std::setw(25 - notes.length()) << v_rr << std::endl;
#define OPTIMIST_ERROR(MSG)
Definition Optimist.hh:37
#define OPTIMIST_BASIC_CONSTANTS(Scalar)
Definition Optimist.hh:69
#define OPTIMIST_ASSERT(COND, MSG)
Definition Optimist.hh:47
Class container for the generic function.
Definition Function.hh:48
bool second_derivative(const Input &x, SecondDerivative &out) const
Definition Function.hh:123
bool evaluate(const Input &x, Output &out) const
Definition Function.hh:101
bool first_derivative(const Input &x, FirstDerivative &out) const
Definition Function.hh:111
void max_second_derivative_evaluations(const Integer t_second_derivative_evaluations)
Definition SolverBase.hh:426
Integer first_derivative_evaluations() const
Definition SolverBase.hh:379
void max_iterations(const Integer t_max_iterations)
Definition SolverBase.hh:456
void disable_damped_mode()
Definition SolverBase.hh:587
bool damp(FunctionLambda &&function, const Input &x_old, const Input &function_old, const Input &step_old, Input &x_new, Input &function_new, Input &step_new)
Definition SolverBase.hh:1109
void damped_mode(bool t_damped)
Definition SolverBase.hh:565
void info(Scalar residuals, const std::string ¬es="-")
Definition SolverBase.hh:1230
bool solve(const FunctionBase< FunctionInput, FunctionOutput, DerivedFunction > &function, const Input &x_ini, Input &x_sol, bool is_optimization)
Definition SolverBase.hh:833
Integer m_function_evaluations
Definition SolverBase.hh:105
void alpha(Scalar t_alpha)
Definition SolverBase.hh:475
void reset_bounds(const Integer n=InputTrait::IsDynamic ? 0 :InputTrait::Dimension)
Definition SolverBase.hh:214
void lower_bound(const Input &t_lower_bound)
Definition SolverBase.hh:266
void upper_bound(const Input &t_upper_bound)
Definition SolverBase.hh:293
void max_relaxations(const Integer t_max_relaxations)
Definition SolverBase.hh:502
SolverBase(FunctionLambda &&function, FirstDerivativeLambda &&first_derivative, SecondDerivativeLambda &&second_derivative, const Input &x_ini, Input &x_sol)
Definition SolverBase.hh:196
void max_function_evaluations(const Integer t_max_function_evaluations)
Definition SolverBase.hh:358
Scalar alpha() const
Definition SolverBase.hh:467
constexpr Integer input_dimension() const
Definition SolverBase.hh:333
std::conditional_t< InputTrait::IsEigen||OutputTrait::IsEigen, std::conditional_t< InputTrait::IsSparse||OutputTrait::IsSparse, Eigen::SparseMatrix< Scalar >, Eigen::Matrix< Scalar, OutputTrait::Dimension, InputTrait::Dimension > >, Scalar > FirstDerivative
Definition SolverBase.hh:80
bool evaluate_function(FunctionLambda &&function, const Input &x, Output &out)
Definition SolverBase.hh:1040
bool evaluate_first_derivative(FirstDerivativeLambda &&function, const Input &x, FirstDerivative &out)
Definition SolverBase.hh:1061
void enable_verbose_mode()
Definition SolverBase.hh:550
Integer function_evaluations() const
Definition SolverBase.hh:349
constexpr Integer output_dimension() const
Definition SolverBase.hh:341
bool m_damped
Definition SolverBase.hh:131
void ostream(std::ostream &t_ostream)
Definition SolverBase.hh:627
Integer relaxations() const
Definition SolverBase.hh:486
bool converged() const
Definition SolverBase.hh:611
void task(std::string t_task)
Definition SolverBase.hh:603
void tolerance(Scalar t_tolerance)
Definition SolverBase.hh:523
const Input & upper_bound() const
Definition SolverBase.hh:285
std::ostream * m_ostream
Definition SolverBase.hh:132
bool evaluate_second_derivative(SecondDerivativeLambda &&function, const Input &x, SecondDerivative &out)
Definition SolverBase.hh:1082
std::ostream & ostream() const
Definition SolverBase.hh:619
Integer m_max_iterations
Definition SolverBase.hh:121
Integer max_iterations() const
Definition SolverBase.hh:448
bool optimize(const FunctionBase< FunctionInput, FunctionOutput, DerivedFunction > &function, const Input &x_ini, Input &x_sol)
Definition SolverBase.hh:784
Scalar m_tolerance
Definition SolverBase.hh:128
bool solve(FunctionLambda &&function, const Input &x_ini, Input &x_sol)
Definition SolverBase.hh:641
Integer m_max_function_evaluations
Definition SolverBase.hh:112
typename InputTrait::Scalar Scalar
Definition SolverBase.hh:57
Integer max_first_derivative_evaluations() const
Definition SolverBase.hh:387
constexpr std::string name() const
Definition SolverBase.hh:814
Scalar tolerance() const
Definition SolverBase.hh:513
const Input & lower_bound() const
Definition SolverBase.hh:258
void header()
Definition SolverBase.hh:1168
Integer max_function_evaluations() const
Definition SolverBase.hh:370
Integer second_derivative_evaluations() const
Definition SolverBase.hh:409
bool rootfind(const FunctionBase< FunctionInput, FunctionOutput, DerivedFunction > &function, const Input &x_ini, Input &x_sol)
Definition SolverBase.hh:740
void disable_verbose_mode()
Definition SolverBase.hh:557
Input m_lower_bound
Definition SolverBase.hh:101
Integer max_second_derivative_evaluations() const
Definition SolverBase.hh:417
TypeTrait< Input > InputTrait
Definition SolverBase.hh:55
std::conditional_t< InputTrait::IsEigen||OutputTrait::IsEigen, std::conditional_t< InputTrait::IsSparse||OutputTrait::IsSparse, std::vector< Eigen::SparseMatrix< Scalar > >, std::vector< Eigen::Matrix< Scalar, OutputTrait::Dimension, InputTrait::Dimension > > >, Scalar > SecondDerivative
Definition SolverBase.hh:88
Integer m_max_second_derivative_evaluations
Definition SolverBase.hh:116
bool damped_mode() const
Definition SolverBase.hh:573
std::string m_task
Definition SolverBase.hh:135
void reset_counters()
Definition SolverBase.hh:1022
void bounds(const Input &t_lower_bound, const Input &t_upper_bound)
Definition SolverBase.hh:313
void enable_damped_mode()
Definition SolverBase.hh:580
bool solve(FunctionLambda &&function, FirstDerivativeLambda &&first_derivative, SecondDerivativeLambda &&second_derivative, const Input &x_ini, Input &x_sol)
Definition SolverBase.hh:704
Integer m_iterations
Definition SolverBase.hh:120
bool solve(FunctionLambda &&function, FirstDerivativeLambda &&first_derivative, const Input &x_ini, Input &x_sol)
Definition SolverBase.hh:668
Integer m_max_relaxations
Definition SolverBase.hh:124
Integer max_relaxations() const
Definition SolverBase.hh:494
TypeTrait< Output > OutputTrait
Definition SolverBase.hh:56
Integer iterations() const
Definition SolverBase.hh:440
std::string task() const
Definition SolverBase.hh:595
SolverBase(FunctionLambda &&function, FirstDerivativeLambda &&first_derivative, const Input &x_ini, Input &x_sol)
Definition SolverBase.hh:170
void max_first_derivative_evaluations(const Integer t_first_derivative_evaluations)
Definition SolverBase.hh:396
Input m_upper_bound
Definition SolverBase.hh:102
Integer m_relaxations
Definition SolverBase.hh:123
SolverBase()
Definition SolverBase.hh:142
SolverBase(FunctionLambda &&function, const Input &x_ini, Input &x_sol)
Definition SolverBase.hh:152
Integer m_second_derivative_evaluations
Definition SolverBase.hh:108
Integer m_max_first_derivative_evaluations
Definition SolverBase.hh:114
Integer m_first_derivative_evaluations
Definition SolverBase.hh:106
bool verbose_mode() const
Definition SolverBase.hh:543
void verbose_mode(bool t_verbose)
Definition SolverBase.hh:535
Scalar m_alpha
Definition SolverBase.hh:122
bool m_verbose
Definition SolverBase.hh:130
bool m_converged
Definition SolverBase.hh:136
void bottom()
Definition SolverBase.hh:1204
Namespace for the Optimist library.
Definition Optimist.hh:89
static constexpr std::string table_top_right_corner()
Retrieve the Unicode character for the top-right corner of a table.
Definition Optimist.hh:258
static constexpr std::string table_top_junction()
Retrieve the Unicode character for the top junction of a table.
Definition Optimist.hh:300
static constexpr std::string table_center_cross()
Retrieve the Unicode character for the center cross of a table.
Definition Optimist.hh:316
static constexpr std::string table_top_left_corner()
Retrieve the Unicode character for the top-left corner of a table.
Definition Optimist.hh:250
static constexpr std::string table_vertical_line()
Retrieve the Unicode character for the vertical line of a table.
Definition Optimist.hh:347
static constexpr std::string table_bottom_junction()
Retrieve the Unicode character for the bottom junction of a table.
Definition Optimist.hh:308
OPTIMIST_DEFAULT_INTEGER_TYPE Integer
The Integer type as used for the API.
Definition Optimist.hh:97
static constexpr std::string table_left_junction()
Retrieve the Unicode character for the left junction of a table.
Definition Optimist.hh:284
static constexpr std::string table_bottom_right_corner()
Retrieve the Unicode character for the bottom-right corner of a table.
Definition Optimist.hh:276
static constexpr std::string table_right_junction()
Retrieve the Unicode character for the right junction of a table.
Definition Optimist.hh:292
static constexpr std::string table_bottom_left_corner()
Retrieve the Unicode character for the bottom-left corner of a table.
Definition Optimist.hh:267
static constexpr std::string table_horizontal_line()
Retrieve the Unicode character for the horizontal line of a table.
Definition Optimist.hh:324
Definition Optimist.hh:113