fitness.m

来自「一个遗传算法编的程序,大家看看吧.有人说不能用,但我用的很好.」· M 代码 · 共 26 行

M
26
字号
function fitnessdegree = fitness(chronom)

[r, length] = size(chronom);
hide = fix(length / 7);

% load training data set
load xl.txt
% -------------------------------------------------------------------------
xl_Input = xl(:, 1:5)';
xl_Target = xl(:, 6)';
clear xl

% Normalize these data set for network training and simulation
[xl_Input_norm, ps] = mapminmax(xl_Input);
[xl_Target_norm, ts] = mapminmax(xl_Target);

% create a neural network to capture the relationship between the Input and
% the Target
net = newff(minmax(xl_Input_norm), [hide, 1], {'tansig' 'purelin'}, 'trainlm');
[Iw, Lw, b] = decode(chronom);
net.IW = Iw;
net.LW = Lw;
net.b = b;
xl_Output_norm = sim(net, xl_Input_norm);
fitnessdegree = sum((xl_Output_norm - xl_Target_norm).^2);

⌨️ 快捷键说明

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