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

📄 gas_evalpopu.m

📁 基因演算法genetic algorthim的程式實現
💻 M
字号:
function [fitness, popu_real, popu] = GAs_evalpopu(popu...
                        , bit_n, ranges, fcn)
%function [fitness, popu_real, popu] = GAs_evalpopu(popu...
%                        , bit_n, ranges, fcn)
% GAs_EVALPOPU Evaluation of the population's fitness values.
%	popu: 0-1 matrix of popu_n by string_leng
%	bit_n: number of bits used to represent an input variable 
%	range: range of input variables, a var_n by 2 matrix
%	fcn: objective function (a MATLAB string)
%   For example: 
%      GAs_evalpopu([1 1 0 1;0 1 1 0],4,[-3 2], 'xfun1')
% Returned varaibles:
%   fitness is the column vector which contains the fitness 
%   function values popu is the matrix in binary string
%   popu_real is the equivalent dicimal values of binary popu
% FOR EXAMPLE:
% [fit, p_real, popu]=GAs_evalpopu(...
%    [1 1 0 1 0 1 1 0; 1 0 0 1 1 1 0 0], 4,[0 -3;2 4],@ga_fun)
% we get fit=[100.1948; 102.0919], 
%        p_real=[1.7333 -0.2000; 1.2000 2.6000],
% popu=[1 1 0 1 0 1 1 0; 1 0 0 1 1 1 0 0];

% Original writer: Roger Jang
% PenChen Chou, 6-30-2001

pop_n = size(popu, 1);     % return row size only
var_n = size(ranges,2);
fitness = zeros(pop_n, 1); % save fitness fuction value 
                           % for ecah chromosome
popu_real=zeros(pop_n,var_n);
for count = 1:pop_n,
   [fitness(count), popu_real(count,:)]=...
       GA_evaleach(popu(count,:), bit_n, ranges, fcn);
end
% Sort it
[fitness, YY]=GA_sort(fitness);
popu_real=popu_real(YY,:);
popu=popu(YY,:);

⌨️ 快捷键说明

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