Genetic algorithm say 'average change in the fitness value less than options.Fu​nctionTole​rance.'

4 views (last 30 days)
I am studying 'Genetic algorithm'. I made 'y2' for optimizing with this function ' y = 100 * (a^2 - b) ^2 + (1 - a)^2 '.
Those are same things. like between y = a + 3 and y = 2 + 3. and i want to get a = 2. I thought this way 'sum((y-y2).^2)'.
But it doesn't work well saying ''average change in the fitness value less than options.FunctionTolerance.' The results are not good. I think the iteration is not enough to optimize . and it ends.
How could I solve this problem....
Thank you so much..
.
.
.
y2 = 100 * (1.5083^2 - 2.2781) ^2 + (1 - 1.5083)^2;
rng default % For reproducibility
FitnessFunction = @(a,b) simple_fitness(y2);
numberOfVariables = 2;
lb = [-3 -3];
ub = [3 3];
[x,fval] = ga(FitnessFunction,numberOfVariables,[],[],[],[],lb,ub)
function of = simple_fitness(y2)
a=1;
b=1;
y = 100 * (a^2 - b) ^2 + (1 - a)^2;
of = sum((y-y2).^2);
end

Accepted Answer

Matt J
Matt J on 11 Nov 2018
Edited: Matt J on 11 Nov 2018
function of = simple_fitness(y2)
a=y2(1);
b=y2(2);
of = 100 * (a^2 - b) ^2 + (1 - a)^2;
end

More Answers (0)

Community Treasure Hunt

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

Start Hunting!