-
function [pop] = initializega(num, bounds,
evalFN,evalOps,options)
%
function
[pop]=initializega(populationSize,
variableBounds,evalFN,evalOps,options)
%
initializega
creates a matrix of random numbers with
%
a number of rows equal to
the populationSize and a number
%
columns equal to the
number of rows in bounds plus 1 for
%
the f(x) value which is
found by applying the evalFN.
%
This is used by the ga to
create the population if it
%
is not supplied.
%
% pop
- the
initial, evaluated, random population
% populatoinSize - the size of the
population, i.e. the number to create
%
variableBounds - a matrix which contains the
bounds of each variable, i.e.
%
[var1_high
var1_low; var2_high var2_low; ....]
%
% evalFN
- the evaluation fn, usually the name
of the .m file for
%
evaluation
%
% evalOps
- any options to be passed to the eval function
defaults []
%
% options
- options to the
initialize function, ie.
%
[type
prec] where eps is the epsilon value
%
and the
second option is 1 for float and 0 for binary,
%
prec is the precision of the variables
defaults [1e-6 1]
if
nargin<5
options=[1e-6 1];
end
if nargin<4
evalOps=[];
end
if any(evalFN<48) %Not a .m file
if options(2)==1 %Float GA
estr=['x=pop(i,1);
pop(i,xZomeLength)=', evalFN ';'];
else %Binary GA
estr=['x=b2f(pop(i,:),bounds,bits);
pop(i,xZomeLength)=', evalFN ';'];
end
else %A .m file
if
options(2)==1 %Float GA
estr=['[ pop(i,:) pop(i,xZomeLength)]='
evalFN '(pop(i,:),[0 evalOps]);'];
else %Binary GA
estr=['x=b2f(pop(i,:),bounds,bits);[x
v]=' evalFN ...
'(x,[0
evalOps]); pop(i,:)=[f2b(x,bounds,bits) v];'];
end
-
-
-
-
-
-
-
-
-
上一篇:DevExpress控件使用大全
下一篇:德英文键盘转换