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

📄 decode.m

📁 简单遗传算法matlab文件?虻ヒ糯惴╩atlab文件
💻 M
字号:
function Ret=Decode(LenChrom,Bound,Code,Opts)
% In this function ,it deCode chromosome 
% LenChrom   input : length of chromosome
% Opts       input : tag of coding method
% Bound      input : Boundary of varibles
% Ret        output: value of varibles
switch Opts
    case 'binary' % binary coding
        for i=length(LenChrom):-1:1
        data(i)=bitand(Code,2^LenChrom(i)-1);
        Code=(Code-data(i))/(2^LenChrom(i));
        end
        Ret=Bound(:,1)'+data./(2.^LenChrom-1).*(Bound(:,2)-Bound(:,1))';
    case 'grey'   % grey coding
        for i=sum(LenChrom):-1:2
            Code=bitset(Code,i-1,bitxor(bitget(Code,i),bitget(Code,i-1)));
        end
        for i=length(LenChrom):-1:1
        data(i)=bitand(Code,2^LenChrom(i)-1);
        Code=(Code-data(i))/(2^LenChrom(i));
        end
        Ret=Bound(:,1)'+data./(2.^LenChrom-1).*(Bound(:,2)-Bound(:,1))';
    case 'float'  % float coding
        Ret=Code;
end

⌨️ 快捷键说明

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