Shark machine learning library
About Shark
News!
Contribute
Credits and copyright
Downloads
Getting Started
Installation
Using the docs
Documentation
Tutorials
Quick references
Class list
Global functions
FAQ
Showroom
include
shark
ObjectiveFunctions
Benchmarks
CIGTAB1.h
Go to the documentation of this file.
1
//===========================================================================
2
/*!
3
*
4
*
5
* \brief Multi-objective optimization benchmark function CIGTAB 1.
6
*
7
* The function is described in
8
*
9
* Christian Igel, Nikolaus Hansen, and Stefan Roth.
10
* Covariance Matrix Adaptation for Multi-objective Optimization.
11
* Evolutionary Computation 15(1), pp. 1-28, 2007
12
*
13
*
14
*
15
* \author -
16
* \date -
17
*
18
*
19
* \par Copyright 1995-2015 Shark Development Team
20
*
21
* <BR><HR>
22
* This file is part of Shark.
23
* <http://image.diku.dk/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_CIGTAB1_H
41
#define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_CIGTAB1_H
42
43
#include <
shark/ObjectiveFunctions/AbstractObjectiveFunction.h
>
44
#include <
shark/ObjectiveFunctions/BoxConstraintHandler.h
>
45
#include <
shark/LinAlg/rotations.h
>
46
47
48
namespace
shark
{
49
/*! \brief Multi-objective optimization benchmark function CIGTAB 1.
50
*
51
* The function is described in
52
*
53
* Christian Igel, Nikolaus Hansen, and Stefan Roth.
54
* Covariance Matrix Adaptation for Multi-objective Optimization.
55
* Evolutionary Computation 15(1), pp. 1-28, 2007
56
*/
57
struct
CIGTAB1
:
public
MultiObjectiveFunction
{
58
59
CIGTAB1
(std::size_t
numberOfVariables
= 5) : m_a( 1E6 ) {
60
m_features
|=
CAN_PROPOSE_STARTING_POINT
;
61
m_numberOfVariables =
numberOfVariables
;
62
}
63
64
/// \brief From INameable: return the class name.
65
std::string
name
()
const
66
{
return
"CIGTAB1"
; }
67
68
std::size_t
numberOfObjectives
()
const
{
69
return
2;
70
}
71
72
std::size_t
numberOfVariables
()
const
{
73
return
m_numberOfVariables;
74
}
75
76
bool
hasScalableDimensionality
()
const
{
77
return
true
;
78
}
79
80
/// \brief Adjusts the number of variables if the function is scalable.
81
/// \param [in] numberOfVariables The new dimension.
82
void
setNumberOfVariables
( std::size_t
numberOfVariables
){
83
m_numberOfVariables =
numberOfVariables
;
84
}
85
86
void
init
() {
87
m_rotationMatrix =
blas::randomRotationMatrix
(m_numberOfVariables);
88
}
89
90
ResultType
eval
(
const
SearchPointType
& x )
const
{
91
m_evaluationCounter
++;
92
93
ResultType
value(2);
94
95
ResultType
y =
prod
( m_rotationMatrix, x );
96
double
result =
sqr
( y(0) ) +
sqr
( m_a ) *
sqr
( y(
numberOfVariables
() - 1 ) );
97
98
for
(
unsigned
i = 1; i <
numberOfVariables
() - 1; i++) {
99
result += m_a *
sqr
( y( i ) );
100
}
101
102
value[0] = result / (
sqr
(m_a) *
numberOfVariables
() );
103
104
result =
sqr
(y( 0 ) - 2) +
sqr
(m_a) *
sqr
(y(
numberOfVariables
()-1) - 2);
105
106
for
(
unsigned
i = 1; i <
numberOfVariables
() - 1; i++) {
107
result += m_a *
sqr
(y( i ) - 2);
108
}
109
110
value[1] = result / (
sqr
(m_a) *
numberOfVariables
() );
111
112
return
value;
113
}
114
115
SearchPointType
proposeStartingPoint
()
const
{
116
RealVector x(m_numberOfVariables);
117
118
for
(std::size_t i = 0; i < x.size(); i++) {
119
x(i) =
Rng::uni
(-10.0, 10.0);
120
}
121
return
x;
122
}
123
private
:
124
double
m_a;
125
RealMatrix m_rotationMatrix;
126
std::size_t m_numberOfVariables;
127
};
128
}
129
#endif