How to define the model in a genetic algorithm when some model parameters are to be searched by the algorithm?

1 次查看(过去 30 天)
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 个评论
Star Strider
Star Strider 2022-4-1
The purpose of my answer is to demonstrate the approach.
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
Sam Chak 2022-4-1
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.

请先登录,再进行评论。

回答(1 个)

Star Strider
Star Strider 2022-4-1
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)
Optimization terminated: average change in the fitness value less than options.FunctionTolerance.
P = 1×2
2.9935 5.0021
.

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by