Shark machine learning library
Installation
Tutorials
Benchmarks
Documentation
Quick references
Class list
Global functions
include
shark
ObjectiveFunctions
Benchmarks
IHR6.h
Go to the documentation of this file.
1
//===========================================================================
2
/*!
3
*
4
*
5
* \brief Multi-objective optimization benchmark function IHR 6.
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_IHR6_H
41
#define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_IHR6_H
42
43
#include <
shark/ObjectiveFunctions/AbstractObjectiveFunction.h
>
44
#include <
shark/ObjectiveFunctions/BoxConstraintHandler.h
>
45
46
#include <
shark/LinAlg/rotations.h
>
47
48
#include <vector>
49
50
namespace
shark
{
namespace
benchmarks{
51
/*! \brief Multi-objective optimization benchmark function IHR 6.
52
*
53
* The function is described in
54
*
55
* Christian Igel, Nikolaus Hansen, and Stefan Roth.
56
* Covariance Matrix Adaptation for Multi-objective Optimization.
57
* Evolutionary Computation 15(1), pp. 1-28, 2007
58
* \ingroup benchmarks
59
*/
60
struct
IHR6
:
public
MultiObjectiveFunction
{
61
62
IHR6
(std::size_t numVariables = 0)
63
: m_handler(numVariables,-1,1 ){
64
announceConstraintHandler
(&m_handler);
65
}
66
67
/// \brief From INameable: return the class name.
68
std::string
name
()
const
69
{
return
"IHR6"
; }
70
71
std::size_t
numberOfObjectives
()
const
{
72
return
2;
73
}
74
75
std::size_t
numberOfVariables
()
const
{
76
return
m_handler.
dimensions
();
77
}
78
79
bool
hasScalableDimensionality
()
const
{
80
return
true
;
81
}
82
83
void
setNumberOfVariables
( std::size_t
numberOfVariables
){
84
m_handler.
setBounds
(
85
SearchPointType
(
numberOfVariables
,-1),
86
SearchPointType
(
numberOfVariables
,1)
87
);
88
}
89
90
void
init
() {
91
m_rotationMatrix =
blas::randomRotationMatrix
(*
mep_rng
,
numberOfVariables
());
92
m_ymax = 1.0/norm_inf(row(m_rotationMatrix,0));
93
}
94
95
ResultType
eval
(
const
SearchPointType
& x )
const
{
96
m_evaluationCounter
++;
97
98
ResultType
value( 2 );
99
100
SearchPointType
y = prod(m_rotationMatrix,x);
101
102
value[0] = 1 - std::exp(-4 * std::abs(y(0))) * std::pow(std::sin(6 * M_PI * y(0)), 6);
103
104
double
g = 0;
105
for
(std::size_t i = 1; i <
numberOfVariables
(); i++)
106
g +=
hg
( y(i) );
107
g = 1 + 9 * std::pow(g / (
numberOfVariables
() - 1.0), 0.25);
108
109
value[1] = g *
hf
(1. -
sqr
( value[0] / g ), y( 0 ));
110
111
return
value;
112
}
113
114
double
h
(
double
x )
const
{
115
return
1 / ( 1 + std::exp( -x / std::sqrt(
double
(
numberOfVariables
()) ) ) );
116
}
117
118
double
hf
(
double
x,
double
y0)
const
{
119
if
( std::abs(y0) <= m_ymax )
120
return
x;
121
return
std::abs( y0 ) + 1.;
122
}
123
124
double
hg
(
double
x)
const
{
125
return
sqr
(x) / ( std::abs(x) + 0.1 );
126
}
127
private
:
128
double
m_ymax;
129
BoxConstraintHandler<SearchPointType>
m_handler;
130
RealMatrix m_rotationMatrix;
131
};
132
133
}}
134
#endif