DTLZ7.h
Go to the documentation of this file.
1 //===========================================================================
2 /*!
3  *
4  *
5  * \brief Objective function DTLZ7
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  * <http://shark-ml.org/>
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_DTLZ7_H
35 #define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_DTLZ7_H
36 
39 
40 namespace shark {
41 /**
42 * \brief Implements the benchmark function DTLZ7.
43 *
44 * See: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.18.7531&rep=rep1&type=pdf
45 * The benchmark function exposes the following features:
46 * - Scalable w.r.t. the searchspace and w.r.t. the objective space.
47 * - Disconnected Pareto front.
48 */
50 {
51  DTLZ7(std::size_t numVariables = 0) : m_objectives(2), m_handler(numVariables,0,1 ){
52  announceConstraintHandler(&m_handler);
53  }
54 
55  /// \brief From INameable: return the class name.
56  std::string name() const
57  { return "DTLZ7"; }
58 
59  std::size_t numberOfObjectives()const{
60  return m_objectives;
61  }
62  bool hasScalableObjectives()const{
63  return true;
64  }
66  m_objectives = numberOfObjectives;
67  }
68 
69  std::size_t numberOfVariables()const{
70  return m_handler.dimensions();
71  }
72 
74  return true;
75  }
76 
77  /// \brief Adjusts the number of variables if the function is scalable.
78  /// \param [in] numberOfVariables The new dimension.
80  m_handler.setBounds(
81  SearchPointType(numberOfVariables,0),
82  SearchPointType(numberOfVariables,1)
83  );
84  }
85 
86  ResultType eval( const SearchPointType & x ) const {
88 
89  RealVector value( numberOfObjectives() );
90 
91  std::size_t k = numberOfVariables() - numberOfObjectives() + 1 ;
92  double g = 0.0 ;
93  for (std::size_t i = numberOfVariables() - k + 1; i <= numberOfVariables(); i++)
94  g += x(i-1);
95 
96  g = 1 + 9 * g / k;
97 
98  for (std::size_t i = 0; i != numberOfObjectives(); i++)
99  value[i] = x(i);
100 
101  double h = 0.0 ;
102  for (std::size_t j = 1; j <= numberOfObjectives() - 1; j++)
103  h += x(j-1) / (1 + g) * ( 1 + std::sin( 3 * M_PI * x(j-1) ) );
104 
105  h = numberOfObjectives() - h ;
106 
107  value[numberOfObjectives()-1] = (1 + g) * h;
108 
109  return value;
110  }
111 
112 private:
113  std::size_t m_objectives;
115 
116 };
117 
118 }
119 #endif