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

📄 decode.m

📁 王小平《遗传算法——理论、应用与软件实现》随书光盘
💻 M
字号:
function [out,desc,bits]=decode(bin,description,action);
%
% Decode a number of parameters from a binary
% sequence, using a description vector.
%
% Useage:
%
%	[Decoded_parameters,desc,bits]=decode(binary,description,action);
%
% Description:
%
%	[Min	Res	Max]
%
% If action is specified as = 0, then no decoding takes
% place, the routine just ascertains the size of the
% binary vector.
%

%
% Determine the number of parameters
%
[num_parm L]=size(description);

%
% Determine the number of bits required for each
% parameter
%
pointer=0;
for i = 1 : num_parm
	N=(description(i,3)-description(i,1))/description(i,2);
	bits(i,1)=ceil(log(N)/log(2));
	%
	% The resolution has now changed.
	% Update the description vector.
	%
	description(i,2)=(N*description(i,2))/(2^bits(i,1));

	%
	% Now extract the relevant number of bits from the
	% input chromasome
	%
	if action ~= 0
		[D L]=size(bin);
		chrom=bin(1,1:bits(i,1));
		bin=bin(1,bits(i,1)+1:L);
		out(1,i)=unbin(chrom,bits(i,1));
		out(1,i)=(out(1,i)*description(i,2))+description(i,1);
	end
end
desc=description;


⌨️ 快捷键说明

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