📄 inversemutation.sci
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -