Clear Filters
Clear Filters

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)
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
Star Strider on 1 Apr 2022
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 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.

Sign in to comment.

Answers (1)

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

Community Treasure Hunt

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

Start Hunting!