LZ5.h
Go to the documentation of this file.
1 //===========================================================================
2 /*!
3  *
4  *
5  * \brief Multi-objective optimization benchmark function LZ5.
6  *
7  * The function is described in
8  *
9  * H. Li and Q. Zhang.
10  * Multiobjective Optimization Problems with Complicated Pareto Sets, MOEA/D and NSGA-II,
11  * IEEE Trans on Evolutionary Computation, 2(12):284-302, April 2009.
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_LZ5_H
41 #define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_LZ5_H
42 
45 
46 namespace shark {
47 /*! \brief Multi-objective optimization benchmark function LZ5.
48 *
49 * The function is described in
50 *
51 * H. Li and Q. Zhang.
52 * Multiobjective Optimization Problems with Complicated Pareto Sets, MOEA/D and NSGA-II,
53 * IEEE Trans on Evolutionary Computation, 2(12):284-302, April 2009.
54 */
55 struct LZ5 : public MultiObjectiveFunction
56 {
57  LZ5(std::size_t numVariables = 0) : m_handler(SearchPointType(numVariables,-1),SearchPointType(numVariables,1) ){
58  announceConstraintHandler(&m_handler);
59  }
60 
61  /// \brief From INameable: return the class name.
62  std::string name() const
63  { return "LZ5"; }
64 
65  std::size_t numberOfObjectives()const{
66  return 2;
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  SearchPointType lb(numberOfVariables,-1);
81  SearchPointType ub(numberOfVariables, 1);
82  lb(0) = 0;
83  ub(0) = 1;
84  m_handler.setBounds(lb, ub);
85  }
86 
87  ResultType eval( const SearchPointType & x ) const {
89 
90  ResultType value( 2, 0 );
91 
92  std::size_t counter1 = 0, counter2 = 0;
93  for( std::size_t i = 1; i < x.size(); i++ ) {
94  if( i % 2 == 0 ) {
95  counter2++;
96  value[1] += sqr(
97  x(i) - (
98  (0.3*x(0)*x(0)*::cos(24*M_PI*x(0)+4*i*M_PI/x.size()) + 0.6*x(0))*
99  ::cos( 6 * M_PI * x( 0 ) + i*M_PI/x.size() )
100  )
101  );
102  } else {
103  counter1++;
104  value[0] += sqr(
105  x(i) - (
106  (0.3*x(0)*x(0)*::cos(24*M_PI*x(0)+4*i*M_PI/x.size()) + 0.6*x(0))*
107  ::sin( 6 * M_PI * x( 0 ) + i*M_PI/x.size() )
108  )
109  );
110  }
111  }
112 
113  value[0] *= 2./counter1;
114  value[0] += x( 0 );
115 
116  value[1] *= 2./counter2;
117  value[1] += 1 - ::sqrt( x( 0 ) );
118 
119  return value;
120  }
121 private:
123 };
124 
125 }
126 #endif