Choosing optimal values from the genetic algorithm
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Sam Chak
le 3 Fév 2023
Modifié(e) : Sam Chak
le 3 Fév 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)
Voir également
Catégories
En savoir plus sur Genetic Algorithm dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!