Optimist
0.0.0
A C++ library for optimization
Toggle main menu visibility
Loading...
Searching...
No Matches
Brown.hh
Go to the documentation of this file.
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2
* Copyright (c) 2025, Davide Stocco and Enrico Bertolazzi. *
3
* *
4
* The Optimist project is distributed under the BSD 2-Clause License. *
5
* *
6
* Davide Stocco Enrico Bertolazzi *
7
* University of Trento University of Trento *
8
* davide.stocco@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/DenseFunction.hh
"
17
18
namespace
Optimist
{
19
20
namespace
TestSet {
21
41
template
<
typename
Input,
typename
Output>
42
class
Brown
:
public
DenseSystemFunction
<Input,
43
2,
44
Brown<Input, Output>,
45
Output,
46
3> {
47
public
:
48
using
Base
=
49
DenseSystemFunction<Input, 2, Brown<Input, Output>
, Output, 3>;
50
using
typename
Base::Dense
;
51
using
typename
Base::DenseMatrix
;
52
using
typename
Base::Scalar
;
53
using
InputTrait
=
TypeTrait<Input>
;
54
using
OutputTrait
=
TypeTrait<Output>
;
55
59
Brown
() {
60
this->
add_solution
(this->
make
({1.0e6, 2.0e-6}));
61
this->
add_guess
(this->
make
({1.0, 1.0}));
62
}
63
68
constexpr
std::string
name_impl
()
const
{
69
return
"Brown"
;
70
}
71
72
void
residual
(
const
Dense
&x,
Dense
&F)
const
{
73
F(0) = x(0) -
Scalar
(1.0e6);
74
F(1) = x(1) -
Scalar
(2.0e-6);
75
F(2) = x(0) * x(1) - 2;
76
}
77
78
void
jacobian
(
const
Dense
&x,
DenseMatrix
&J)
const
{
79
J << 1, 0, 0, 1, x(1), x(0);
80
}
81
82
void
hessian
([[maybe_unused]]
const
Dense
&x,
const
Integer
i,
DenseMatrix
&H)
const
{
83
H.setZero();
84
if
(i == 2) {
85
H(0, 1) = 1;
86
H(1, 0) = 1;
87
}
88
}
89
90
};
// class Brown
91
92
}
// namespace TestSet
93
94
}
// namespace Optimist
95
96
#endif
// OPTIMIST_TESTSET_BROWN_HH
DenseFunction.hh
Optimist::TestSet::Brown::OutputTrait
TypeTrait< Output > OutputTrait
Definition
Brown.hh:54
Optimist::TestSet::Brown::DenseMatrix
Utils::DenseMatrix< Input > DenseMatrix
Definition
DenseFunction.hh:156
Optimist::TestSet::Brown::Brown
Brown()
Definition
Brown.hh:59
Optimist::TestSet::Brown::residual
void residual(const Dense &x, Dense &F) const
Definition
Brown.hh:72
Optimist::TestSet::Brown::Scalar
typename Input::Scalar Scalar
Definition
DenseFunction.hh:154
Optimist::TestSet::Brown::Dense
Utils::DenseVector< Input > Dense
Definition
DenseFunction.hh:155
Optimist::TestSet::Brown::jacobian
void jacobian(const Dense &x, DenseMatrix &J) const
Definition
Brown.hh:78
Optimist::TestSet::Brown::hessian
void hessian(const Dense &x, const Integer i, DenseMatrix &H) const
Definition
Brown.hh:82
Optimist::TestSet::Brown::name_impl
constexpr std::string name_impl() const
Definition
Brown.hh:68
Optimist::TestSet::Brown::Base
DenseSystemFunction< Input, 2, Brown< Input, Output >, Output, 3 > Base
Definition
Brown.hh:48
Optimist::TestSet::Brown::InputTrait
TypeTrait< Input > InputTrait
Definition
Brown.hh:53
Optimist::TestSet::DenseSystemFunction
Helper base class for nonlinear systems written once in terms of dense vectors (square by default).
Definition
DenseFunction.hh:151
Optimist::TestSet::DenseSystemFunction< Input, 2, Brown< Input, Output >, Output, 3 >::add_guess
void add_guess(const Dense &x)
Definition
DenseFunction.hh:225
Optimist::TestSet::DenseSystemFunction< Input, 2, Brown< Input, Output >, Output, 3 >::DenseMatrix
Utils::DenseMatrix< Input > DenseMatrix
Definition
DenseFunction.hh:156
Optimist::TestSet::DenseSystemFunction< Input, 2, Brown< Input, Output >, Output, 3 >::Scalar
typename Input::Scalar Scalar
Definition
DenseFunction.hh:154
Optimist::TestSet::DenseSystemFunction< Input, 2, Brown< Input, Output >, Output, 3 >::Dense
Utils::DenseVector< Input > Dense
Definition
DenseFunction.hh:155
Optimist::TestSet::DenseSystemFunction< Input, 2, Brown< Input, Output >, Output, 3 >::add_solution
void add_solution(const Dense &x)
Definition
DenseFunction.hh:218
Optimist::TestSet::DenseSystemFunction< Input, 2, Brown< Input, Output >, Output, 3 >::make
static Dense make(std::initializer_list< Scalar > values)
Definition
DenseFunction.hh:232
Optimist
Namespace for the Optimist library.
Definition
Optimist.hh:90
Optimist::Integer
OPTIMIST_DEFAULT_INTEGER_TYPE Integer
The Integer type as used for the API.
Definition
Optimist.hh:98
Optimist::TypeTrait
Definition
Optimist.hh:105
core
include
Optimist
TestSet
Brown.hh
Generated by
1.18.0