gadecode.m

来自「修改自wiley的书中的各种遗传算法(GA)matlab代码」· M 代码 · 共 23 行

M
23
字号

%PROGRAM 2: CONVERTS BINARY CHROMOSOME TO CONTINUOUS VARIABLES
% gadecode.m
% Decodes binary encripted parameters
%
% f=gadecode(chrom,lo,hi,bits,gray)
% chrom = population
% lo = minimum parameter value
% hi = maximum parameter value
% bits = number of bits/parameter
% Haupt & Haupt
% 2003
function f=gadecode(chrom,lo,hi,bits)
[M,N]=size(chrom);
npar=N/bits; % number of variables
quant=(0.5.^[1:bits]'); % quantization levels
quant=quant/sum(quant); % quantization levels normalized
ct=reshape(chrom',bits,npar*M)';% each column contains
% one variable
par=((ct*quant)*(hi-lo)+lo); % DA conversion and
% unnormalize varaibles
f=reshape(par,npar,M)'; % reassemble population

⌨️ 快捷键说明

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