DTLZ1.h
Go to the documentation of this file.
1//===========================================================================
2/*!
3 *
4 *
5 * \brief Objective function DTLZ1
6 *
7 *
8 *
9 * \author T.Voss, T. Glasmachers, O.Krause
10 * \date 2010-2011
11 *
12 *
13 * \par Copyright 1995-2017 Shark Development Team
14 *
15 * <BR><HR>
16 * This file is part of Shark.
17 * <https://shark-ml.github.io/Shark/>
18 *
19 * Shark is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU Lesser General Public License as published
21 * by the Free Software Foundation, either version 3 of the License, or
22 * (at your option) any later version.
23 *
24 * Shark is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU Lesser General Public License for more details.
28 *
29 * You should have received a copy of the GNU Lesser General Public License
30 * along with Shark. If not, see <http://www.gnu.org/licenses/>.
31 *
32 */
33//===========================================================================
34#ifndef SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_DTLZ1_H
35#define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_DTLZ1_H
36
39
40namespace shark {namespace benchmarks{
41
42/**
43* \brief Implements the benchmark function DTLZ1.
44*
45* See: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.18.7531&rep=rep1&type=pdf
46* The benchmark function exposes the following features:
47* - Scalable w.r.t. the searchspace and w.r.t. the objective space.
48* - Highly multi-modal.
49* \ingroup benchmarks
50*/
52{
53 DTLZ1(std::size_t numVariables = 0) : m_objectives(2), m_handler(numVariables,0,1 ){
54 announceConstraintHandler(&m_handler);
55 }
56
57 /// \brief From INameable: return the class name.
58 std::string name() const
59 { return "DTLZ1"; }
60
61 std::size_t numberOfObjectives()const{
62 return m_objectives;
63 }
65 return true;
66 }
67
69 m_objectives = numberOfObjectives;
70 }
71
72
73 std::size_t numberOfVariables()const{
74 return m_handler.dimensions();
75 }
76
78 return true;
79 }
80
87
88 ResultType eval( const SearchPointType & x ) const {
90
92
93 std::size_t k = numberOfVariables() - numberOfObjectives()+1;
94 double g = (double)k;
95 for( std::size_t i = numberOfVariables() - k; i < numberOfVariables(); i++ )
96 g += sqr( x( i ) - 0.5 ) - std::cos( 20.0 * M_PI * ( x( i ) - 0.5) );
97 g *= 100;
98
99 for (std::size_t i = 0; i < numberOfObjectives(); i++) {
100 value[i] = 0.5*(1.0 + g);
101 for( std::size_t j = 0; j < numberOfObjectives() - i -1; ++j)
102 value[i] *= x( j );
103
104 if (i > 0)
105 value[i] *= 1 - x( numberOfObjectives() - i -1);
106 }
107
108 return value;
109 }
110private:
111 std::size_t m_objectives;
113
114};
115
116}}
117
118#endif