ELLI2.h
Go to the documentation of this file.
1 //===========================================================================
2 /*!
3  *
4  *
5  * \brief Multi-objective optimization benchmark function ELLI 2.
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  * <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 #ifndef SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_ELLI2_H
41 #define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_ELLI2_H
42 
45 #include <shark/Core/Random.h>
46 
47 #include <shark/LinAlg/rotations.h>
48 
49 namespace shark {
50 /*! \brief Multi-objective optimization benchmark function ELLI2.
51 *
52 * The function is described in
53 *
54 * Christian Igel, Nikolaus Hansen, and Stefan Roth.
55 * Covariance Matrix Adaptation for Multi-objective Optimization.
56 * Evolutionary Computation 15(1), pp. 1-28, 2007
57 */
58 struct ELLI2 : public MultiObjectiveFunction{
59 
60  ELLI2(std::size_t numVariables = 0) : m_a( 1E6 ){
62  setNumberOfVariables(numVariables);
63  }
64 
65  /// \brief From INameable: return the class name.
66  std::string name() const
67  { return "ELLI2"; }
68 
69  std::size_t numberOfObjectives()const{
70  return 2;
71  }
72 
73  std::size_t numberOfVariables()const{
74  return m_coefficients.size();
75  }
76 
78  return true;
79  }
80 
81  void setNumberOfVariables( std::size_t numVariables ){
82  m_coefficients.resize(numVariables);
83  for(std::size_t i = 0; i != numVariables; ++i){
84  m_coefficients(i) = std::pow(m_a, 2.0 * (i / (numVariables - 1.0)));
85  }
86  }
87 
88  void init() {
89  m_rotationMatrix1 = blas::randomRotationMatrix(*mep_rng, numberOfVariables() );
90  m_rotationMatrix2 = blas::randomRotationMatrix(*mep_rng, numberOfVariables() );
91  }
92 
93  ResultType eval( const SearchPointType & x ) const {
95 
96  ResultType value( 2 );
97 
98  SearchPointType y = prod( m_rotationMatrix1, x );
99  SearchPointType z = prod( m_rotationMatrix2, x );
100 
101  double sum1 = 0.0;
102  double sum2 = 0.0;
103  for (unsigned i = 0; i < numberOfVariables(); i++) {
104  sum1 += m_coefficients(i) * sqr( y(i) );
105  sum2 += m_coefficients(i) * sqr( z(i) - 2.0 );
106  }
107 
108  value[0] = sum1 / ( sqr(m_a) * numberOfVariables() );
109  value[1] = sum2 / ( sqr(m_a) * numberOfVariables() );
110 
111  return value;
112  }
113 
115  RealVector x(numberOfVariables());
116 
117  for (std::size_t i = 0; i < x.size(); i++) {
118  x(i) = random::uni(*mep_rng, -10,10);
119  }
120  return x;
121  }
122 
123 private:
124  double m_a;
125  RealMatrix m_rotationMatrix1;
126  RealMatrix m_rotationMatrix2;
127  RealVector m_coefficients;
128 };
129 
130 }
131 #endif