资源简介
用于matlab的万有引力搜索算法 考虑了粒子质量和速度 并对其进行适度函数分析
代码片段和文件信息
% Gravitational Search Algorithm.
function [FbestLbestBestChartMeanChart]=GSA(F_indexNmax_itElitistCheckmin_flagRpower)
%V: Velocity.
%a: Acceleration.
%M: Mass. Ma=Mp=Mi=M;
%dim: Dimension of the test function.
%N: Number of agents.
%X: Position of agents. dim-by-N matrix.
%R: Distance between agents in search space.
%[low-up]: Allowable range for search space.
%Rnorm: Norm in eq.8.
%Rpower: Power of R in eq.7.
Rnorm=2;
%get allowable range and dimension of the test function.
function [downupdim]=test_functions_range(F_index)
[lowupdim]=test_functions_range(F_index);
%random initialization for agents.
X=initialization(dimNuplow);
%create the best so far chart and average fitnesses chart.
BestChart=[];MeanChart=[];
V=zeros(Ndim);
for iteration=1:max_it
% iteration
%Checking allowable range.
X=space_bound(Xuplow);
%Evaluation of agents.
fitness=evaluateF(XF_index);
if min_flag==1
[best best_X]=min(fitness); %minimization.
else
[best best_X]=max(fitness); %maximization.
end
if iteration==1
Fbest=best;Lbest=X(best_X:);
end
if min_flag==1
if best Fbest=best;Lbest=X(best_X:);
end
else
if best>Fbest %maximization
Fbest=best;Lbest=X(best_X:);
end
end
BestChart=[BestChart Fbest];
MeanChart=[MeanChart mean(fitness)];
%Calculation of M. eq.14-20
[M]=massCalculation(fitnessmin_flag);
%Calculation of Gravitational constant. eq.13.
G=Gconstant(iterationmax_it);
%Calculation of accelaration in gravitational field. eq.7-1021.
a=Gfield(MXGRnormRpowerElitistCheckiterationmax_it);
%Agent movement. eq.11-12
[XV]=move(XaV);
end %iteration
% This function gives boundaries and dimension of search space for test functions.
function [downupdim]=test_functions_range(F_index)
%If lower bounds of dimensions are the same then ‘down‘ is a value.
%Otherwise ‘down‘ is a vector that shows the lower bound of each dimension.
%This is also true for upper bounds of dimensions.
%Insert your own boundaries with a new F_index.
dim=30;
if F_index==1
down=-100;up=100;
end
if F_index==2
down=-10;up=10;
end
if F_index==3
down=-100;up=100;
end
if F_index==4
down=-100;up=100;
end
if F_index==5
down=-30;up=30;
end
if F_index==6
down=-100;up=100;
end
if F_index==7
down=-1.28;up=1.28;
end
if F_index==8
down=-500;up=500;
end
if F_index==9
down=-5.12;up=5.12;
end
if F_index==10
down=-32;up=32;
end
if F_index==11
down=-600;up=600;
end
if F_index==12
down=-50;up=50;
end
if F_index==13
down=-50;up=50;
end
if F_index==14
down=-65.536;up=65.536;dim=2;
end
if F_index==15
down=-5;up=5;dim=4;
end
if F_index==16
down=-5;up=5;dim=2;
end
if F_in
相关资源
- BP神经网络解决手写数字识别问题 m
- 数字识别matlab源代码
- Split bregman 算法MATLAB源代码
- 字符识别matlab源代码
- 图像超分辨重建MATLAB源代码迭代步长
- 深度学习和matlab源代码
- MATLAB43案例
- RMSHE的MATLAB源代码
- 纹理图像分割Matlab源代码 PDF PPT
- Random Walk Model Matlab源代码
- 贝叶斯网络Matlab源代码
- Vibe背景建模的方法检测运动物体mat
- 贝叶斯压缩感知matlab源代码
- 指纹识别系统matlab源代码
- 基于颜色的图像检索 matlab源代码
- 系统辨识理论及Matlab仿真-刘金琨 [程
- 人工神经网络原理及仿真书及 matlab源
- 数字信号处理实验报告内含matlab源代
- PID控制MATLAB仿真第2版含MATLAB源代码
- 图像处理-边缘检测和特征提取MATLAB源
- RSIHE的MATLAB源代码
- 贪婪算法和最小路径算法解决TSP问题
- MATLAB智能算法30个案例分析第2版源代
- Duda《模式分类》第二版的Matlab源代码
- 粒子图像测速PIVMatlab源代码
- 二维LDA的matlab源代码
- 图象纹理分割matlab源代码
- 引导滤波matlab源代码
- 配套光盘:现代信号处理教程-胡广书
- 强化学习matlab源代码289697
评论
共有 条评论