Fonseca.h
Go to the documentation of this file.
1 #ifndef SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_FONSECA_H
2 #define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_FONSECA_H
3 
4 //===========================================================================
5 /*!
6  *
7  *
8  * \brief Bi-objective real-valued benchmark function proposed by Fonseca and Flemming.
9  *
10  *
11  *
12  * \author -
13  * \date 2011
14  *
15  *
16  * \par Copyright 1995-2017 Shark Development Team
17  *
18  * <BR><HR>
19  * This file is part of Shark.
20  * <http://shark-ml.org/>
21  *
22  * Shark is free software: you can redistribute it and/or modify
23  * it under the terms of the GNU Lesser General Public License as published
24  * by the Free Software Foundation, either version 3 of the License, or
25  * (at your option) any later version.
26  *
27  * Shark is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  *
32  * You should have received a copy of the GNU Lesser General Public License
33  * along with Shark. If not, see <http://www.gnu.org/licenses/>.
34  *
35  */
36 //===========================================================================
37 
40 #include <shark/Core/Random.h>
41 
42 namespace shark {
43 
44 /// \brief Bi-objective real-valued benchmark function proposed by Fonseca and Flemming.
45 ///
46 /// Fonseca, C. M. and P. J. Fleming (1998). Multiobjective
47 /// optimization and multiple constraint handling with evolutionary
48 /// algorithms-Part II: Application example. IEEE Transactions on
49 /// Systems, Man, and Cybernetics, Part A: Systems and Humans 28(1),
50 /// 38-47
51 ///
52 /// The default search space dimension is 3, but the function can
53 /// handle more dimensions.
54 
56 
57  Fonseca(std::size_t numVariables)
58  :m_handler(SearchPointType(numVariables,-4),SearchPointType(numVariables,4) ){
59  announceConstraintHandler(&m_handler);
60  }
61 
62  /// \brief From INameable: return the class name.
63  std::string name() const
64  { return "Fonseca"; }
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 
79  m_handler.setBounds(
80  SearchPointType(numberOfVariables,-4),
81  SearchPointType(numberOfVariables,4)
82  );
83  }
84 
85  ResultType eval( const SearchPointType & x ) const {
87 
88  ResultType value( 2 );
89 
90  const double d = 1. / std::sqrt( static_cast<double>( x.size() ) );
91  double sum1 = 0., sum2 = 0.;
92  for( std::size_t i = 0; i < x.size(); i++ ) {
93  sum1 += sqr( x( i ) - d );
94  sum2 += sqr( x( i ) + d );
95  }
96 
97  value[0] = 1-std::exp( - sum1 );
98  value[1] = 1-std::exp( - sum2 );
99 
100  return value;
101  }
102 private:
104 };
105 }
106 #endif