Skip to content

Commit

Permalink
Add camel test functions, with three and six humps
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainAit authored and jbect committed Oct 19, 2024
1 parent 9dde6fa commit 1219905
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2024-08-07 Romain Ait Abdelmalek-Lomenech <romain.ait@centralesupelec.fr>

Add camel test functions, with three and six humps

* examples/test_functions/stk_testfun_sixhumpscamel.m: New tets function.
* examples/test_functions/stk_testfun_threehumpscamel.m: New tets function.
* admin/octpkg/INDEX: Update Octave package index.
* NEWS.md: Advertise the change.

2024-03-28 Romain Ait Abdelmalek-Lomenech <romain.ait@centralesupelec.fr>

stk_param_estim.m: Fix nargout condition
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@

* `stk_length`: Removed. (Had been deprecated since 2.7.0.)

## Test functions

* `stk_testfun_threehumpscamel`, `stk_testfun_sixhumpscamel`: New test
functions.

* Most test functions in `examples/test_functions` are now also
available under the CC0 license (see each file).

-----


Expand Down
2 changes: 2 additions & 0 deletions admin/octpkg/INDEX
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ Examples: test functions, datasets, etc.
stk_testfun_hartman4
stk_testfun_hartman6
stk_testfun_hartman_generic
stk_testfun_sixhumpscamel
stk_testfun_threehumpscamel
stk_testfun_twobumps
stk_testcase_truss3
stk_testfun_truss3_bb
Expand Down
75 changes: 75 additions & 0 deletions examples/test_functions/stk_testfun_sixhumpscamel.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
% STK_TESTFUN_SIXHUMPSCAMEL computes the "six humps camel back" function
%
% CALL: Y = stk_testfun_sixhumpscamel (X)
%
% computes the value Y of the Hartman4 function at X.
%
% The six humps camel back function is a test function in dimension 2,
% which is usually evaluated over [-5, 5]^2.
%
% GLOBAL MINIMUM
%
% According to [1], the function has two global minima at
%
% x = [-0.0898, 0.7126]
%
% and
%
% x = [0.0898, -0.7126].
%
% The corresponding function value is:
%
% f(x) = -1.0316.
%
% REFERENCES
%
% [1] M. Jamil & X. Yang, A Literature Survey of Benchmark Functions
% For Global Optimization Problems. Int. Journal of Mathematical
% Modelling and Numerical Optimisation, Vol. 4, No. 2, pp. 150–194
% (2013).

% Author
%
% Written in 2024 by Romain Ait Abdelmalek-Lomenech
% <romain.ait@centralesupelec.fr>

% Copying Permission Statement (this file)
%
% To the extent possible under law, CentraleSupelec has waived all
% copyright and related or neighboring rights to
% stk_testfun_sixhumpscamel.m. This work is published from France.
%
% License: CC0 <http://creativecommons.org/publicdomain/zero/1.0/>

% Copying Permission Statement (STK toolbox as a whole)
%
% This file is part of
%
% STK: a Small (Matlab/Octave) Toolbox for Kriging
% (https://github.com/stk-kriging/stk/)
%
% STK is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or (at your
% option) any later version.
%
% STK is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
% License for more details.
%
% You should have received a copy of the GNU General Public License
% along with STK. If not, see <http://www.gnu.org/licenses/>.

function y = stk_testfun_sixhumpscamel (x)

x1 = x(:, 1);
x2 = x(:, 2);

A = (4 - (2.1 * x1 .^ 2) + (x1 .^ 4) / 3) .* (x1 .^ 2);
B = x1 .* x2;
C = 4 * (x2 .^ 2 - 1) .* (x2 .^ 2);

y = A + B + C;

end % function
71 changes: 71 additions & 0 deletions examples/test_functions/stk_testfun_threehumpscamel.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
% STK_TESTFUN_THREEHUMPSCAMEL computes the "three humps camel back" function
%
% CALL: Y = stk_testfun_threehumpscamel (X)
%
% computes the value Y of the Hartman4 function at X.
%
% The six humps camel back function is a test function in dimension 2,
% which is usually evaluated over [-5, 5]^2.
%
% GLOBAL MINIMUM
%
% According to [1], the function has one global minimum at
%
% x = [0, 0].
%
% The corresponding function value is:
%
% f(x) = 0.
%
% REFERENCES
%
% [1] M. Jamil & X. Yang, A Literature Survey of Benchmark Functions
% For Global Optimization Problems. Int. Journal of Mathematical
% Modelling and Numerical Optimisation, Vol. 4, No. 2, pp. 150–194
% (2013).

% Author
%
% Written in 2024 by Romain Ait Abdelmalek-Lomenech
% <romain.ait@centralesupelec.fr>

% Copying Permission Statement (this file)
%
% To the extent possible under law, CentraleSupelec has waived all
% copyright and related or neighboring rights to
% stk_testfun_threehumpscamel.m. This work is published from France.
%
% License: CC0 <http://creativecommons.org/publicdomain/zero/1.0/>

% Copying Permission Statement (STK toolbox as a whole)
%
% This file is part of
%
% STK: a Small (Matlab/Octave) Toolbox for Kriging
% (https://github.com/stk-kriging/stk/)
%
% STK is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or (at your
% option) any later version.
%
% STK is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
% License for more details.
%
% You should have received a copy of the GNU General Public License
% along with STK. If not, see <http://www.gnu.org/licenses/>.

function y = stk_testfun_threehumpscamel (x)

x1 = x(:, 1);
x2 = x(:, 2);

A = (2 * x1 .^ 2) - (1.05 * x1 .^ 4) + (x1 .^ 6 / 6);
B = x1 .* x2;
C = x2 .^ 2;

y = A + B + C;

end % function

0 comments on commit 1219905

Please sign in to comment.