要求:
(1)模型:
(2)设计变量:
(3) 约束条件:
(4) 已知条件
(5)初始化:
1.优化模型建立
由题目要求可以得到优化函数为 :
约束条件:
优化模型的输入参数:
优化模型的输出参数:
其中,为最小的飞行时间,
、
、
、
分别为最小飞行时间下的弹丸参数 。
2.优化设计方法
2.1 优化目标函数
考虑到此优化模型中的优化函数有约束条件,故采用罚函数方法构造目标函数。罚函数的构造思想是将约束优化问题转变为无约束问题来求解,在原优化函数的基础上加上惩罚项,使得在参数越界时,目标函数的值变得非常大,不会在边界外产生最小值。故此优化目标函数为:
2.2 外弹道求解模块
在外弹道求解模块中使用了铅垂平面内的质点弹道模型,气象参数使用炮兵标准气象:
其中:
重力加速度标准分布:
虚温标准分布 :
气压标准分布 :
密度标准分布 :
声速计算 :
马赫数计算 :
参数分布:
使用龙格库塔数值积分计算外弹道诸元,当飞行弧长为4000m时停止计算,输出飞行时间,并且求得最小时间。
2.3 粒子群优化模块
在多参数的优化问题中,直接求解会比较困难,而且计算量特别大,所以需要采用一些适应性和收敛性的优化方法来进行求解。目前常用的方法有坐标轮换法、模式搜索法、Powell方法和近些年来一些新兴的智能算法。本问题求解中使用的是粒子群算法,粒子群算法具有迭代格式简单,可快速收敛到最优解等特点,应用比较广泛。
粒子群算法的优势在于简单,无需梯度计算,参数少,通过事先在域中随机散布一些粒子,并将粒子赋予记忆功能,不断趋近于最优解,最终所有粒子收敛于最优解,粒子群算法的主要式子如下:
其中:
查阅相关文献,参数取值如下 :
3.优化设计的程序框图
4.优化设计的程序实现
图为该弹道优化设计的主界面图,通过程序内输入的模型及其参数进行迭代计算,可以解算出优化弹道后的最小时间以及相应值,界面内坐标轴展示的是最小时间与迭代次数的关系。可以通过多次计算来得到最终相对精确的解。
5.优化结果
通过MATLAB计算,得到最小时间与迭代次数之间的计算结果如图所示,此计算结果中迭代次数为20左右时计算结果趋于稳定,所以选择的迭代次数30是可以满足计算结果的。通过分析六次的计算结果可以得到最终最小时间收敛于3.0660s左右。
以第一次计算结果为基数,后面的计算结果所产生的误差分别为0.0727%、-0.0088%、-0.0055%、0.0248%、-0.0130%,误差相对比较小,所以最终的优化结果还是比较理想的。
7.部分代码
function varargout = untitled123(varargin)
% UNTITLED123 MATLAB code for untitled123.fig
% UNTITLED123, by itself, creates a new UNTITLED123 or raises the existing
% singleton*.
%
% H = UNTITLED123 returns the handle to a new UNTITLED123 or the handle to
% the existing singleton*.
%
% UNTITLED123('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED123.M with the given input arguments.
%
% UNTITLED123('Property','Value',...) creates a new UNTITLED123 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled123_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled123_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help untitled123
% Last Modified by GUIDE v2.5 09-Jan-2020 12:55:29
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled123_OpeningFcn, ...
'gui_OutputFcn', @untitled123_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before untitled123 is made visible.
function untitled123_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to untitled123 (see VARARGIN)
% Choose default command line output for untitled123
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled123 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled123_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%clc;clear;close all;
tic
%% 维数与粒子个数限定
m = 4; %维度
n = 25; %粒子个数
%% 范围值限定
Xlimit = [0.5,0,0,0;3,5,5,5]; %分别是m,Lambda_n,Lambda_b,Lambda_c的上下限定值
vlimit = [-0.25,-0.5,-0.5,-0.5;0.25,0.5,0.5,0.5]; %分别是m,Lambda_n,Lambda_b,Lambda_c对应粒子速度的上下限定值
%% 计算
[v,X,PYbest,PY_Xbest,GY_Xbest,GYbest] = Initial(Xlimit,vlimit,m,n); %初值初始化
[best,tbest,P] = PSO(v,X,PYbest,PY_Xbest,GY_Xbest,GYbest,Xlimit,vlimit,m,n);%粒子群计算
toc
set(handles.edit1,'string',tbest);
set(handles.edit2,'string',best(1,1));
set(handles.edit3,'string',best(1,2));
set(handles.edit4,'string',best(1,3));
set(handles.edit5,'string',best(1,4));
plot(handles.axes1,P(1,:),P(2,:));
%% 已知弹道计算
% S = [sqrt(275000 * 2 / 0.60),1.13,0,0,0];
% for j = 1:2000
% S = Runge_Kutta(S,[0.60,2.50,0.70,1.8]);
% end
% disp(S(5))
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns calle
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end