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

📄 ga_evalpopu.m

📁 其中提到遺傳學的程式碼與應用提供給次淚相向的研究者參考下載
💻 M
字号:
function [fitness, popu_real, popu] = GA_evalpopu(popu...                        , bit_n, range, fcn)%function [fitness, popu_real, popu] = GA_evalpopu(popu...%                        , bit_n, range, fcn)% GA_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: %      GA_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]=GA_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-2001pop_n = size(popu, 1);     % return row size onlyvar_n = size(range,2);
fitness = zeros(pop_n, 1); % save fitness fuction value                            % for ecah chromosomepopu_real=zeros(pop_n,var_n);
for count = 1:pop_n,
   [fitness(count), popu_real(count,:)]=...       GA_evaleach(popu(count,:), bit_n, range, 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 + -