👨🎓个人主页:研学社的博客
💥💥💞💞欢迎来到本博客❤️❤️💥💥
🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。
⛳️座右铭:行百里者,半于九十。
📋📋📋本文目录如下:🎁🎁🎁
目录
💥1 概述
在本文中,讲解了如何使用遗传算法来查找电路中符合我们设计标准的电阻和热敏电阻的值。该示例使用优化技术来最小化所需响应曲线与电路仿真生成的曲线之间的差异。由于电阻器和热敏电阻仅提供标准尺寸,因此由于此设计变量仅限于这些标准尺寸,因此这成为一个相互约束的问题。
📚2 运行结果
部分代码:
optchanged = false;
switch flag
case 'init'
figure('Position',[40 535 800 520],'Tag','tempCurve');
set(gca,'Tag','ax1');
set(gca,'YLim',[0.1 0.2]);
grid on;
hold on;
plot(Tdata,VData,'-*b');
xlabel('Temperature (^oC)');
ylabel('Voltage (V)');
title('Thermistor Network Temperature Curve','FontSize',12);
[~,loc] = min(state.Score); % Find location of best
bestV = voltageCurve(Tdata,state.Population(loc,:),Res,ThVal,ThBeta);
plotBest = plot(Tdata,bestV,'-or');
set(plotBest,'Tag','bestVLine'); % Update voltage curve
legend('Ideal Curve','GA Solution','Location','southeast');
drawnow;
case 'iter'
fig = findobj(0,'Tag','tempCurve');
figure(fig(end));
[~,loc] = min(state.Score); % Find location of best
bestV = voltageCurve(Tdata,state.Population(loc,:),Res,ThVal,ThBeta);
ax1 = findobj(get(gcf,'Children'),'Tag','ax1');
plotBest = findobj(get(ax1,'Children'),'Tag','bestVLine');
set(plotBest, 'Ydata', bestV); % Update voltage curve
drawnow;
case 'done'
fig = findobj(0,'Tag','tempCurve');
figure(fig(end));
[~,loc] = min(state.Score);
xOpt = state.Population(loc,:);
s{1} = sprintf('Optimal solution found by Mixed Integer GA solver: \n');
s{2} = sprintf('R1 = %6.0f ohms \n', Res(xOpt(1)));
s{3} = sprintf('R2 = %6.0f ohms \n', Res(xOpt(2)));
s{4} = sprintf('R3 = %6.0f ohms \n', Res(xOpt(3)));
s{5} = sprintf('R4 = %6.0f ohms \n', Res(xOpt(4)));
s{6} = sprintf('TH1 = %6.0f ohms, %6.0f beta \n', ...
ThVal(xOpt(5)), ThBeta(xOpt(5)));
s{7} = sprintf('TH2 = %6.0f ohms, %6.0f beta \n', ...
ThVal(xOpt(6)), ThBeta(xOpt(6)));
% Display the text in "s" in an annotation object on the
% temperature curve figure. The four-element vector is used to
% specify the location.
annotation(gcf, 'textbox', [0.15 0.45 0.22 0.45], 'String', s,...
'BackGroundColor','w','FontSize',8);
hold off;
end
🎉3 参考文献
部分理论来源于网络,如有侵权请联系删除。
[1]雷阳.基于混合整数遗传算法的输油管道泄漏定位研究[J].电子技术与软件工程,2015(09):184-185.
[2]Seth DeLand (2022). Optimal Component Selection Using the Mixed-Integer Genetic Algorithm.