Shark machine learning library
About Shark
News!
Contribute
Credits and copyright
Downloads
Getting Started
Installation
Using the docs
Documentation
Tutorials
Quick references
Class list
Global functions
FAQ
Showroom
include
shark
ObjectiveFunctions
Benchmarks
ZDT2.h
Go to the documentation of this file.
1
//===========================================================================
2
/*!
3
*
4
*
5
* \brief Multi-objective optimization benchmark function ZDT2
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
* <http://shark-ml.org/>
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_ZDT2_H
42
#define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_ZDT2_H
43
44
#include <
shark/ObjectiveFunctions/AbstractObjectiveFunction.h
>
45
#include <
shark/ObjectiveFunctions/BoxConstraintHandler.h
>
46
47
namespace
shark
{
48
/*! \brief Multi-objective optimization benchmark function ZDT2
49
*
50
* The function is described in
51
*
52
* Eckart Zitzler, Kalyanmoy Deb, and Lothar Thiele. Comparison of
53
* Multiobjective Evolutionary Algorithms: Empirical
54
* Results. Evolutionary Computation 8(2):173-195, 2000
55
*/
56
struct
ZDT2
:
public
MultiObjectiveFunction
57
{
58
59
ZDT2
(std::size_t numVariables = 0) : m_handler(numVariables,0,1) {
60
announceConstraintHandler
(&m_handler);
61
}
62
63
/// \brief From INameable: return the class name.
64
std::string
name
()
const
65
{
return
"ZDT2"
; }
66
67
std::size_t
numberOfObjectives
()
const
{
68
return
2;
69
}
70
71
std::size_t
numberOfVariables
()
const
{
72
return
m_handler.
dimensions
();
73
}
74
75
bool
hasScalableDimensionality
()
const
{
76
return
true
;
77
}
78
79
/// \brief Adjusts the number of variables if the function is scalable.
80
/// \param [in] numberOfVariables The new dimension.
81
void
setNumberOfVariables
( std::size_t
numberOfVariables
){
82
m_handler.
setBounds
(numberOfVariables,0,1);
83
}
84
85
ResultType
eval
(
const
SearchPointType
& x )
const
{
86
m_evaluationCounter
++;
87
88
ResultType
value( 2 );
89
90
value[0] = x( 0 );
91
92
double
g = 1.0 + 9.0 *(sum(x)-x(0))/(
numberOfVariables
() - 1.0);
93
double
h
= 1.0 -
sqr
(x( 0 ) / g);
94
95
value[1] = g *
h
;
96
97
return
( value );
98
}
99
100
private
:
101
BoxConstraintHandler<SearchPointType>
m_handler;
102
};
103
104
}
105
#endif