?? c62.m
字號:
function [pop] = initializega(num, bounds, eevalFN,eevalOps,options)
if nargin<5
options=[1e-6 1];
end
if nargin<4
eevalOps=[];
end
if options(2)==1 %浮點編碼
estr=['[ pop(i,:) pop(i,xZomeLength)]=' eevalFN '(pop(i,:),[0 eevalOps]);'];
else %二進制編碼
estr=['x=b2f(pop(i,:),bounds,bits);[x v]=' eevalFN(x,[0 eevalOps]);
pop(i,:)=[f2b(x,bounds,bits) v];'];
end
end
numVars = size(bounds,1); %變量的數目
rng= (bounds(:,2)-bounds(:,1))'; %變量邊界
if options(2)==1
xZomeLength = numVars+1;
pop= zeros(num,xZomeLength);
pop(:,1:numVars)=(ones(num,1)*rng).*(rand(num,numVars))+ (ones(num,1)*bounds(:,1)');
else
bits=calcbits(bounds,options(1));
xZomeLength = sum(bits)+1;
pop = round(rand(num,sum(bits)+1));
end
for i=1:num
eeval(estr);
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -