12.07.2015 Views

Evolutionary Algorithms Solutions Problem Set - MATLAB

Evolutionary Algorithms Solutions Problem Set - MATLAB

Evolutionary Algorithms Solutions Problem Set - MATLAB

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1510505005−5−54 Fletcher and Powellfunction F = fletcher_powell(A, B, alpha, x)% A, B: n-by-n matrix, real; alpha, x: column vector, realn = length(A(:,1));for (i=1:n)p(i) = sum(A(:,i) .* sin(alpha) + B(:,i) .* cos(alpha));q(i) = sum(A(:,i) .* sin(x) + B(:,i) .* cos(x));endF = sum((p - q) .^ 2);endTo plot the Fletcher and Powell function in 3D for −π ≤ x i ≤ π, a ij , b ij ∈ [−100, 100], andα ∈ [−π, π], type:>> A = rand(2) * 100 - 100>> B = rand(2) * 100 - 100>> alpha = rand(2,1) * 2*pi - pi>> func = @(x) fletcher_powell(A, B, alpha, x)>> plot_2d_function(func, -pi * ones(2,1), pi * ones(2,1))

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!