⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gradmution1.asv

📁 自适应变步长定向变异遗传算法解函数优化问题 需要调用GAOT5.
💻 ASV
字号:
function [parent]=gradmution1(parent,bounds,Ops)
%directional mutation
%function [newSol]=
%
%
%
%

cg = Ops(1);  %Current Generation
mg=Ops(3);    %
b=Ops(4);     %
df =  bounds(:,2)-bounds(:,1);
numVar = size(parent,2)-1;

child = zeros(1,numVar+1);
child = parent;
delt = df./30;
r1 = rand;
step = sqrt(delt.^2.*(2*log(1/r1)));

%
for mPoint=1:numVar
    md = round(rand); %
    if md
        newValue=parent(mPoint)+step(mPoint);
        positive=1;
        if newValue>bounds(mPoints,2);
            newValue = bounds(mPoints,2);
        end
    else
        newValue = parent(mPoint)-step(mPoint);
        if newValue<bounds(mPoints,2);
            newValue = bounds(mPoints,1);
        end
        positive = -1;
    end
    child(mPoint) = newValue;
    [child(1:numVar) chlid(3)]=feval('function1',child(1:numVar),[]);
    
    p1=.0001;
    if child(3)<=parent(3)
        if p1>rand
            parent=child
        end
    else
        while child(3)>parent(3)
            parent=child;
            y1=child(mPoint);
            y1=y1+positive*step(mPoint);
            if bounds(mPoint,1)>y1 y1=bounds(mPoint,1); end
            if bounds(mPoint,2)<y1 y1=bounds(mPoint,2); end
            child(mPoint)=y1;
            [child(1:numVar) child(3)]=feval('function1',child(1:numVar),[]);
        end
        %
        while child(3)<=parent(3)
            step = step/2;
            if step<0.000005 child=parent; break; end
            if (parent(mPoint)==bounds(mPoint,1)&positive==-1)|(parent(mPoint)==bounds(mPoint,2)&positive==1)
                child=parent;
                break;
            end
            child(mPoint)=parent(mPoint)+positive*step(mPoint);
            if bounds(mPoint,1)>child(mPoint)
                child(mPoint)=bounds(mPoint,1);
            end
            if boun
    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -