|
欢迎来到本博客
目前更新: 智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真。
欢迎您的到来
CSDN主页:Matlab科研室
所有代码目录见微信公众号:天天Matlab 1 内容介绍
为准确提取轴承故障特征信息,提出以样本熵为综合目标函数的变分模态分解(variational mode decomposition,VMD)参数优化方法,并改进了诊断流程实现了无需指定参数优化范围的自适应参数优化算法.通过麻雀算法对综合目标函数最小值进行搜索,以确定模态分量个数及惩罚参数的最佳组合.原始故障信号经最佳参数组合下的VMD方法分解为若干个本征模态函数,选择最小综合目标函数值对应的模态分量进行包络解调分析,进而通过模态分量的包络谱判断轴承故障类型.通过实测故障信号分析表明,该方法能够从噪声干扰中有效提取到早期故障信号的微弱故障特征,实现了轴承故障类型的准确判定,验证了该方法的有效性.
2 仿真代码
function SSA_VMD(varargin)
SearchAgents_no = cell2mat(varargin(1));
Max_iteration = cell2mat(varargin(2));
dim = cell2mat(varargin(3));
lb = cell2mat(varargin(4));
ub = cell2mat(varargin(5));
try
imf_write = cell2mat(varargin(6));
catch
imf_write = 0;
end
t = evalin('base', 't');
s = evalin('base', 's');
fs = evalin('base', 'fs');
ST = 0.6;
PD = 0.7;
SD = 0.2;
PDNumber = round(SearchAgents_no * PD);
SDNumber = round(SearchAgents_no - SearchAgents_no * SD);
if (max(size(ub)) == 1)
ub = ub .* ones(1, dim);
lb = lb .* ones(1, dim);
end
X0 = initialization(SearchAgents_no, dim, ub, lb);
X = X0;
fitness = zeros(1, SearchAgents_no);
for i = 1:SearchAgents_no
fitness(i) = fun(X(i, :), s);
end
[fitness, index] = sort(fitness);
BestF = fitness(1);
WorstF = fitness(end);
GBestF = fitness(1);
for i = 1:SearchAgents_no
X(i, :) = X0(index(i), :);
end
Convergence_curve = zeros(Max_iteration, 1);
GBestX = X(1, :);
X_new = X;
gbest_array = zeros(Max_iteration, 2);
for i = 1:Max_iteration
BestF = fitness(1);
WorstF = fitness(end);
R2 = rand(1);
for j = 1:PDNumber
if (R2 < ST)
X_new(j, :) = X(j, :) .* exp(- j / (rand(1) * Max_iteration));
else
X_new(j, :) = X(j, :) + randn() * ones(1, dim);
end
end
for j = PDNumber + 1:SearchAgents_no
if (j > (SearchAgents_no - PDNumber) / 2 + PDNumber)
X_new(j, :) = randn() .* exp((X(end, :) - X(j, :)) / j^2);
else
A = ones(1, dim);
for a = 1:dim
if (rand() > 0.5)
A(a) =- 1;
end
end
AA = A&#39; * inv(A * A&#39;);
X_new(j, :) = X(1, :) + abs(X(j, :) - X(1, :)) .* AA&#39;;
end
end
Temp = randperm(SearchAgents_no);
SDchooseIndex = Temp(1:SDNumber);
for j = 1:SDNumber
if (fitness(SDchooseIndex(j)) > BestF)
X_new(SDchooseIndex(j), :) = X(1, :) + randn() .* abs(X(SDchooseIndex(j), :) - X(1, :));
elseif (fitness(SDchooseIndex(j)) == BestF)
K = 2 * rand( - 1;
X_new(SDchooseIndex(j), :) = X(SDchooseIndex(j), :) + K .* (abs(X(SDchooseIndex(j), :) - X(end, :)) ./ (fitness(SDchooseIndex(j)) - fitness(end) + 10^ - 8));
end
end
for j = 1:SearchAgents_no
for a = 1:dim
if (X_new(j, a) > ub(a))
X_new(j, a) = ub(a);
end
if (X_new(j, a) < lb(a))
X_new(j, a) = lb(a);
end
end
end
for j = 1:SearchAgents_no
fitness_new(j) = fun(X_new(j, :), s);
end
for j = 1:SearchAgents_no
if (fitness_new(j) < GBestF)
GBestF = fitness_new(j);
GBestX = X_new(j, :);
end
end
X = X_new;
fitness = fitness_new;
[fitness, index] = sort(fitness);
BestF = fitness(1);
WorstF = fitness(end);
for j = 1:SearchAgents_no
X(j, :) = X(index(j), :);
end
disp([&#39;current iteration is: &#39;, num2str(i), &#39;, best fitness is: &#39;, num2str(GBestF)])
gbest_array(i, :) = GBestX;
Convergence_curve(i) = GBestF;
end
Best_pos = GBestX;
flag = 1;
figure(1)
plot(Convergence_curve, &#39;k-.o&#39;, &#39;linewidth&#39;, 1)
legend(&#39;最佳适应度&#39;)
grid on
xlabel(&#39;进化代数&#39;)
ylabel(&#39;包络熵&#39;)
title(&#39;SSA进化曲线&#39;)
figure(2)
plot(gbest_array(:, 1), &#39;ks-.&#39;, &#39;linewidth&#39;, 1)
grid on
xlabel(&#39;进化代数&#39;)
ylabel(&#39;惩罚因子&#39;)
title(&#39;惩罚因子的优化过程曲线&#39;)
figure(3)
plot(round(gbest_array(:, 2)), &#39;kv-.&#39;, &#39;linewidth&#39;, 1)
grid on
xlabel(&#39;进化代数&#39;)
ylabel(&#39;分解的模态数&#39;)
title(&#39;分解模态数的优化过程曲线&#39;)
alpha = Best_pos(1);
K = round(Best_pos(2));
tau = 0;
DC = 0;
init = 1;
tol = 1e-7;
[u, u_hat, omega] = VMD(s, alpha, tau, K, DC, init, tol);
[m, ~] = size(u);
m = m + 1;
figure(4)
for i = 1:m - 1
subplot(m, 1, i)
plot(t, u(i, :), &#39;b-&#39;, &#39;linewidth&#39;, 1)
ylabel([&#39;IMF&#39;, num2str(i)]);
end
res = s&#39; - sum(u, 1);
subplot(m, 1, m)
plot(t, res, &#39;b-&#39;, &#39;linewidth&#39;, 1)
ylabel(&#39;Res&#39;);
xlabel(&#39;t/s&#39;)
figure(5)
for i = 1:m - 1
subplot(m, 1, i)
[cc, y_f] = plot_fft(u(i, :), fs, 1);
plot(y_f, cc, &#39;b&#39;, &#39;LineWIdth&#39;, 1);
ylabel([&#39;FFT of IMF&#39;, num2str(i)]);
end
subplot(m, 1, m)
[cc, y_f] = plot_fft(res, fs, 1);
plot(y_f, cc, &#39;b&#39;, &#39;LineWIdth&#39;, 1);
ylabel(&#39;FFT of Res&#39;);
xlabel(&#39;f/Hz&#39;)
fig_text(flag)
% figure(6)
%
% imshow(a. personal_id);
% title( &#39;Color&#39;, &#39;red&#39;, &#39;FontSize&#39;, 16,...
% &#39;HorizontalAlignment&#39;, &#39;center&#39;,...
% &#39;Interpreter&#39;, &#39;none&#39;)
%
% fprintf_result(Best_pos, s);
%
% if imf_write == 1
% xlswrite(&#39;imf结果.xlsx&#39;, u&#39;, &#39;u&#39;, &#39;A1&#39;);
% xlswrite(&#39;imf结果.xlsx&#39;, u_hat, &#39;uhat&#39;, &#39;A1&#39;);
% xlswrite(&#39;imf结果.xlsx&#39;, omega, &#39;omega&#39;, &#39;A1&#39;);
% end
3 运行结果
编辑
4 参考文献
[1]胡鸿志, 覃畅, 管芳,等. 基于麻雀搜索算法优化支持向量机的刀具磨损识别[J]. 科学技术与工程, 2021, 21(25):7.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
5 往期回顾扫扫下方二维码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|