?? 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 + -