带有模拟退火的 kreisselmeier steinhauser 函数

发布于 2024-10-10 17:53:37 字数 1221 浏览 6 评论 0原文

如何通过模拟退火优化来实现 Kreisselmeier Steinhauser (KS) 函数? 我的带有 KS 函数的 SA 代码如下:

while (Gen < GenMax )
while    iter > 0 %PerturbIter 
    NewZ = PerturbZ(CurZ);
    NewX = lb + (ub-lb).*(sin(NewZ)).^2;
    x0 = NewX;
    NewFitness = KS(NewX,x0);
    Delta_Cost = NewFitness - CurFitness;
    if Delta_Cost <= 0
        CurZ = NewZ; CurX = NewX;
        CurCost = NewFitness;
        if NewFitness < BestFitness
            BestZ = NewZ; BestX = NewX;
            BestFitness = NewFitness;            
        end
   else
        if rand() < exp(-Delta_Cost/T)
            CurZ = NewZ; CurX = NewX;
            CurFitness = NewFitness;
        end
    end
    iter = iter - 1;        
    %x0 = BestX;
end

figure(1), hold on
plot(Gen,BestFitness,'-md','MarkerEdgeColor','b','MarkerFaceColor','b','MarkerSize',3)
T = Cooling(T);
Gen = Gen+1;
iter = PerturbIter;    

end

KS 函数的实现如下:

function fun = ksfunc(x, x0, objfun, confun, rho)
obj = objfun(x);
[con,coneq] = confun(x);

[con0,coneq] = confun(x0);
temp = obj./objfun(x0) - 1 - max(con0);
temp = [temp; con];
fmax = max(temp);
summ = sum( exp( rho*(temp - fmax) ));

fun = fmax + log(summ)/rho;

How can I implement Kreisselmeier Steinhauser (KS) function with Simulated Annealing optimization?
My code for SA with KS func is as follows:

while (Gen < GenMax )
while    iter > 0 %PerturbIter 
    NewZ = PerturbZ(CurZ);
    NewX = lb + (ub-lb).*(sin(NewZ)).^2;
    x0 = NewX;
    NewFitness = KS(NewX,x0);
    Delta_Cost = NewFitness - CurFitness;
    if Delta_Cost <= 0
        CurZ = NewZ; CurX = NewX;
        CurCost = NewFitness;
        if NewFitness < BestFitness
            BestZ = NewZ; BestX = NewX;
            BestFitness = NewFitness;            
        end
   else
        if rand() < exp(-Delta_Cost/T)
            CurZ = NewZ; CurX = NewX;
            CurFitness = NewFitness;
        end
    end
    iter = iter - 1;        
    %x0 = BestX;
end

figure(1), hold on
plot(Gen,BestFitness,'-md','MarkerEdgeColor','b','MarkerFaceColor','b','MarkerSize',3)
T = Cooling(T);
Gen = Gen+1;
iter = PerturbIter;    

end

The KS function is implemented as followed:

function fun = ksfunc(x, x0, objfun, confun, rho)
obj = objfun(x);
[con,coneq] = confun(x);

[con0,coneq] = confun(x0);
temp = obj./objfun(x0) - 1 - max(con0);
temp = [temp; con];
fmax = max(temp);
summ = sum( exp( rho*(temp - fmax) ));

fun = fmax + log(summ)/rho;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文