%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Fuzzy Model Reference Learning Control (FMRLC) System for a Tanker Ship
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% By: Kevin Passino
% Version: 4/26/01
%
% Notes: This program has evolved over time and uses programming
% ideas of Andrew Kwong, Jeff Layne, and Brian Klinehoffer.
%
% This program simulates an FMRLC for a tanker
% ship. It has a fuzzy controller with two inputs, the error
% in the ship heading (e) and the change in that error (c). The output
% of the fuzzy controller is the rudder input (delta). The FMRLC
% adjusts the fuzzy controller to try to get tanker ship heading (psi)
% to track the output of a "reference model" (psi_m) that has as an
% input the reference input heading (psi_r). We simulate the tanker
% as a continuous time system that is controlled by an FMRLC that
% is implemented on a digital computer with a sampling interval of T=1 sec.
%
% This program can be used to illustrate:
% - How to code an FMRLC (for two inputs and one output,
% for the controller and "fuzzy inverse model").
% - How to tune the input and output gains of an FMRLC.
% - How changes in plant conditions ("ballast" and "full" and speed)
% can affect performance and how the FMRLC can adapt to improve
% performance when there are such changes.
% - How the effects of sensor noise (heading sensor noise) and plant
% disturbances (wind hitting the side of the ship) can be reduced
% over the case of non-adaptive fuzzy control.
% - The shape of the nonlinearity synthesized by the FMRLC
% by plotting the input-output map of the fuzzy controller at the
% end of the simulation (and providing the output membership function
% centers).
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear % Clear all variables in memory
% Initialize ship parameters
ell=350; % Length of the ship (in meters)
abar=1; % Parameters for nonlinearity
bbar=1;
% Define the reference model (we use a first order transfer function
% k_r/(s+a_r)):
a_r=1/150;
k_r=1/150;
% Initialize parameters for the fuzzy controller
nume=11; % Number of input membership functions for the e
% universe of discourse (can change this but must also
% change some variables below if you make such a change)
numc=11; % Number of input membership functions for the c
% universe of discourse (can change this but must also
% change some variables below if you make such a change)
% Next, we define the scaling gains for tuning membership functions for
% universes of discourse for e, change in e (what we call c) and
% delta. These are g1, g2, and g0, respectively
% These can be tuned to try to improve the performance.
% First guess:
g1=1/pi;,g2=100;,g0=8*pi/18; % Chosen since:
% g1: The heading error is at most 180 deg (pi rad)
% g2: Just a guess - that ship heading will change at most
% by 0.01 rad/sec (0.57 deg/sec)
% g0: Since the rudder is constrained to move between +-80 deg
% "Good" tuned values:
g1=2/pi;,g2=250;,g0=8*pi/18;
% Next, define some parameters for the membership functions
we=0.2*(1/g1);
% we is half the width of the triangular input membership
% function bases (note that if you change g0, the base width
% will correspondingly change so that we always end
% up with uniformly distributed input membership functions)
% Note that if you change nume you will need to adjust the
% "0.2" factor if you want membership functions that
% overlap in the same way.
wc=0.2*(1/g2);
% Similar to we but for the c universe of discourse
base=0.4*g0;
% Base width of output membership fuctions of the fuzzy
% controller
% Place centers of membership functions of the fuzzy controller:
% Centers of input membership functions for the e universe of
% discourse of fuzzy controller (a vector of centers)
ce=[-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1]*(1/g1);
% Centers of input membership functions for the c universe of
% discourse of fuzzy controller (a vector of centers)
cc=[-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1]*(1/g2);
% This next matrix specifies the rules of the fuzzy controller.
% The entries are the centers of the output membership functions.
% This choice represents just one guess on how to synthesize
% the fuzzy controller. Notice the regularity
% of the pattern of rules (basiscally we are using a type of
% saturated index adding). Notice that it is scaled by g0, the
% output scaling factor, since it is a normalized rule base.
% The rule base can be tuned to try to improve performance.
% The gain gf is a gain that can be set to one to initialize
% the rule base with an initial guess at the fuzzy controller to be
% synthesized or to zero to initialize the rule base to all zeros
% (i.e., all centers at zero so the rules all say to put zero
% into the plant).
gf=1;
rules=[1 1 1 1 1 1 0.8 0.6 0.3 0.1 0;
1 1 1 1 1 0.8 0.6 0.3 0.1 0 -0.1;
1 1 1 1 0.8 0.6 0.3 0.1 0 -0.1 -0.3;
1 1 1 0.8 0.6 0.3 0.1 0 -0.1 -0.3 -0.6;
1 1 0.8 0.6 0.3 0.1 0 -0.1 -0.3 -0.6 -0.8;
1 0.8 0.6 0.3 0.1 0 -0.1 -0.3 -0.6 -0.8 -1;
0.8 0.6 0.3 0.1 0 -0.1 -0.3 -0.6 -0.8 -1 -1;
0.6 0.3 0.1 0 -0.1 -0.3 -0.6 -0.8 -1 -1 -1;
0.3 0.1 0 -0.1 -0.3 -0.6 -0.8 -1 -1 -1 -1;
0.1 0 -0.1 -0.3 -0.6 -0.8 -1 -1 -1 -1 -1;
0 -0.1 -0.3 -0.6 -0.8 -1 -1 -1 -1 -1 -1]*gf*g0;
% Next, we define some parameters for the fuzzy inverse model
gye=2/pi;,gyc=10; % Scaling gains for the error and change in error for
% the inverse model
% These are tuned to improve the performance of the FMRLC
gp=0.4;
% Scaling gain for the output of inverse model. If you let gp=0 then
% you turn off the learning mechanism and hence the FMRLC reduces to
% a direct fuzzy controller that is not tuned. Hence, from this
% program you can also see how to code a non-adaptive fuzzy controller.
% If gp is large then generally large updates will be made to the
% fuzzy controller. You should think of gp as an "adaptation gain."
numye=11; % Number of input membership functions for the ye
% universe of discourse
numyc=11; % Number of input membership functions for the yc
% universe of discourse
wye=0.2*(1/gye); % Sets the width of the membership functions for
% ye from center to extremes
wyc=0.2*(1/gyc); % Sets the width of the membership functions for
% yc from center to extremes
invbase=0.4*gp; % Sets the base of the output membership functions
% for the inverse model
% Place centers of inverse model membership functions
% For error input for learning mechanism
cye=[-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1]*(1/gye);
% For change in error input for learning mechanism
cyc=[-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1]*(1/gyc);
% The next matrix contains the rule-base matrix for the fuzzy
% inverse model. Notice that for simplicity we choose it to have
% the same structure as the rule base for the fuzzy controller.
% While this will work for the control of the tanker
% for many nonlinear systems a different structure
% will be needed for the rule base. Again, the entries are
% the centers of the output membership functions, but now for
% the fuzzy inverse model.
inverrules=[1 1 1 1 1 1 0.8 0.6 0.4 0.2 0;
1 1 1 1 1 0.8 0.6 0.4 0.2 0 -0.2;
1 1 1 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4;
1 1 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6;
1 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8;
1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1;
0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0
船舶航向的模糊控制matlab仿真
2星 需积分: 50 4 浏览量
2017-12-28
16:45:26
上传
评论 10
收藏 10KB RAR 举报
普通网友
- 粉丝: 0
- 资源: 1
最新资源
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈