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

📄 select.m

📁 多智能体工具包
💻 M
字号:
function [newchrom,fitmax,IsBreak]=select(criteria,chrom)% SELECT	Select the best chromosomes for next generation based on the criteria.%     Copyright (c) 1998-2000 Jiming Liu and Jianbing Wu[pop bitlength]=size(chrom);fit=[];%calculate fitness[fit,fitot]=callfitn(criteria,chrom);  for chromnum=1:pop  sval(chromnum)=sum(fit(1,1:chromnum));end%select according to fitness by probability% Remain a most optimal population.% if change it ,the loop variable should be i=1:pop[fitmax,Pos]=max(fit);parname=Pos;for i=1:pop-1  rval=fitot*rand;  if rval<=sval(1)    parname=[parname 1];  else    for j=1:pop-1      sl=sval(j);    % Left value for comparing      su=sval(j+1);  % Right value for comparing      if (rval>sl) & (rval<=su)         parname=[parname j+1];         break;      end    end  end	endnewchrom(1:pop,:)=chrom(parname,:);IsBreak=isbreak(newchrom);

⌨️ 快捷键说明

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