%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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
普通网友
- 粉丝: 0
- 资源: 1
最新资源
- 使用群晖NAS搭建虚拟机
- 基于minifly的学习源码-本人耗时五年完善的稳定源码移植于minifly上,不带操作系统,直接操作寄存器,代码简洁明了,算法基于数学公式,便于学习数学知识
- 基于motorcad设计的外转子发电机,磁钢采用FB6B铁氧体 ,不等匝绕组,输出功率2.3KW 定子外径156 3200RPM,18极27槽永磁同步发电机(PMSG)设计案例.
- 电力电子、电机驱动、数字滤波器matlab simulink仿真模型实现及相关算法的C代码实现 配置C2000 DSP ADC DAC PWM定时器 中断等模块,提供simulink与DSP的联合仿
- 视觉系统程序,新能源电池检测 1、支持4个相机 2、实现Profinet网卡通信 3、实现日志功能 4、实现图像存储功能 5、实现电芯有无判断、电芯和端板涂胶检测
- 基于51单片机的电子时钟设计
- 西门子smart200与汇川变频器 Modbus RTU控制程序 步科触摸屏程序 振捣控制系统 汇川变频器手册
- C#上位机与西门子plc通信,实现伺服控制与数字量控制 提供C#源代码,plc测试程序
- 45.<资源>番茄钟3.0 无代码 C#例子 WPF例子
- stm32f103的Bootloader IAP串口升级stm32f103的Bootloader IAP串口升级st m32固件的学习资料,成熟产品方案已经用在批量产品上,资料包括上位机(电脑端)运行
- 基于Spark的电商用户行为分析系统-源码+课设论文(本科期末课程设计).zip
- Qt C++pdf阅读器源码 上下翻页 精美工具栏 支持ofd格式 1. 仿WPS界面 2. 预览PDF文件 3. 支持PDF预览放大,缩小 4. 支持目录预览查看 5. 支持目录点击跳转页查
- RDM(radis桌面工具)
- 西门子s7 200smart与3台台达VFD-M变频器通讯目标:用触摸屏和西门子smart 控制3台台达变频器通讯 器件:西门子s7 200 smart PLC,3台台达VFD-M变频器,昆仑通态触摸
- 基于51单片机的电子密码锁设计
- Qt5工业上位机源码 工业电子称 无线扫码器 串口的使用 Qt5.14可运行 Qt5工业上位机应用! 一套完整工程! 工业电子称使用, 无线扫码枪的使用, 串口的使用 使用Qt5.14 用QtCrea
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈