模糊语意变数、规则和模糊运算--AForge.NET框架的使用(二)
原文:模糊语意变数、规则和模糊运算--AForge.NET框架的使用(二)
语意变数(Linguistic Variable)
语意变数存储了数个语意量(标签),每个语意量包含一个识别名和模糊集合。在宣告陈述时每个语意量只能和在同一变数中的语意比较。
举个很简单的例子,我们有一个名为temperature的语意变数,它包含4个语意量,名为cold、cool、warm、hot,这也是各自的标签名,同时它们还有各自的隶属度函数。
那么我们就在接下来的系统中使用诸如temperature is hot或者temperature is not hot等等了。
//语意变数的声明
LinguisticVariable lvTemperature = new LinguisticVariable("Temperature", , ); //模糊集合和隶属度函数
TrapezoidalFunction function1 = new TrapezoidalFunction(, , TrapezoidalFunction.EdgeType.Right);
FuzzySet fsCold = new FuzzySet("Cold", function1);
TrapezoidalFunction function2 = new TrapezoidalFunction(, , , );
FuzzySet fsCool = new FuzzySet("Cool", function2);
TrapezoidalFunction function3 = new TrapezoidalFunction(, , , );
FuzzySet fsWarm = new FuzzySet("Warm", function3);
TrapezoidalFunction function4 = new TrapezoidalFunction(, , TrapezoidalFunction.EdgeType.Left);
FuzzySet fsHot = new FuzzySet("Hot", function4); //添加标签
lvTemperature.AddLabel(fsCold);
lvTemperature.AddLabel(fsCool);
lvTemperature.AddLabel(fsWarm);
lvTemperature.AddLabel(fsHot); //获取隶属度
Console.WriteLine("Input; Cold; Cool; Warm; Hot");
for (float x = ; x < ; x += 1f)
{
float y1 = lvTemperature.GetLabelMembership("Cold", x);
float y2 = lvTemperature.GetLabelMembership("Cool", x);
float y3 = lvTemperature.GetLabelMembership("Warm", x);
float y4 = lvTemperature.GetLabelMembership("Hot", x); Console.WriteLine(String.Format("{0:N}; {1:N}; {2:N}; {3:N}; {4:N}",x, y1, y2, y3, y4));
}

模糊规则(Fuzzy Rule)与数据库(Fuzzy Database)
在拥有语意变数后,我们就创建表述(Statement),它是一种表达,可以做成判断,比如什么是什么,什么不是什么。
而规则(Rule)是可以被模糊系统执行的语意指令。如什么是什么时,就怎么。最简单的就是这种:
IF antecedent THEN consequent
前提(antecedent )一般由多个由模糊运算符连接的子句组成。如:
...Clause1 AND (Clause2 OR Clause3) AND NOT Clause4 ...
结果(consequent)一般由赋值子句组成,这里的赋值不光是Variable1 IS Value1,Variable1 IS Not Value1同样支持。
举个例子,再创建一个语意变数,Wind,标签有Strong、Breeze、Airless。
那么一下规则就是有效的:
IF Wind IS Strong THEN Temperature IS Cold IF Wind IS AirlessTHEN Temperature IS NOT Cold
数据库(Fuzzy Database)是一个包含语意变数和相应规则的资料集合,它可以被模糊推理系统(Fuzzy Inference System)使用。
//语意变数的声明
LinguisticVariable lvTemperature = new LinguisticVariable("Temperature", , ); //模糊集合和隶属度函数
TrapezoidalFunction function1 = new TrapezoidalFunction(, , TrapezoidalFunction.EdgeType.Right);
FuzzySet fsCold = new FuzzySet("Cold", function1);
TrapezoidalFunction function2 = new TrapezoidalFunction(, , , );
FuzzySet fsCool = new FuzzySet("Cool", function2);
TrapezoidalFunction function3 = new TrapezoidalFunction(, , , );
FuzzySet fsWarm = new FuzzySet("Warm", function3);
TrapezoidalFunction function4 = new TrapezoidalFunction(, , TrapezoidalFunction.EdgeType.Left);
FuzzySet fsHot = new FuzzySet("Hot", function4); //添加标签
lvTemperature.AddLabel(fsCold);
lvTemperature.AddLabel(fsCool);
lvTemperature.AddLabel(fsWarm);
lvTemperature.AddLabel(fsHot); //语意变数的声明
LinguisticVariable lvWind = new LinguisticVariable("Wind", , ); //模糊集合和隶属度函数
TrapezoidalFunction functionw1 = new TrapezoidalFunction(, , TrapezoidalFunction.EdgeType.Right);
FuzzySet fsStrong = new FuzzySet("Strong", function1);
TrapezoidalFunction functionw2 = new TrapezoidalFunction(, , , );
FuzzySet fsBreeze = new FuzzySet("Breeze", function2);
TrapezoidalFunction functionw3 = new TrapezoidalFunction(,,TrapezoidalFunction.EdgeType.Left);
FuzzySet fsAirless = new FuzzySet("Airless", function3); //添加标签
lvWind.AddLabel(fsStrong);
lvWind.AddLabel(fsBreeze);
lvWind.AddLabel(fsAirless); //创建数据库
Database db = new Database();
db.AddVariable(lvTemperature);
db.AddVariable(lvWind); //书写规则
Rule r1 = new Rule(db, "Thinking1", "IF Wind IS Strong THEN Temperature IS Cold");
Rule r2 = new Rule(db, "Thinking2", "IF Wind IS AirlessTHEN Temperature IS NOT Cold");
模糊运算
以下全是数学相关物…不喜者勿入。
模糊运算主要针对模糊集合,有3种:联集(union)、补集(complement)与交集(intersection),而依照不同定义有不同的型态。
1.交集中:
标准交集(standard intersection):t (p,q) = min (p,q)
代数乘积(algebraic product):t (p,q) = pq
有界差异(bounded different):t (p,q) = max (0, p+q-1)
彻底交集(drastic intersection):

2.联集中:
标准联集(standard intersection):s (p,q) = max (p,q)
代数加法(algebraic product): s (p,q) = p + q -pq
有界加法(bounded different): s (p,q) = min (1, p+q)
彻底联集(drastic intersection):

本来还想写模糊合成的…但是没找到可以画矩阵的软件,matlab画出来太丑了。
写在最后:
1.本文参考了很多文档和资料,特别是相关英文的对应翻译上,主要参考http://www.academia.edu相关讨论和台湾一些院校的研究报告。
2.有个不错的PPT,可以看一下:http://www.ctdisk.com/file/4479740
模糊语意变数、规则和模糊运算--AForge.NET框架的使用(二)的更多相关文章
- 人工神经网络简介和单层网络实现AND运算--AForge.NET框架的使用(五)
原文:人工神经网络简介和单层网络实现AND运算--AForge.NET框架的使用(五) 前面4篇文章说的是模糊系统,它不同于传统的值逻辑,理论基础是模糊数学,所以有些朋友看着有点迷糊,如果有兴趣建议参 ...
- 基于AForge.Net框架的扑克牌识别
原文:基于AForge.Net框架的扑克牌识别 © 版权所有 野比 2012 原文地址:点击查看 作者:Nazmi Altun Nazmi Altun著,野比 译 下载源代码 - 148.61 KB ...
- 模糊系统架构和简单实现--AForge.NET框架的使用(四)
原文:模糊系统架构和简单实现--AForge.NET框架的使用(四) 先说一下,为什么题目是简单实现,因为我实在没有弄出好的例子. 我原来用AForge.net做的项目中的模糊系统融入了神经网络和向量 ...
- 子句判断、启动强度和去模糊化--AForge.NET框架的使用(三)
原文:子句判断.启动强度和去模糊化--AForge.NET框架的使用(三) 使用AForge.NET进行模糊运算 上一篇说来一些模糊运算的数学问题,用AForge.NET做相关运算就很简单了. 1.联 ...
- 模糊集合和隶属度函数--AForge.NET框架的使用(一)
原文:模糊集合和隶属度函数--AForge.NET框架的使用(一) 什么是AForge.NET? AForge.NET是一个为开发人员和研究人员开发的框架,它可以用于计算机视觉,遗传算法,图像处理,神 ...
- 进化计算简介和遗传算法的实现--AForge.NET框架的使用(六)
原文:进化计算简介和遗传算法的实现--AForge.NET框架的使用(六) 开学了,各种忙起来了… 上一篇介绍了AForge.NET在人工神经网络上的一点点使用,但是老觉不过瘾.matlab用着实在不 ...
- 规则引擎以及blaze 规则库的集成初探之二——JSR94 的规则引擎API和实现
http://jefferson.iteye.com/blog/67839 规则引擎以及blaze 规则库的集成初探之二——JSR94 的规则引擎API和实现
- MongoDB模糊查询,以及MongoDB模糊查询时带有括号的情况
模糊查询 记录如下: { "_id" : ObjectId("5c3d486d24aa9a000526367b"), "name" : &q ...
- Linq的模糊查询(包含精确模糊查询)
目录: 1.判断是否为空或者null 2.普通包含模糊查询 1)以某字符串开头的模糊查询 2)以某字符串结尾的模糊查询 3)包含某字符串的模糊查询 3.精确到字符串对应位数字符的模糊查询(*重点) l ...
随机推荐
- 关于在SLES11, RHEL6, OEL6 and UEK2 Kernels使用hugepages的告警
ALERT: Disable Transparent HugePages on SLES11, RHEL6, OEL6 and UEK2 Kernels (Doc ID 1557478.1) Modi ...
- java笔记11之二维数组
格式1: 二维数组:就是元素为一维数组的一个数组 数据类型[][] 数组名 = new 数组类型[m][n] 其中m为行 n为列 注意: A:以下格式也可以表示二维数组 a:数据 ...
- Android ProgressDialog 加载进度
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools= ...
- Android ImageView 点击更换头像
首先搭建布局 主界面布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" ...
- [Angular 2] Using a Value from the Store in a Reducer
RxJS allows you to combine streams in various ways. This lesson shows you how to take a click stream ...
- HDU 1166 敌兵布阵(线段树)
题目地址:pid=1166">HDU 1166 听说胡浩版的线段树挺有名的. 于是就拜訪了一下他的博客.详情戳这里.于是就全然仿照着胡浩大牛的风格写的代码. 至于原理.鹏鹏学长已经讲的 ...
- ubuntu12.04软件中心打开错误和 ubuntu 包管理之“:E: 读错误 - read (5: 输入/输出错误) E: 无法解析或打开软件包的列表或是状态文件。”的解决
执行ubuntu软讲中心时打不开.老是崩溃,从终端也下载不了软件. 执行包管理的update或者search等等会报错: E: 读错误 - read (5: 输入/输出错误) E: 无法解析或打开软件 ...
- Cross-origin resource sharing--reference
Cross-origin resource sharing (CORS) is a mechanism that allows many resources (e.g., fonts, JavaScr ...
- 27个Jupyter Notebook使用技巧及快捷键(翻译版)
Jupyter Notebook Jupyter Notebook 以前被称为IPython notebook.Jupyter Notebook是一款能集各种分析包括代码.图片.注释.公式及自己画的图 ...
- 全球最流行的66款App的共同规律
根据苹果AppStore.Google Play.App Annie.亚马逊 AppStore及Windows Phone 应用商店历年的公开数据统计,以下66个非游戏类应用正在全球范围内流行,持续时 ...