LZ8.h
Go to the documentation of this file.
1//===========================================================================
2/*!
3 *
4 *
5 * \brief Multi-objective optimization benchmark function LZ8.
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_LZ8_H
41#define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_LZ8_H
42
45
46
47namespace shark {namespace benchmarks{
48/*! \brief Multi-objective optimization benchmark function LZ8.
49*
50* The function is described in
51*
52* H. Li and Q. Zhang.
53* Multiobjective Optimization Problems with Complicated Pareto Sets, MOEA/D and NSGA-II,
54* IEEE Trans on Evolutionary Computation, 2(12):284-302, April 2009.
55* \ingroup benchmarks
56*/
58{
59 LZ8(std::size_t numVariables = 0) : m_handler(SearchPointType(numVariables,0),SearchPointType(numVariables,1) ){
60 announceConstraintHandler(&m_handler);
61 }
62
63 /// \brief From INameable: return the class name.
64 std::string name() const
65 { return "LZ8"; }
66
67 std::size_t numberOfObjectives()const{
68 return 2;
69 }
70
71 std::size_t numberOfVariables()const{
72 return m_handler.dimensions();
73 }
74
76 return true;
77 }
78
79 /// \brief Adjusts the number of variables if the function is scalable.
80 /// \param [in] numberOfVariables The new dimension.
87
88 ResultType eval( const SearchPointType & x ) const {
90
91 ResultType value( 2, 0 );
92
93 std::size_t counter1 = 0, counter2 = 0;
94 for( std::size_t i = 1; i < x.size(); i++ ) {
95 double y = x(i) - ::pow( x(0), 0.5*(1.0 + 3*(i-1)/(x.size()-1) ) );
96 if( i % 2 == 0 ) {
97 counter2++;
98 value[1] += sqr( y );// - ::cos( 8*y*M_PI) + 1.;
99 double product = 2.;
100 for( std::size_t j = 0; j < x.size(); j++ )
101 if( j%2 == 0 )
102 product *= ::cos( 20 * y * M_PI / ::sqrt( static_cast<double>( j ) ) );
103 value[1] -= product + 2.;
104 } else {
105 counter1++;
106 value[0] += sqr( y );// - ::cos( 8*y*M_PI) + 1.;
107 double product = 2.;
108 for( std::size_t j = 0; j < x.size(); j++ )
109 if( j%2 == 1 )
110 product *= ::cos( 20 * y * M_PI / ::sqrt( static_cast<double>( j ) ) );
111 value[0] -= product + 2.;
112 }
113 }
114
115 value[0] *= 8./counter1;
116 value[0] += x( 0 );
117
118 value[1] *= 8./counter2;
119 value[1] += 1 - ::sqrt( x( 0 ) );
120
121 return( value );
122 }
123private:
125};
126
127}}
128#endif