LZ6.h
Go to the documentation of this file.
1//===========================================================================
2/*!
3 *
4 *
5 * \brief Multi-objective optimization benchmark function LZ6.
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 * <https://shark-ml.github.io/Shark/>
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_LZ6_H
41#define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_LZ6_H
42
45
46namespace shark {namespace benchmarks{
47/*! \brief Multi-objective optimization benchmark function LZ6.
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* \ingroup benchmarks
55*/
57{
58 LZ6(std::size_t numVariables = 0) : m_handler(SearchPointType(numVariables,-2),SearchPointType(numVariables,2) ){
59 announceConstraintHandler(&m_handler);
60 }
61
62 /// \brief From INameable: return the class name.
63 std::string name() const
64 { return "LZ6"; }
65
66 std::size_t numberOfObjectives()const{
67 return 2;
68 }
69
70 std::size_t numberOfVariables()const{
71 return m_handler.dimensions();
72 }
73
75 return true;
76 }
77
78 /// \brief Adjusts the number of variables if the function is scalable.
79 /// \param [in] numberOfVariables The new dimension.
83 lb(0) = 0;
84 ub(0) = 1;
85 m_handler.setBounds(lb, ub);
86 }
87
88 ResultType eval( const SearchPointType & x ) const {
90
91 ResultType value( 3, 0 );
92
93 std::size_t counter1 = 0, counter2 = 0, counter3 = 0;
94 for( std::size_t i = 3; i <= x.size(); i++ ) {
95 if( (i-1) % 3 == 0 ) { //J1
96 counter1++;
97 value[0] += sqr(x(i-1)-2*x( 1 )*::sin( 2 * M_PI * x( 0 ) + i*M_PI/x.size() ) );
98 } else if( (i-2) % 3 == 0 ) { //J2
99 counter2++;
100 value[1] += sqr(x(i-1)-2*x( 1 )*::sin( 2 * M_PI * x( 0 ) + i*M_PI/x.size() ) );
101 } else if( i % 3 == 0 ) {
102 counter3++;
103 value[2] += sqr(x(i-1)-2*x( 1 )*::sin( 2 * M_PI * x( 0 ) + i*M_PI/x.size() ) );
104 }
105 }
106
107 value[0] *= counter1 > 0 ? 2./counter1 : 1;
108 value[1] *= counter2 > 0 ? 2./counter2 : 1;
109 value[2] *= counter3 > 0 ? 2./counter3 : 1;
110
111 value[0] += ::cos( 0.5*M_PI * x( 0 ) ) * ::cos( 0.5*M_PI * x( 1 ) );
112 value[1] += ::cos( 0.5*M_PI * x( 0 ) ) * ::sin( 0.5*M_PI * x( 1 ) );
113 value[2] += ::sin( 0.5*M_PI * x( 0 ) );
114
115 return( value );
116 }
117private:
119};
120
121}}
122#endif