% MIGRATE.M (MIGRATion of individuals between subpopulations)
%
% This function performs migration of individuals.
%
% Syntax: [Chrom, ObjV] = migrate(Chrom, SUBPOP, MigOpt, ObjV)
%
% Input parameters:
% Chrom - Matrix containing the individuals of the current
% population. Each row corresponds to one individual.
% SUBPOP - Number of subpopulations
% MigOpt - (optional) Vector containing migration parameters
% MigOpt(1): MIGR - Rate of individuals to be migrated per
% subpopulation (% of subpopulation)
% if omitted or NaN, 0.2 (20%) is assumed
% MigOpt(2): Select - number indicating the selection method
% of replacing individuals
% 0 - uniform selection
% 1 - fitness-based selection (replace worst
% individuals)
% if omitted or NaN, 0 is assumed
% MigOpt(3): Structure - number indicating the structure
% of the subpopulations for migration
% 0 - net structure (unconstrained migration)
% 1 - neighbourhood structure
% 2 - ring structure
% if omitted or NaN, 0 is assumed
% ObjV - (optional) Column vector containing the objective values
% of the individuals in the current population, needed for
% fitness-based migration, this saves the
% recalculation of objective values for population.
%
% Output parameters:
% Chrom - Matrix containing the individuals of the current
% population after migration.
% ObjV - if ObjV is input parameter, than column vector containing
% the objective values of the individuals of the current
% generation after migration.
%
% Author: Hartmut Pohlheim
% History: 16.02.94 file created
% 18.02.94 comments at the beginning added
% exchange of ObjV too
% 25.02.94 clean up
% 26.02.94 ObjV optional input parameter
% Select and Structure added, parameter reordered
% 17.03.94 renamed to migrate.m, more parameter checks
% 20.01.03 tested under MATLAB v6 by Alex Shenfield
function [Chrom, ObjV] = migrate(Chrom, SUBPOP, MigOpt, ObjV);
% Check parameter consistency
if nargin < 2, error('Input parameter SUBPOP missing'); end
if (nargout == 2 & nargin < 4), error('Input parameter ObjV missing'); end
[Nind, Nvar] = size(Chrom);
if length(SUBPOP) ~= 1, error('SUBPOP must be a scalar'); end
if SUBPOP == 1, return; end
if (Nind/SUBPOP) ~= fix(Nind/SUBPOP), error('Chrom and SUBPOP disagree'); end
NIND = Nind/SUBPOP; % Compute number of individuals per subpopulation
if nargin > 3,
[mO, nO] = size(ObjV);
if nO ~= 1, error('ObjV must be a column vector'); end
if Nind ~= mO, error('Chrom and ObjV disagree'); end
IsObjV = 1;
else IsObjV = 0; ObjV = [];
end
if nargin < 3, MIGR = 0.2; Select = 0; Structure = 0; end
if nargin > 2,
if isempty(MigOpt), MIGR = 0.2; Select = 0; Structure = 0;
elseif isnan(MigOpt), MIGR = 0.2; Select = 0; Structure = 0;
else
MIGR = NaN; Select = NaN; Structure = NaN;
if length(MigOpt) > 3, error('Parameter MigOpt is too long'); end
if length(MigOpt) >= 1, MIGR = MigOpt(1); end
if length(MigOpt) >= 2, Select = MigOpt(2); end
if length(MigOpt) >= 3, Structure = MigOpt(3); end
if isnan(MIGR), MIGR =0.2; end
if isnan(Select), Select = 0; end
if isnan(Structure), Structure = 0; end
end
end
if (MIGR < 0 | MIGR > 1), error('Parameter for migration rate must be a scalar in [0 1]'); end
if (Select ~= 0 & Select ~= 1), error('Parameter for selection method must be 0 or 1'); end
if (Structure < 0 | Structure > 2), error ('Parameter for structure must be 0, 1 or 2'); end
if (Select == 1 & IsObjV == 0), error('ObjV for fitness-based migration needed');end
if MIGR == 0, return; end
MigTeil = max(floor(NIND * MIGR), 1); % Number of individuals to migrate
% Perform migration between subpopulations --> create a matrix for migration
% in every subpopulation from best individuals of the other subpopulations
% Clear storing matrices
ChromMigAll = [];
if IsObjV == 1, ObjVAll = []; end
% Create matrix with best/uniform individuals of all subpopulations
for irun = 1:SUBPOP
% sort ObjV of actual subpopulation
if Select == 1, % fitness-based selection
[Dummy, IndMigSo]=sort(ObjV((irun-1)*NIND+1:irun*NIND));
else % if Select == 0 % uniform selection
[Dummy, IndMigSo]=sort(rand(NIND, 1));
end
% take MigTeil (best) individuals, copy individuals and objective values
IndMigTeil=IndMigSo(1:MigTeil)+(irun-1)*NIND;
ChromMigAll = [ChromMigAll; Chrom(IndMigTeil,:)];
if IsObjV == 1, ObjVAll = [ObjVAll; ObjV(IndMigTeil,:)]; end
end
% perform migration
for irun = 1:SUBPOP
ChromMig = ChromMigAll;
if IsObjV == 1, ObjVMig = ObjVAll; end
if Structure == 1, % neighbourhood
% select individuals of neighbourhood subpopulations for ChromMig and ObjVMig
popnum = [SUBPOP 1:SUBPOP 1];
ins1 = popnum(irun); ins2 = popnum(irun + 2);
InsRows = [(ins1-1)*MigTeil+1:ins1*MigTeil (ins2-1)*MigTeil+1:ins2*MigTeil];
ChromMig = ChromMig(InsRows,:);
if IsObjV == 1, ObjVMig = ObjVMig(InsRows,:); end
elseif Structure == 2, % ring
% select individuals of actual-1 subpopulation for ChromMig and ObjVMig
popnum = [SUBPOP 1:SUBPOP 1];
ins1 = popnum(irun);
InsRows = (ins1-1)*MigTeil+1:ins1*MigTeil;
ChromMig = ChromMig(InsRows,:);
if IsObjV == 1, ObjVMig = ObjVMig(InsRows,:); end
else % if Structure == 0, % complete net
% delete individuals of actual subpopulation from ChromMig and ObjVMig
DelRows = (irun-1)*MigTeil+1:irun*MigTeil;
ChromMig(DelRows,:) = [];
if IsObjV == 1, ObjVMig(DelRows,:) = []; end
end
% Create an index from a sorted vector with random numbers
[Dummy,IndMigRa]=sort(rand(size(ChromMig,1),1));
% Take MigTeil numbers from the random vector
IndMigN=IndMigRa((1:MigTeil)');
% copy MigTeil individuals into Chrom and ObjV
Chrom((1:MigTeil)+(irun-1)*NIND,:) = ChromMig(IndMigN,:);
if IsObjV == 1, ObjV((1:MigTeil)+(irun-1)*NIND,:) = ObjVMig(IndMigN,:); end
end
% End of function
没有合适的资源?快使用搜索试试~ 我知道了~
(matlab代码)地铁列车节能优化曲线(遗传算法GA)(惰行控制).zip
共76个文件
m:72个
ps:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 5 下载量 84 浏览量
2022-05-03
18:19:23
上传
评论 14
收藏 242KB ZIP 举报
温馨提示
地铁列车节能优化曲线(遗传算法GA)(惰行控制).zip 注意事项: 1、程序是在matlab2013b环境下编写的,在之前版本中不知可否正常运行。 2、如果matlab没有遗传算法工具箱,需要将genetic放到根目录的toolbox的 文件夹中,然后设置路径。 3、需要保存程序的输出时,文件的目录需要更改。 遗传算法工具箱实现地铁牵引能耗的优化
资源推荐
资源详情
资源评论
收起资源包目录
地铁列车节能优化曲线(遗传算法GA)(惰行控制).zip (76个子文件)
地铁列车节能优化曲线(遗传算法GA)(惰行控制)
main.m 36B
genetic
sga.m 2KB
Test_fns
sga.m 2KB
objlinq.m 3KB
objfun7.m 2KB
resplot.m 2KB
objdopi.m 4KB
demoga1.m 5KB
objsixh.m 3KB
objbran.m 3KB
objfun8.m 3KB
simlinq2.m 850B
simobjp.m 531B
simlinq1.m 2KB
simdopi2.m 873B
objfun1b.m 2KB
simdopi1.m 3KB
objgold.m 3KB
objfun1a.m 3KB
objeaso.m 2KB
objfun6.m 3KB
objpush.m 3KB
objlinq2.m 4KB
objfun9.m 2KB
objharv.m 3KB
mpga.m 5KB
objfun1.m 3KB
objfun2.m 3KB
TEST_FNS.PS 138KB
reclin.m 2KB
resplot.m 2KB
xovsprs.m 1KB
xovsp.m 1KB
contents.m 2KB
xovdprs.m 1KB
recdis.m 2KB
xovmp.m 3KB
DOC
GATBXA0.PS 52KB
GATBXA2.PS 196KB
GATBXA1.PS 199KB
recombin.m 3KB
bs2rv.m 3KB
recmut.m 5KB
xovshrs.m 1KB
crtrp.m 2KB
migrate.m 7KB
sus.m 1KB
mutbga.m 5KB
crtbp.m 2KB
reins.m 6KB
rws.m 1KB
xovdp.m 1KB
select.m 2KB
recint.m 2KB
ranking.m 5KB
xovsh.m 1KB
objharv.m 3KB
crtbase.m 1KB
rep.m 1KB
mpga.m 4KB
mut.m 2KB
objfun1.m 3KB
scaling.m 1KB
mutate.m 3KB
coastcontrol
chromsort.m 505B
arginitial.m 1KB
getcurvat.m 457B
testchrom.m 1KB
getgradient.m 336B
etjcalc.m 2KB
objv.m 1KB
getspeedlim.m 381B
genemain.m 4KB
etjarray.m 293B
calcacc.m 3KB
veloprof.m 2KB
共 76 条
- 1
资源存储库
- 粉丝: 4503
- 资源: 392
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页