带有模拟退火的 kreisselmeier steinhauser 函数
如何通过模拟退火优化来实现 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论