genetic algorithm fintess function

조회 수: 8 (최근 30일)
Ifeatu Ezenwe
Ifeatu Ezenwe 2019년 3월 4일
편집: Walter Roberson 2019년 3월 4일
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