使用C#中的模糊逻辑对数字进行分类

时间:2014-05-28 14:00:19

标签: c# fuzzy-logic

我想使用模糊逻辑框架在c#中编写一个小代码,用户将在0到10之间输入数字,这些数字需要分为低,中等和高。低为0到3,中等为3到7,高为6到10.使用三角形隶属函数。任何猜测如何做到这一点我读了一些关于模糊框架的教程,但无法解决我的问题。以下是我写的代码,

 class Program
    {
        static void Main(string[] args)
        { 
            ContinuousDimension score = new ContinuousDimension("score", "score of word", "unit", 0, 10);    

            //Definition of basic fuzzy sets with which we will work
            //  input sets:

 ContinuousSet low = new RightQuadraticSet(score, "Low Score", 0, 3, 4);
            ContinuousSet high = new LeftQuadraticSet(score, "High Score", 6, 7, 10);
            ContinuousSet mod = new BellSet(score, "Moderate Score", 5, 1, 2);

....
}

我现在该怎么办?我已经在0到10的等级上手动分配了意见单词的一些分数,我想用三角函数将这些意见单词的强度分类为低,中或高。

1 个答案:

答案 0 :(得分:0)

模糊逻辑有效处理处理情况。想想温度控制,你不希望从加热到冷却来回切换,因为这会非常耗能。

在你的例子中,你会有这样的东西:

Very low = low limit of moderate => below 2.5 => time to turn on the heater

Very high = high limit of moderate => above 7.5 => time to turn on the AC

在&#34之后采取行动;非常低"事件(打开加热器)然后下一个动作是当值超过低上限(3.5)时,即加热器关闭时。

Very Low = 0 - 2.5
Moderate Low = 2.5 - 3.5
Moderate = 3.5-6.5
Moderate High = 6.5 - 7.5
Very High = 7.5-10