Optimist  0.0.0
A C++ library for optimization
Loading...
Searching...
No Matches
Test11.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2 * Copyright (c) 2025, Davide Stocco, Mattia Piazza and Enrico Bertolazzi. *
3 * *
4 * The Optimist project is distributed under the BSD 2-Clause License. *
5 * *
6 * Davide Stocco Mattia Piazza Enrico Bertolazzi *
7 * University of Trento University of Trento University of Trento *
8 * davide.stocco@unitn.it mattia.piazza@unitn.it enrico.bertolazzi@unitn.it *
9\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
10
11#ifndef OPTIMIST_TESTSET_TEST11_HH
12#define OPTIMIST_TESTSET_TEST11_HH
13
14#include "Optimist/TestSet.hh"
15
16namespace Optimist
17{
18
19 namespace TestSet
20 {
21
33 template <typename Real>
34 class Test11 : public Function<Real, 1, 1, Test11<Real>, true>
35 {
36 public:
38
43
48 {
49 this->m_solutions.emplace_back(-10.0);
50 this->m_solutions.emplace_back(-5.0);
51 this->m_solutions.emplace_back(0.0);
52 this->m_solutions.emplace_back(5.0);
53 this->m_solutions.emplace_back(10.0);
54 }
55
60 std::string name_impl() const {return "Test11";}
61
68 bool evaluate_impl(InputVector const & x, OutputVector & out) const
69 {
70 out << x(0) * x(0);
71 return out.allFinite();
72 }
73
80 bool first_derivative_impl(InputVector const & x, Matrix & out) const
81 {
82 out << 2.0 * x(0);
83 return out.allFinite();
84 }
85
92 bool second_derivative_impl(InputVector const & /*x*/, Tensor & out) const
93 {
94 out << 2.0;
95 return out.allFinite();
96 }
97
98 }; // class Test11
99
100 } // namespace TestSet
101
102} // namespace Optimist
103
104#endif // OPTIMIST_TESTSET_TEST11_HH
#define OPTIMIST_BASIC_CONSTANTS(Real)
Definition Optimist.hh:71
std::vector< InputType > m_solutions
Definition Function.hh:65
typename FunctionBase< Real, N, M, Test11< Real >, ForceEigen >::OutputType OutputVector
Definition Function.hh:200
typename FunctionBase< Real, N, M, Test11< Real >, ForceEigen >::InputType InputVector
Definition Function.hh:199
typename FunctionBase< Real, N, M, Test11< Real >, ForceEigen >::FirstDerivativeType Matrix
Definition Function.hh:203
typename FunctionBase< Real, N, M, Test11< Real >, ForceEigen >::SecondDerivativeType Tensor
Definition Function.hh:204
std::string name_impl() const
Definition Test11.hh:60
bool evaluate_impl(InputVector const &x, OutputVector &out) const
Definition Test11.hh:68
Test11()
Definition Test11.hh:47
bool second_derivative_impl(InputVector const &, Tensor &out) const
Definition Test11.hh:92
bool first_derivative_impl(InputVector const &x, Matrix &out) const
Definition Test11.hh:80
Namespace for the Optimist library test set functions.
Definition TestSet.hh:34
Namespace for the Optimist library.
Definition Optimist.hh:88