-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathackley.R
More file actions
executable file
·35 lines (30 loc) · 1.08 KB
/
Copy pathackley.R
File metadata and controls
executable file
·35 lines (30 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
### The Ackley function for the testing of minimization and optimization functions.
ack_ley <- function(xx, a=20, b=0.2, c=2*pi) {
##########################################################################
#
# Authors: Sonja Surjanovic, Simon Fraser University
# Derek Bingham, Simon Fraser University
# Questions/Comments: Please email Derek Bingham at [email protected].
# Copyright 2013. Derek Bingham, Simon Fraser University.
#
# For function details and reference information, see:
# http://www.sfu.ca/~ssurjano/
#
##########################################################################
#
# INPUTS:
#
# xx = c(x1, x2, ..., xd)
# a = constant (optional), with default value 20
# b = constant (optional), with default value 0.2
# c = constant (optional), with default value 2*pi
#
##########################################################################
d <- length(xx)
sum1 <- sum(xx^2)
sum2 <- sum(cos(c*xx))
term1 <- -a * exp(-b*sqrt(sum1/d))
term2 <- -exp(sum2/d)
y <- term1 + term2 + a + exp(1)
return(y)
} # end ack_ley