How to define the model in a genetic algorithm when some model parameters are to be searched by the algorithm?
1 view (last 30 days)
Show older comments
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 Comments
Star Strider
on 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
on 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.
Answers (1)
Star Strider
on 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 Comments
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!