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

4 次查看(过去 30 天)
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

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by