inversemutation.sci
来自「基于SCILAB的The Genetic Algorithm Toolbox f」· SCI 代码 · 共 28 行
SCI
28 行
function [p]= OInverseMutation(p1,bounds,Ops)
// function [c1,c2] = singlePtXover(p1,p2,bounds,Ops)
// p1 - the first parent ( [solution string function value] )
// bounds - the bounds matrix for the solution space
// Ops - Options matrix for simple crossover [gen #SimpXovers].
rng = (bounds(:,2)-bounds(:,1))'; // The variable ranges'
numArranges = rng + 1; // Number of each arrages
cumArranges = cumsum([0 numArranges]);
xZomeLength = sum(numArranges)+1; // Length of string is numVar + fit
p=p1;
for i= 1:size(numArranges,2)
sz=numArranges(i);
pfrom=(cumArranges(i)+1);
pto=cumArranges(i+1);
cut1 = floor(rand*sz); // Generate random cut point U(0,n-1)
cut2 = floor(rand*sz); // Generate random cut point U(0,n-1)
if ~(cut1==cut2)
if (cut1>cut2)
temp=cut2;
cut2=cut1;
cut1=temp;
end
c=p1((pfrom+cut1):(pfrom+cut2));
p((pfrom+cut1):(pfrom+cut2))=c(cut2-cut1+1:-1:1);
end
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?