genetic algorithm fintess function
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ifeatu Ezenwe
am 4 Mär. 2019
Bearbeitet: Walter Roberson
am 4 Mär. 2019
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 Kommentare
Walter Roberson
am 4 Mär. 2019
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 .
Akzeptierte Antwort
Walter Roberson
am 4 Mär. 2019
Bearbeitet: Walter Roberson
am 4 Mär. 2019
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!