Shark machine learning library
Installation
Tutorials
Benchmarks
Documentation
Quick references
Class list
Global functions
include
shark
ObjectiveFunctions
Benchmarks
IHR3.h
Go to the documentation of this file.
1
//===========================================================================
2
/*!
3
*
4
*
5
* \brief Multi-objective optimization benchmark function IHR 3.
6
*
7
* The function is described in
8
*
9
* Christian Igel, Nikolaus Hansen, and Stefan Roth.
10
* Covariance Matrix Adaptation for Multi-objective Optimization.
11
* Evolutionary Computation 15(1), pp. 1-28, 2007
12
*
13
*
14
*
15
* \author -
16
* \date -
17
*
18
*
19
* \par Copyright 1995-2017 Shark Development Team
20
*
21
* <BR><HR>
22
* This file is part of Shark.
23
* <https://shark-ml.github.io/Shark/>
24
*
25
* Shark is free software: you can redistribute it and/or modify
26
* it under the terms of the GNU Lesser General Public License as published
27
* by the Free Software Foundation, either version 3 of the License, or
28
* (at your option) any later version.
29
*
30
* Shark is distributed in the hope that it will be useful,
31
* but WITHOUT ANY WARRANTY; without even the implied warranty of
32
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33
* GNU Lesser General Public License for more details.
34
*
35
* You should have received a copy of the GNU Lesser General Public License
36
* along with Shark. If not, see <http://www.gnu.org/licenses/>.
37
*
38
*/
39
//===========================================================================
40
#ifndef SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_IHR3_H
41
#define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_IHR3_H
42
43
#include <
shark/ObjectiveFunctions/AbstractObjectiveFunction.h
>
44
#include <
shark/ObjectiveFunctions/BoxConstraintHandler.h
>
45
46
#include <
shark/LinAlg/rotations.h
>
47
48
namespace
shark
{
namespace
benchmarks{
49
/*! \brief Multi-objective optimization benchmark function IHR3.
50
*
51
* The function is described in
52
*
53
* Christian Igel, Nikolaus Hansen, and Stefan Roth.
54
* Covariance Matrix Adaptation for Multi-objective Optimization.
55
* Evolutionary Computation 15(1), pp. 1-28, 2007
56
* \ingroup benchmarks
57
*/
58
struct
IHR3
:
public
MultiObjectiveFunction
{
59
IHR3
(std::size_t numVariables = 0)
60
: m_handler(numVariables,-1,1){
61
announceConstraintHandler
(&m_handler);
62
}
63
64
/// \brief From INameable: return the class name.
65
std::string
name
()
const
66
{
return
"IHR3"
; }
67
68
std::size_t
numberOfObjectives
()
const
{
69
return
2;
70
}
71
72
std::size_t
numberOfVariables
()
const
{
73
return
m_handler.
dimensions
();
74
}
75
76
bool
hasScalableDimensionality
()
const
{
77
return
true
;
78
}
79
80
void
setNumberOfVariables
( std::size_t
numberOfVariables
){
81
m_handler.
setBounds
(
82
SearchPointType
(
numberOfVariables
,-1),
83
SearchPointType
(
numberOfVariables
,1)
84
);
85
}
86
87
void
init
() {
88
m_rotationMatrix =
blas::randomRotationMatrix
(*
mep_rng
,
numberOfVariables
());
89
m_ymax = 1.0/norm_inf(row(m_rotationMatrix,0));
90
}
91
92
ResultType
eval
(
const
SearchPointType
& x )
const
{
93
m_evaluationCounter
++;
94
95
ResultType
value( 2 );
96
97
SearchPointType
y = prod(m_rotationMatrix,x);
98
99
value[0] = std::abs( y( 0 ) );
100
101
double
g = 0;
102
for
(
unsigned
i = 1; i <
numberOfVariables
(); i++)
103
g +=
hg
( y( i ) );
104
g = 1 + 9 * g / (
numberOfVariables
() - 1.);
105
double
quotient =
h
(y( 0 )) / g;
106
value[1] = g *
hf
(1. - std::sqrt(quotient) - quotient * std::sin(10 * M_PI * y( 0 ) ), y( 0 ));
107
108
return
value;
109
}
110
111
double
h
(
double
x )
const
{
112
return
1 / ( 1 + std::exp( -x / std::sqrt(
double
(
numberOfVariables
()) ) ) );
113
}
114
115
double
hf
(
double
x,
double
y0)
const
{
116
if
( std::abs(y0) <= m_ymax )
117
return
x;
118
return
std::abs( y0 ) + 1.;
119
}
120
121
double
hg
(
double
x)
const
{
122
return
sqr
(x) / ( std::abs(x) + 0.1 );
123
}
124
private
:
125
double
m_ymax;
126
BoxConstraintHandler<SearchPointType>
m_handler;
127
RealMatrix m_rotationMatrix;
128
};
129
130
}}
131
#endif