Optimist  0.0.0
A C++ library for optimization
Loading...
Searching...
No Matches
Brown.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_BROWN_HH
14#define OPTIMIST_TESTSET_BROWN_HH
15
16#include "Optimist/TestSet.hh"
17
18namespace Optimist
19{
20
21 namespace TestSet
22 {
23
35 template <typename Real>
36 class Brown : public Function<Real, 2, 3, Brown<Real>>
37 {
38 private:
39 Real m_a{1.0e-6};
40
41 public:
43
44 using InputVector = typename Function<Real, 2, 3, Brown<Real>>::InputVector;
45 using OutputVector = typename Function<Real, 2, 3, Brown<Real>>::OutputVector;
46 using Matrix = typename Function<Real, 2, 3, Brown<Real>>::Matrix;
47 using Tensor = typename Function<Real, 2, 3, Brown<Real>>::Tensor;
48
53 {
54 this->m_solutions.emplace_back(this->m_a, 2.0*this->m_a);
55 this->m_guesses.emplace_back(1.0, 1.0);
56 }
57
62 std::string name_impl() const {return "Brown";}
63
69 void evaluate_impl(const InputVector & x, OutputVector & out) const
70 {
71 out << x(0) - this->m_a,
72 x(1) - 2.0*this->m_a,
73 x(0)*x(1) - 2.0;
74 }
75
80 void first_derivative_impl(const InputVector & x, Matrix & out) const
81 {
82 out << 1.0, 0.0, x(1),
83 0.0, 1.0, x(0);
84 }
85
91 void second_derivative_impl(const InputVector & /*x*/, Tensor & out) const
92 {
93 out.resize(this->output_dimension());
94 out[0].setZero();
95 out[1].setZero();
96 out[2] << 0.0, 1.0,
97 1.0, 0.0;
98 }
99
100 }; // class Brown
101
102 } // namespace TestSet
103
104} // namespace Optimist
105
106#endif // OPTIMIST_TESTSET_BROWN_HH
#define OPTIMIST_BASIC_CONSTANTS(Real)
Definition Optimist.hh:70
std::vector< InputType > m_guesses
Definition Function.hh:63
std::vector< InputType > m_solutions
Definition Function.hh:62
constexpr Integer output_dimension() const
Definition Function.hh:117
typename Function< Real, 2, 3, Brown< Real > >::OutputVector OutputVector
Definition Brown.hh:45
void second_derivative_impl(const InputVector &, Tensor &out) const
Definition Brown.hh:91
void first_derivative_impl(const InputVector &x, Matrix &out) const
Definition Brown.hh:80
Real m_a
Definition Brown.hh:39
void evaluate_impl(const InputVector &x, OutputVector &out) const
Definition Brown.hh:69
std::string name_impl() const
Definition Brown.hh:62
typename Function< Real, 2, 3, Brown< Real > >::Matrix Matrix
Definition Brown.hh:46
Brown()
Definition Brown.hh:52
typename Function< Real, 2, 3, Brown< Real > >::InputVector InputVector
Definition Brown.hh:44
typename Function< Real, 2, 3, Brown< Real > >::Tensor Tensor
Definition Brown.hh:47
Namespace for the Optimist library.
Definition Optimist.hh:87