genetic algorithm fintess function

3 次查看(过去 30 天)
Hi,
I need help with figuring out how to start with my genetic algorithm code for my problem. Especially figuring out the firness/objective function for my problem. The aim to produce two continouos optimised values.
Any help with be appreciated.
  4 个评论
Walter Roberson
Walter Roberson 2019-3-4
Why bother to run that through ga? Why not just say x = FTe and y = FTi ?
You can use the options to configure a FitnessLimit of 0.01 .
Ifeatu Ezenwe
Ifeatu Ezenwe 2019-3-4
编辑:Ifeatu Ezenwe 2019-3-4
thank you for your reply,
Just to confirm, this: "(H=0.5 *(x - FTe).^2 * 0.5*(y - FTi).^2" would be a suitable fitness fucntion?
I want to run it through ga as part of a bigger project.
What do you mean about options? I've read about it in a couple of websites but I don't know what it is, what is is used for or how to use it. Is it part of the gentic algorithm toolbox?
On a different problem: If another aim is to optimise two numbers between the range 0 and 1. Any formula that if executed with the two best parameters possible, would give exactly 0, would be okay? It doesnt matter what the formula is? as long as it equals to 0 ?
Thank you.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2019-3-4
编辑:Walter Roberson 2019-3-4
FTe = randn() * 10;
FTi = randn() * 10;
H = @(xy) 0.5 * (xy(1) - FTe).^2 .* 0.5*(xy(2) - FTi).^2;
good_enough = 0.01;
nvar = 2;
A = []; b = [];
Aeq = []; beq = [];
lb = zeros(1, nvar); %lower bound 0
ub = ones(1, nvar); %upper bound 1
nlcon = [];
options = optimoptions('ga', 'display', 'iter', 'FitnessLimit', good_enough);
[xy, fval] = ga(H, nvar, A, b, Aeq, beq, lb, ub, nlcon, options )
ga does not care whether the formula gives 0: ga will keep minimizing until either the target fitness is reached (if one was specified), or until it decide that there have been no improvements for a sufficiently long time, or until it has executed the function more times that it has been configured to try. It is just that function value 0 (such as a residue function) or function value -infinity are the two common cases for knowing when to stop: if you do not know what the global minima is for your objective function, then it is hard to know if ga did a good enough job.
With the random FTe and FTi that I put in for this sample code, if the random values are outside of the lower bound to upper bound range, ga will keep bouncing off the ends of the ranges until it gives up. If, though, the random FTe and FTi happen to be in the 0 to 1 range, then with that particular formula, ga will need only a small number of iterations to reach the target you asked for.

更多回答(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