|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
呵呵,刚开始看遗传算法,有个小程序不懂,向大家请教.
function [child] = adjswapmutation(par,bounds,genInfo,Ops)
% Adjswap mutation performs a swap of two adjacent
% genes in a permutation
%
% function [newSol] = adjswapmutation(parent,bounds,Ops)
% parent - the first parent ( [solution string function value] )
% bounds - the bounds matrix for the solution space
% Ops - Options for binaryMutation [gen prob_of_mutation]
sz = size(par,2)-1;
pos = round(rand*(sz-1) + 0.5); %Generate U(1,n-1)
child = par;
child(pos:pos+1)=[par(pos+1) par(pos)];
其中pos = round(rand*(sz-1) + 0.5);是什么意思,能否解释一下.谢谢 |
|