Initial population in genetic algorithm

Hello
I am trying to use GA and other algorithms to minimize my problem. For a faire comparison, the initial population will be chosen the same for all the algorithms. A randomly generated population is then generated and called for each algorithm.
So far, the idea works well except for GA where different result (starting objective) is obtained.
Following the options used for the GA, anyone can help me with this?
options = optimoptions(@ga,'Generations',Max_iteration,'OutputFcns',@outputfunction,'PopulationSize',50,'InitialPopulationMatrix',initialX,'TolFun',1e-10);

 采纳的回答

To get reproducible results, set the random number generator before you call ga. For example,
rng default
% or rng(1) or whatever you like
% Then call ga
Alan Weiss
MATLAB mathematical toolbox documentation

4 个评论

Hello
I am not sure I understand your response,
initialX is my initial population
should i set it like this?
rng(1)=initialX;
and call the GA?
No.
If I understand your initial question, your trouble is that you get differing results from different runs of ga. I was saying that the way to get identical runs is to run the command
rng default
before running ga. This has nothing to do with your initial population, unless you are setting your initial population randomly. If you are, then call
rng default
before creating your initial population. This is simply setting the random number seed in order to get reproducible results.
Alan Weiss
MATLAB mathematical toolbox documentation
Thank you again,
My trouble is that is I am getting different result namely for the first itteration of the GA compared to the other algorithm where the same initial population is used.
I tried your suggested solution and it works
with
rng(0.5)
Many thanks

请先登录,再进行评论。

更多回答(0 个)

类别

产品

版本

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by