Ackley’s function is a standard benchmark mathematical function used to test numerical optimization algorithms. The function is defined in two dimensions as:

f(x,y) = -20 * exp(-0.2*sqrt(0.5*(x^2 + y^2))) -
- exp(0.5*cos(2*pi*x) + cos(2*pi*y)))
+ 20 + e

The function has a minimum value of 0.0 located at x = 0, y = 0. I wanted to graph the function so I used SciLab, a free program that is similar to the very expensive MatLab program.

Here are the five SciLab commands I issued:

-->[x,y]=meshgrid(-4:.10:4,-4:.10:4);
-->z=-20 * exp(-0.2*sqrt(0.5 * (x.^2 + y.^2)))
- exp(0.5 * (cos(2*%pi*x) + cos(2*%pi*y)))
+ 20 + %e;
-->g=scf();
-->g.color_map=jetcolormap(64);
-->surf(x,y,z);

The first command sets up a matrix of (x,y) values from -4 to +4, 0.10 units apart. The second command is the definition of Ackley’s function for two variables. Note the use of the .^ operator rather than the ^ operator. The third through fifth commands create the graph.

Notice that Ackley’s function has many local minimum values, which makes finding the optimal solution at (0,0) a bit tricky for some numerical optimization algorithms.

### Like this:

Like Loading...

*Related*