Optimist  0.0.0
A C++ library for optimization
Loading...
Searching...
No Matches
EllipticParaboloid.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#pragma once
12
13#ifndef OPTIMIST_TESTSET_ELLIPTICPARABOLOID_HH
14#define OPTIMIST_TESTSET_ELLIPTICPARABOLOID_HH
15
16#include "Optimist/TestSet.hh"
17
18namespace Optimist
19{
20
21 namespace TestSet
22 {
23
35 template <typename Real>
36 class EllipticParaboloid : public Function<Real, 2, 1, EllipticParaboloid<Real>>
37 {
38 Real m_a{1.0};
39 Real m_b{1.0};
40
41 public:
43
45 using typename Function<Real, 2, 1, EllipticParaboloid<Real>>::RowVector;
47
52 {
53 this->m_solutions.emplace_back(0.0, 0.0);
54 for (Real x{-100}; x < 100 + EPSILON; x += 100/25.0) {
55 for (Real y{-100}; y < 100 + EPSILON; y += 100/25.0) {
56 this->m_guesses.emplace_back(x, y);
57 }
58 }
59 }
60
65 std::string name_impl() const {return "EllipticParaboloid";}
66
72 bool evaluate_impl(Vector const & x, Real & out) const
73 {
74 out = this->m_a*x(0)*x(0) + this->m_b*x(1)*x(1);
75 return std::isfinite(out);
76 }
77
83 bool first_derivative_impl(Vector const & x, RowVector & out) const
84 {
85 out << 2.0*this->m_a*x(0), 2.0*this->m_b*x(1);
86 return out.allFinite();
87 }
88
94 bool second_derivative_impl(Vector const & /*x*/, Matrix & out) const
95 {
96 out << 2.0*this->m_a, 0.0,
97 0.0, 2.0*this->m_b;
98 return out.allFinite();
99 }
100
101 }; // class EllipticParaboloid
102
103 } // namespace TestSet
104
105} // namespace Optimist
106
107#endif // OPTIMIST_TESTSET_ELLIPTICPARABOLOID_HH
#define OPTIMIST_BASIC_CONSTANTS(Real)
Definition Optimist.hh:71
std::vector< InputType > m_guesses
Definition Function.hh:66
std::vector< InputType > m_solutions
Definition Function.hh:65
Class container for the vector-valued function.
Definition Function.hh:190
typename FunctionBase< Real, N, M, EllipticParaboloid< Real >, false >::FirstDerivativeType Matrix
Definition Function.hh:203
bool second_derivative_impl(Vector const &, Matrix &out) const
Definition EllipticParaboloid.hh:94
bool first_derivative_impl(Vector const &x, RowVector &out) const
Definition EllipticParaboloid.hh:83
bool evaluate_impl(Vector const &x, Real &out) const
Definition EllipticParaboloid.hh:72
Real m_b
Definition EllipticParaboloid.hh:39
std::string name_impl() const
Definition EllipticParaboloid.hh:65
Real m_a
Definition EllipticParaboloid.hh:38
EllipticParaboloid()
Definition EllipticParaboloid.hh:51
Namespace for the Optimist library.
Definition Optimist.hh:88