Clear Filters
Clear Filters

Genetic algorithm initial popuplation

2 views (last 30 days)
dimitris
dimitris on 3 Mar 2013
I use GA to minimize an objective function with 20 variables. I noticed that ga always produces initial population with small distance between individuals, usually at [0,1] while lower bound is 0 and upper bound is 90. I would like ga to produce the initial population more uniformly. Is this possible? My code:
n=20;
A=zeros(n,n); %linear constraint x1<=x2<=x3<=x4<=...<=x20
b=zeros(n,1);
for i = 1:n
for j = 1:n
if(i+j==n+1)
A(i,j)=-1;
end
if(i+j==n)
A(i,j)=1;
end
end
end
b(n)=90;
LB=zeros(n,1);
UB=90*ones(n,1);
options=gaoptimset('creationfcn',@gacreationuniform,'PlotFcns',{@gaplotbestf,@gaplotscores,@gaplotbestindiv,@gaplotdistance},'Display','iter');
[x,fval,exitflag,output,final_pop]=ga(@(x) obj(x),n,A,b,[],[],LB,UB,[],options)

Answers (2)

Matt J
Matt J on 3 Mar 2013
use gaoptimset to control the Population options as you please

Alan Weiss
Alan Weiss on 4 Mar 2013
I believe you need to set your PopInitRange option. See this example.
Alan Weiss
MATLAB mathematical toolbox documentation

Community Treasure Hunt

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

Start Hunting!