Genetic Algorithm Calculation steps

2 views (last 30 days)
Dear All,
i am using Genetic Algorithm throught optimization toolbox. my optimization problem is little complicated as a lot of dependent variables are to be calculated, and they are defined on five m.files.
i want to show the calculations steps on detailes that are done on each trail of optimization process. this is important for me to understand how the algorithm think and do what before what and how it transfere from one file to another, so, i can adjust my code. if it possible, how can i do that.
what i want is not the general steps of Genetic Algorithm, i want to show the steps actualy performed by my code after i run it.
thank you a lot.
  5 Comments
Nourhan Elsayed
Nourhan Elsayed on 27 Sep 2020
you mention that
'the first (NVARS+1) calls to the objective function are used to create a simplex for further use and are not counted as being part of the iterations'.
i understand the point you are refering to, however, there are some thing strange for me, the number of calls for objective function is ,at least, equal to NVARS.
relating the number of calls to NVARS made me understand that objective function is calculated for each variable of Decision values [x1, x2, x3, .... xNVARS] separately.
i dont think what i understand is true
Walter Roberson
Walter Roberson on 27 Sep 2020
At the beginning, in order to create the initial simplex, for continuous variables the code uses something like:
if lower bound is in effect
LB = lowerbound
else
LB = zeros(1, nvars);
end
F = zeros(1,nvars+1);
F(1) = objective(LB);
for K = 1 : nvars
lb = LB;
lb(K) = lb(K) + 0.1;
F(K+1) = objective(lb);
end
This takes an initial point and then evaluates nvars more times, each time varying exactly one of the parameters a small distance away from the initial point.
For discrete variables it would uses the minimum discrete values for LB and modify each in turn to its second valid discrete value.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 24 Sep 2020
The ga function essentially takes a population of possible parameter vectors and ‘evolves’ them so that the set that produces the lowest value of the fitness function is the eventual best individual. It tests every member of the population with the fitness function to do this.
I doubt that anything in the code for your fitness function changes significantly except with respect to the results dependent on the parameters, and those you can simulate with any set of parameters.
Likely the closest you can get to doing what you want and seeing what the ga function is doing is to use an options structure and write your own OutputFcn to return what you want. See Output Function Options and Custom Output Function for Genetic Algorithm for details.
I leave the rest to you!
  1 Comment
Nourhan Elsayed
Nourhan Elsayed on 27 Sep 2020
Edited: Nourhan Elsayed on 27 Sep 2020
yeah, your next words draws my attention
' It tests every member of the population with the fitness function to do this
I doubt that anything in the code for your fitness function changes significantly except with respect to the results dependent on the parameters, and those you can simulate with any set of parameters'
thats mean that only variables that are dependent on the set of Decision Variables are recalculated. that is logical and should not lead to any defalut.
however, i am not sure that constraints, or variables , that are defined on a separt file as a function handle, are recalculated accordingly. i always get error msg regarding the 'nonlcon' , they are not satisfied. i suspect they are satisfied even at first iteration.
Thank you for the references links

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!