Choosing optimal values from the genetic algorithm
19 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
As GA are probabilistic and indetriministic everytime I run the code I am getting different optimas with the same value of objective function.
How to choose the proper and best optima when the function value remains same for different optimias.
Is there any way to choose the best optima.
Thank you in Advance!!
0 Commenti
Risposte (1)
Sam Chak
il 3 Feb 2023
Modificato: Sam Chak
il 3 Feb 2023
Hi @Vivek
You can try setting the rng to 'default' for the reproducibility of the result.
If the function has multiple extrema, I'd probably set the lower and upper bounds on the design variables, so that the solution is searched and found in the range of interest.
xx = linspace(-pi, pi, 51);
yy = linspace(-pi, pi, 51);
[X, Y] = meshgrid(xx, yy);
Z = (sin(X)).^2 + (cos(Y)).^2;
% contour(X, Y, Z)
surfc(X, Y, Z)
xlabel('x_1'), ylabel('x_2'), zlabel('f(x_1, x_2)')
rng default % For reproducibility
fun = @(x) (sin(x(1))).^2 + (cos(x(2))).^2;
lb = [-pi -pi]; % lower bound
ub = [pi pi]; % upper bound
x = ga(fun, 2, [], [], [], [], lb, ub)
Vedere anche
Categorie
Scopri di più su Genetic Algorithm in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!