Shark machine learning library
Installation
Tutorials
Benchmarks
Documentation
Quick references
Class list
Global functions
include
shark
ObjectiveFunctions
Benchmarks
ZDT4.h
Go to the documentation of this file.
1
//===========================================================================
2
/*!
3
*
4
*
5
* \brief Multi-objective optimization benchmark function ZDT4
6
*
7
* The function is described in
8
*
9
* Eckart Zitzler, Kalyanmoy Deb, and Lothar Thiele. Comparison of
10
* Multiobjective Evolutionary Algorithms: Empirical
11
* Results. Evolutionary Computation 8(2):173-195, 2000
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
41
#ifndef SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_ZDT4_H
42
#define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_ZDT4_H
43
44
#include <
shark/ObjectiveFunctions/AbstractObjectiveFunction.h
>
45
#include <
shark/ObjectiveFunctions/BoxConstraintHandler.h
>
46
47
namespace
shark
{
namespace
benchmarks{
48
/*! \brief Multi-objective optimization benchmark function ZDT4
49
*
50
* The function is described in
51
* This function is highly multimodal
52
*
53
* Eckart Zitzler, Kalyanmoy Deb, and Lothar Thiele. Comparison of
54
* Multiobjective Evolutionary Algorithms: Empirical
55
* Results. Evolutionary Computation 8(2):173-195, 2000
56
* \ingroup benchmarks
57
*/
58
struct
ZDT4
:
public
MultiObjectiveFunction
59
{
60
61
ZDT4
(std::size_t numVariables = 1) {
62
announceConstraintHandler
(&m_handler);
63
setNumberOfVariables
(numVariables);
64
}
65
66
/// \brief From INameable: return the class name.
67
std::string
name
()
const
68
{
return
"ZDT4"
; }
69
70
std::size_t
numberOfObjectives
()
const
{
71
return
2;
72
}
73
74
std::size_t
numberOfVariables
()
const
{
75
return
m_handler.
dimensions
();
76
}
77
78
bool
hasScalableDimensionality
()
const
{
79
return
true
;
80
}
81
82
/// \brief Adjusts the number of variables if the function is scalable.
83
/// \param [in] numberOfVariables The new dimension.
84
void
setNumberOfVariables
( std::size_t
numberOfVariables
){
85
RealVector lower(
numberOfVariables
,-5);
86
RealVector upper(
numberOfVariables
,5);
87
lower(0) = 0;
88
upper(0) = 1;
89
m_handler.
setBounds
(lower,upper);
90
}
91
92
ResultType
eval
(
const
SearchPointType
& x )
const
{
93
m_evaluationCounter
++;
94
95
ResultType
value( 2 );
96
97
value[0] = x( 0 );
98
99
double
sum = 0.0;
100
for
(
unsigned
i = 1; i <
numberOfVariables
(); i++)
101
sum +=
sqr
(x( i )) - (10.0 * cos(4 * M_PI * x(i) ) );
102
103
double
g = 1.0 + (10.0 * (
numberOfVariables
() - 1.0)) + sum;
104
double
h = 1.0 - std::sqrt(x(0) / g);
105
106
value[1] = g * h;
107
108
return
value;
109
}
110
111
private
:
112
BoxConstraintHandler<SearchPointType>
m_handler;
113
};
114
115
}}
116
#endif