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