bstr2rval.m
来自「基本遗传算法的matlab源程序」· M 代码 · 共 28 行
M
28 行
function indiv=bstr2rval(geneCode,genek_bitnum,bounds)
% decoding the binary gene string to the actual value
% syntax:indiv=bstr2rval(geneCode,genek_bitnum,bounds)
%
% Output Arguments:
% indiv ---- a matrix of all individual in form of actual value
% Input Arguments:
% geneCode ---- a matrix of chromosome codes
% genek_bitnum ---- length of gene string
% bounds ---- a matrix of upper and lower bounds on the variables
%
% Author:Yan Anxin
% ID number:081810
% Date:finished on 2008.11.29
% Yax235 DreamWorks, SEE, SEU, 2# Sipailou Nanjing, 210096, P.R.China
[sizePop,]=size(geneCode);varNum=length(genek_bitnum);
indiv=zeros();
for ik=1:sizePop
genePor=geneCode(ik,:);porNum=1;
for jk=1:varNum
bou=bounds(jk,:);a=bou(1);b=bou(2);
geneStr=genePor(porNum:(porNum+genek_bitnum(jk)-1));
porNum=porNum+genek_bitnum(jk);
rval=bin2dec(geneStr);
indiv(ik,jk)=a+(b-a)*rval/(2^(genek_bitnum(jk))-1);
end
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?