GSP.h
Go to the documentation of this file.
1/*!
2 * \brief GSP benchmark function for multiobjective optimization
3 *
4 * \author O. Krause
5 * \date 2015
6 *
7 *
8 * \par Copyright 1995-2017 Shark Development Team
9 *
10 * <BR><HR>
11 * This file is part of Shark.
12 * <https://shark-ml.github.io/Shark/>
13 *
14 * Shark is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License as published
16 * by the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * Shark is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public License
25 * along with Shark. If not, see <http://www.gnu.org/licenses/>.
26 *
27 */
28#ifndef SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_GSP_H
29#define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_GSP_H
30
33#include <shark/Core/Random.h>
34
35namespace shark {namespace benchmarks{
36/// \brief Real-valued benchmark function with two objectives.
37/// \ingroup benchmarks
39{
40 GSP(std::size_t numVariables=5) : m_handler(SearchPointType(numVariables,0),SearchPointType(numVariables,10000)) {
41 announceConstraintHandler(&m_handler);
42 }
43
44 /// \brief From INameable: return the class name.
45 std::string name() const
46 { return "GSP"; }
47
48 std::size_t numberOfObjectives()const{
49 return 2;
50 }
51
52 std::size_t numberOfVariables()const{
53 return m_handler.dimensions();
54 }
55
57 return true;
58 }
59
66
67 ResultType eval( const SearchPointType & x ) const {
69
70 ResultType value( 2 );
71 double alpha = 1. / ( 2. * m_gamma );
72
73 double sum1 = 0., sum2 = 0.;
74
75 for( std::size_t i = 0; i < x.size(); i++ ) {
76 sum1 += sqr( x( i ) );
77 sum2 += sqr( 1 - x( i ) );
78 }
79
80 double alphaN = 1. / ( std::pow( x.size(), alpha ) );
81
82 value[0] = alphaN * std::pow( sum1, alpha );
83 value[1] = alphaN * std::pow( sum2, alpha );
84
85 return( value );
86 }
87private:
89 double m_gamma;
90};
91
92}}
93#endif