primatologist-gpl 6.0.4
test_functions.h
Go to the documentation of this file.
1/* Copyright (C) 2000-2013 CEA
2 *
3 * This software and supporting documentation were developed by
4 * bioPICSEL
5 * CEA/DSV/I²BM/MIRCen/LMN, Batiment 61,
6 * 18, route du Panorama
7 * 92265 Fontenay-aux-Roses
8 * France
9 */
10
11#ifndef PRIMATOLOGIST_OPTIMIZATION_TEST_FUNCTIONS_H
12#define PRIMATOLOGIST_OPTIMIZATION_TEST_FUNCTIONS_H
13
16#include <cmath>
17
18// This file defines and implements classic test functions for optimization
19// algorithms. They are described at:
20// http://en.wikipedia.org/wiki/Test_functions_for_optimization
21// where one can visualize their shape.
22
23namespace aims {
24namespace math {
25
26 //==========================================================================
27 // RASTRIGIN
28 //==========================================================================
29
32 {
33 public:
34 Rastrigin( int n = 2, float A = 10. );
36
37 float value( const Vector & x ) const;
38 Vector derivative( const Vector & x ) const;
39 Matrix hessian( const Vector & x ) const;
40
42 float exactMinValue() const;
43
44 protected:
45 float _A;
46 float _n;
47 };
48
49 //==========================================================================
50 // ACKLEY
51 //==========================================================================
52
54 class Ackley
55 {
56 public:
57 Ackley( int n = 2, float a = 20, float b = 0.2, float c = TWO_PI );
59
60 float value( const Vector & x ) const;
61 Vector derivative( const Vector & x ) const;
62 Matrix hessian( const Vector & x ) const;
63
65 float exactMinValue() const;
66
67 protected:
68 int _n;
69 float _a;
70 float _b;
71 float _c;
72 float term_poly( const Vector & ) const;
73 float term_cos( const Vector & ) const;
74 float g_poly( const Vector &, int ) const;
75 float g_cos( const Vector &, int ) const;
76 float gg_poly( const Vector &, int, int ) const;
77 float gg_cos( const Vector &, int, int ) const;
78 };
79
80 //==========================================================================
81 // SPHERE
82 //==========================================================================
83
85 class SphereF
86 {
87 public:
88 SphereF( int n = 2 );
90
91 float value( const Vector & x ) const;
92 Vector derivative( const Vector & x ) const;
93 Matrix hessian( const Vector & x ) const;
94
96 float exactMinValue() const;
97
98 protected:
99 float _n;
100 };
101
102 //==========================================================================
103 // ROSENBROCK
104 //==========================================================================
105
108 {
109 public:
110 Rosenbrock( int n = 2 );
112
113 float value( const Vector & x ) const;
114 Vector derivative( const Vector & x ) const;
115 Matrix hessian( const Vector & x ) const;
116
118 float exactMinValue() const;
119
120 protected:
121 float _n;
122 };
123
124 //==========================================================================
125 // Beale
126 //==========================================================================
127
129 class Beale
130 {
131 public:
134
135 float value( const Vector & x ) const;
136 Vector derivative( const Vector & x ) const;
137 Matrix hessian( const Vector & x ) const;
138
140 float exactMinValue() const;
141 };
142
143 //==========================================================================
144 // Goldstein-Price
145 //==========================================================================
146
149 {
150 public:
153
154 float value( const Vector & x ) const;
155 Vector derivative( const Vector & x ) const;
156 Matrix hessian( const Vector & x ) const;
157
159 float exactMinValue() const;
160 };
161
162 //==========================================================================
163 // Booth
164 //==========================================================================
165
166 class Booth
167 {
168 public:
171
172 float value( const Vector & x ) const;
173 Vector derivative( const Vector & x ) const;
174 Matrix hessian( const Vector & x ) const;
175
177 float exactMinValue() const;
178 };
179
180 //==========================================================================
181 // Bukin n°6
182 //==========================================================================
183
185 class Bukin6
186 {
187 public:
190
191 float value( const Vector & x ) const;
192 Vector derivative( const Vector & x ) const;
193 Matrix hessian( const Vector & x ) const;
194
196 float exactMinValue() const;
197 };
198
199 //==========================================================================
200 // Matyas
201 //==========================================================================
202
204 class Matyas
205 {
206 public:
209
210 float value( const Vector & x ) const;
211 Vector derivative( const Vector & x ) const;
212 Matrix hessian( const Vector & x ) const;
213
215 float exactMinValue() const;
216 };
217
218 //==========================================================================
219 // Levi n°13
220 //==========================================================================
221
223 class Levi13
224 {
225 public:
228
229 float value( const Vector & x ) const;
230 Vector derivative( const Vector & x ) const;
231 Matrix hessian( const Vector & x ) const;
232
234 float exactMinValue() const;
235 };
236
237 //==========================================================================
238 // Three-hump camel
239 //==========================================================================
240
243 {
244 public:
247
248 float value( const Vector & x ) const;
249 Vector derivative( const Vector & x ) const;
250 Matrix hessian( const Vector & x ) const;
251
253 float exactMinValue() const;
254 };
255
256 //==========================================================================
257 // Easom
258 //==========================================================================
259
261 class Easom
262 {
263 public:
266
267 float value( const Vector & x ) const;
268 Vector derivative( const Vector & x ) const;
269 Matrix hessian( const Vector & x ) const;
270
272 float exactMinValue() const;
273 };
274
275 //==========================================================================
276 // Cross-in-tray
277 //==========================================================================
278
282 {
283 public:
286
287 float value( const Vector & x ) const;
288 Vector derivative( const Vector & x ) const;
289 Matrix hessian( const Vector & x ) const;
290
292 float exactMinValue() const;
293 };
294
295 //==========================================================================
296 // Eggholder
297 //==========================================================================
298
301 {
302 public:
305
306 float value( const Vector & x ) const;
307 Vector derivative( const Vector & x ) const;
308 Matrix hessian( const Vector & x ) const;
309
311 float exactMinValue() const;
312 };
313
314 //==========================================================================
315 // Hoelder table
316 //==========================================================================
317
320 {
321 public:
324
325 float value( const Vector & x ) const;
326 Vector derivative( const Vector & x ) const;
327 Matrix hessian( const Vector & x ) const;
328
330 float exactMinValue() const;
331 };
332
333 //==========================================================================
334 // McCormick
335 //==========================================================================
336
338 {
339 public:
342
343 float value( const Vector & x ) const;
344 Vector derivative( const Vector & x ) const;
345 Matrix hessian( const Vector & x ) const;
346
348 float exactMinValue() const;
349 };
350
351 //==========================================================================
352 // Schaffer n°2
353 //==========================================================================
354
356 {
357 public:
360
361 float value( const Vector & x ) const;
362 Vector derivative( const Vector & x ) const;
363 Matrix hessian( const Vector & x ) const;
364
366 float exactMinValue() const;
367 };
368
369 //==========================================================================
370 // Schaffer n°4
371 //==========================================================================
372
374 {
375 public:
378
379 float value( const Vector & x ) const;
380 Vector derivative( const Vector & x ) const;
381 Matrix hessian( const Vector & x ) const;
382
384 float exactMinValue() const;
385 };
386
387 //==========================================================================
388 // Styblinski–Tang
389 //==========================================================================
390
392 {
393 public:
394 StyblinskiTang( int n = 2 );
396
397 float value( const Vector & x ) const;
398 Vector derivative( const Vector & x ) const;
399 Matrix hessian( const Vector & x ) const;
400
402 float exactMinValue() const;
403
404 protected:
405 int _n;
406 };
407
408} // math
409} // aims
410
411#endif // PRIMATOLOGIST_OPTIMIZATION_TEST_FUNCTIONS_H
float value(const Vector &x) const
float term_cos(const Vector &) const
Vector derivative(const Vector &x) const
float g_cos(const Vector &, int) const
float gg_cos(const Vector &, int, int) const
float gg_poly(const Vector &, int, int) const
float g_poly(const Vector &, int) const
Ackley(int n=2, float a=20, float b=0.2, float c=TWO_PI)
float term_poly(const Vector &) const
Vector exactMin() const
float exactMinValue() const
Matrix hessian(const Vector &x) const
float exactMinValue() const
Vector exactMin() const
Matrix hessian(const Vector &x) const
Vector derivative(const Vector &x) const
float value(const Vector &x) const
float value(const Vector &x) const
Vector exactMin() const
Vector derivative(const Vector &x) const
float exactMinValue() const
Matrix hessian(const Vector &x) const
float exactMinValue() const
Vector derivative(const Vector &x) const
Matrix hessian(const Vector &x) const
float value(const Vector &x) const
Vector exactMin() const
Matrix hessian(const Vector &x) const
float exactMinValue() const
float value(const Vector &x) const
Vector derivative(const Vector &x) const
Vector exactMin() const
float value(const Vector &x) const
float exactMinValue() const
Vector derivative(const Vector &x) const
Matrix hessian(const Vector &x) const
Vector exactMin() const
float exactMinValue() const
Vector exactMin() const
Vector derivative(const Vector &x) const
Matrix hessian(const Vector &x) const
float value(const Vector &x) const
Vector derivative(const Vector &x) const
Matrix hessian(const Vector &x) const
float value(const Vector &x) const
Vector exactMin() const
Matrix hessian(const Vector &x) const
float exactMinValue() const
Vector derivative(const Vector &x) const
float value(const Vector &x) const
float exactMinValue() const
float value(const Vector &x) const
Vector exactMin() const
Matrix hessian(const Vector &x) const
Vector derivative(const Vector &x) const
Vector exactMin() const
float exactMinValue() const
Vector derivative(const Vector &x) const
Matrix hessian(const Vector &x) const
float value(const Vector &x) const
Vector exactMin() const
Vector derivative(const Vector &x) const
float value(const Vector &x) const
Matrix hessian(const Vector &x) const
float exactMinValue() const
Vector derivative(const Vector &x) const
Rastrigin(int n=2, float A=10.)
float value(const Vector &x) const
float exactMinValue() const
Matrix hessian(const Vector &x) const
Vector exactMin() const
Vector exactMin() const
float value(const Vector &x) const
Matrix hessian(const Vector &x) const
Vector derivative(const Vector &x) const
float exactMinValue() const
Vector derivative(const Vector &x) const
Matrix hessian(const Vector &x) const
float exactMinValue() const
float value(const Vector &x) const
Vector exactMin() const
Vector exactMin() const
Matrix hessian(const Vector &x) const
float exactMinValue() const
float value(const Vector &x) const
Vector derivative(const Vector &x) const
float exactMinValue() const
Matrix hessian(const Vector &x) const
Vector exactMin() const
Vector derivative(const Vector &x) const
float value(const Vector &x) const
float value(const Vector &x) const
Matrix hessian(const Vector &x) const
Vector derivative(const Vector &x) const
Matrix hessian(const Vector &x) const
float value(const Vector &x) const
Vector derivative(const Vector &x) const
const double TWO_PI
Definition constants.h:19
MatrixBase< float > Vector
Definition matrix.h:29
MatrixBase< float > Matrix
Definition matrix.h:27