How to define the model in a genetic algorithm when some model parameters are to be searched by the algorithm?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
How to define the model in a genetic algorithm when some model parameters are to be searched by the algorithm?
I have an optimization problem, it has some formulas and parameters and 2 of them should be found by the algorithm.
but these two parameters are needed for the definition of the model, too.
How should I define them at first?
3 comentarios
Star Strider
el 1 de Abr. de 2022
There is also nothing wrong with the function I chose to do so. Note that it converges on the correct values, demonstrating the robust nature of the ga function.
Sam Chak
el 1 de Abr. de 2022
Yes true, @Star Strider is very helpful with the example. Hope @Fatemeh Sharafi is able to find the fitness function. If she needs help, she can consider showing all governing equations and describe what she is trying to optimze.
Respuestas (1)
Star Strider
el 1 de Abr. de 2022
To pass extra parameters to the fitness function, and optimise only the parameters-of-interest (here ‘p’), do something like this —
fitness = @(p,a,b) (p(1) - a)^2 + (p(2) - b)^2; % Parameters To Optimise: 'p'; Extra Parameters: 'a', 'b'
a = 3;
b = 5;
nvars = 2; % Two Elements in 'p'
P = ga(@(p)fitness(p,a,b), nvars)
.
0 comentarios
Ver también
Categorías
Más información sobre Genetic Algorithm en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!