Functions for genetic algorithms

3 views (last 30 days)
Dua
Dua on 29 Oct 2012
When I run rastriginsfcn.m using optimization toolbox, GA solver, the final value of the fitness function when the algorithm terminated:
Objective function value: 0.05531602101322264 and the final point, which in this example is [0.001 -0.017].
The following are the code for rastriginsfcn.m:
function scores = rastriginsfcn(pop)
% pop = max(-5.12,min(5.12,pop));
scores = 10.0 * size(pop,2) + sum(pop .^2 - 10.0 * cos(2 * pi .* pop),2);
Are the above the complete code for rastriginsfcn.m? How does the code specify the initial population? How does the code specify that this function needs 2 variables (i.e x and y)? How does the code specify that x and y are to be generated randomly?

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!