MATLAB Answers

0

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

Asked by CHOI HYUNDUK on 11 Nov 2018 at 0:23
Latest activity Edited by Matt J
on 11 Nov 2018 at 1:19
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

  0 Comments

Sign in to comment.

1 Answer

Answer by Matt J
on 11 Nov 2018 at 1:19
Edited by Matt J
on 11 Nov 2018 at 1:19
 Accepted Answer

function of = simple_fitness(y2)
a=y2(1);
b=y2(2);
of = 100 * (a^2 - b) ^2 + (1 - a)^2;
end

  0 Comments

Sign in to comment.