优化算法

阅读: 评论:0

优化算法

优化算法

今天为各位讲解Jaya算法,Jaya算法提出时间比较晚,比较有趣的一点是Jaya算法的提出者与教学优化算法的提出者是同一位学者:R. Venkata Rao。

各位一定非常好奇为什么叫Jaya算法?该算法努力通过达到最优解来取得胜利,因此将其命名为 Jaya(Jaya是梵文,意思是胜利)。

相比于教学优化算法的两个阶段(即教师阶段与学习阶段),Jaya算法只有一个阶段,并具有无参数运行、求解速度快、不易陷入局部最优解等优点。

目录

  • Jaya算法更新解的策略

  • Jaya算法流程图

  • Jaya算法实例验证

▎Jaya算法更新解的策略

Jaya算法的基本思想是趋近最优解,远离最差解。因此,Jaya算法更新位置的公式如下:

其中是第i次迭代过程中第k个个体的第j个变量,是第i次迭代过程中目标函数值最好个体的第j个变量,是第i次迭代过程中目标函数值最差个体的第j个变量,是 的绝对值,和是0~1之间的随机数。是更新后的值。

从上述公式可以看出,表现出是当前解向最好解靠拢的趋势,表现出是当前解远离最差解的趋势。

▎Jaya算法流程图

▎Jaya算法实例验证

实例验证函数如下,目标是求解下述函数最小值:

 

目标函数Sphere函数代码如下:

function [f] = Sphere(x)
f= sum(x.^2);
end

主函数代码如下:

%% JAYA algorithms
clc
clear all
close all%% Problem Definitionpop = 1000;               % Population size
var = 10;                 % Number of design variables
maxGen = 3000;            % Maximum number of iterations
mini = -100*ones(1,var);  % Lower Bound of Variables
maxi = 100*ones(1,var);   % Upper Bound of Variables
objective = @Sphere;      % Cost Function%% initialize
[row,var] = size(mini);
x = zeros(pop,var);
fnew = zeros(pop,1);
f = zeros(pop,1);
fopt= zeros(pop,1);
xopt=zeros(1,var);%%  Generation and Initialize the positions
for i=1:varx(:,i) = mini(i)+(maxi(i)-mini(i))*rand(pop,1);
endfor i=1:popf(i) = objective(x(i,:));
end%%  Main Loop
gen=1;
while(gen <= maxGen)[row,col]=size(x);[t,tindex]=min(f);Best=x(tindex,:);[w,windex]=max(f);worst=x(windex,:);xnew=zeros(row,col);for i=1:rowfor j=1:colxnew(i,j)=(x(i,j))+rand*(Best(j)-abs(x(i,j))) - (worst(j)-abs(x(i,j)));  %endendfor i=1:rowxnew(i,:) = max(min(xnew(i,:),maxi),mini);fnew(i,:) = objective(xnew(i,:));endfor i=1:popif(fnew(i)<f(i))x(i,:) = xnew(i,:);f(i) = fnew(i);endendfnew = []; xnew = [];[fopt(gen),ind] = min(f);xopt(gen,:)= x(ind,:);gen = gen+1;disp(['Iteration No. = ',num2str(gen), ',   Best Cost = ',num2str(min(f))])end%%[val,ind] = min(fopt);
Fes = pop*ind;
disp(['Optimum value = ',num2str(val,10)])figure(1)
plot(fopt,'linewid',2)
xlabel('Itteration')
ylabel('Best Cost');
legend('JAYA')
disp(' ' )

求解结果如下:

编辑切换为居中

添加图片注释,不超过 140 字(可选)

▎参考文献

[1]Rao R. Jaya: A simple and new optimization algorithm for solving constrained and unconstrained optimization problems[J]. International Journal of Industrial Engineering Computations, 2016, 7(1): 19-34.

咱们下期再见

▎近期你可能错过了的好文章:

新书上架 | 《MATLAB智能优化算法:从写代码到算法思想》

优化算法 | 灰狼优化算法(文末有福利)

优化算法 | 鲸鱼优化算法

遗传算法(GA)求解带时间窗的车辆路径(VRPTW)问题MATLAB代码

粒子群优化算法(PSO)求解带时间窗的车辆路径问题(VRPTW)MATLAB代码

本文发布于:2024-01-30 19:41:24,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170661488622368.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:算法
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23