How to define the model in a genetic algorithm when some model parameters are to be searched by the algorithm?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Star Strider
am 1 Apr. 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
am 1 Apr. 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.
Antworten (1)
Star Strider
am 1 Apr. 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 Kommentare
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!