⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 initializega.m

📁 利用matlba编写的遗传算法工具箱
💻 M
字号:
function [pop] = initializega(num, bounds, evalFN,evalOps,options)if nargin<5  options=[1e-6 1];endif nargin<4  evalOps=[];endif any(evalFN<48)   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 ';'];   endelse %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];'];      endendnumVars     = size(bounds,1); 		%Number of variablesrng         = (bounds(:,2)-bounds(:,1))'; %The variable ranges'if options(2)==1 %Float GA  xZomeLength = numVars+1; 		%Length of string is numVar + fit  pop         = zeros(num,xZomeLength); 	%Allocate the new population  pop(:,1:numVars)=(ones(num,1)*rng).*(rand(num,numVars))+...    (ones(num,1)*bounds(:,1)');else %Binary GA  bits=calcbits(bounds,options(1));  xZomeLength = sum(bits)+1; 		%Length of string is numVar + fit  pop = round(rand(num,sum(bits)+1));end% load Data_Gaot  EndPop        % pop=EndPop;for i=1:num  eval(estr);end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -