Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 模糊逻辑真实性证明_Java_Fuzzy Logic - Fatal编程技术网

Java 模糊逻辑真实性证明

Java 模糊逻辑真实性证明,java,fuzzy-logic,Java,Fuzzy Logic,我正在创建一个简单的例子来证明模糊逻辑的真实性。 问题在于确定结果的真实性 我首先关心的是:通过测试高低目标之间的真值,这真的是在使用模糊逻辑吗 我的第二个担忧:对于目标/阈值命中率,真实性%似乎不正确 结果: Miss: 30 Hit: 40 at 100% true ( should be 80% ? ) Hit: 50 at 80% true ( should be 100% ? ) Hit: 60 at 66% true ( should be 80% ? ) Miss: 70

我正在创建一个简单的例子来证明模糊逻辑的真实性。 问题在于确定结果的真实性

我首先关心的是:通过测试高低目标之间的真值,这真的是在使用模糊逻辑吗

我的第二个担忧:对于目标/阈值命中率,真实性%似乎不正确

结果:

Miss: 30
 Hit: 40 at 100% true ( should be 80% ? )
 Hit: 50 at 80% true  ( should be 100% ? )
 Hit: 60 at 66% true  ( should be 80% ? )
Miss: 70
类别:

public class FuzzyTest {

class Result {    
    int value;
    int truthfullness;
}

Result evaluate(final int valueIn, final int target, final int threshold) {
    Result result = null;
    final boolean truth = (((target - threshold) <= valueIn) && (valueIn <= (target + threshold)));
    if (truth) {
        result = new Result();
        result.value = valueIn;
        result.truthfullness = (int) (100.0 - (100.0 * (valueIn - Math.abs(target - threshold)) / valueIn));
    }
    return result;
}

public static void main(final String[] args) {
    final int[] arrayIn = new int[] { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
    final int threshold = 10;
    final int target = 50;
    final FuzzyTest fuzzy = new FuzzyTest();
    for (final int x : arrayIn) {
        final Result result = fuzzy.evaluate(x, target, threshold);
        if (result == null) {
            System.out.println("Miss: " + x);
        }
        else {
            System.out.println("Hit: " + x + " at " + result.truthfullness + "% true");
        }
    }
}
}
公共类模糊测试{
类结果{
int值;
诚实;
}
结果评估(最终整型值、最终整型目标、最终整型阈值){
结果=空;
最终布尔真值=((目标-阈值)
通过测试高目标和低目标之间的真值,这真的是在使用模糊逻辑吗

不。它仍然是相同的布尔逻辑。要真正获得模糊值,必须从输入变量的模糊函数中获得模糊值

模糊函数是一个函数,它接收一个实值并返回一个介于0和1之间的值。它表示该变量的真实度。例如,在下图中(取自维基百科关于模糊的文章),实值温度将有一个“冷”、“热”和“热”的度。这些值就是你的真实度

真实性%对于目标/阈值命中率似乎不正确

是的,这是不正确的。首先,因为您的阈值实际上在模糊定义中介于0和1之间(因此,您已经有了一个百分比)。其次,如果您定义的阈值为[01100],则它不是模糊的



如果您使用Java创建模糊系统(即使是一个简单的系统),我可以推荐一个好的框架吗?尝试使用。它将帮助您编程模糊系统并了解模糊的工作原理。

尝试以下方法以获得您想要的值:

result.truthfullness = (int) (100.0 - (100.0 * Math.abs(target - valueIn)) / target);
它给出了以下结果:

Miss: 30
Hit: 40 at 80% true
Hit: 50 at 100% true
Hit: 60 at 80% true
Miss: 70

似乎40和60的命中率应该接近0%(不是80%),45和55的命中率应该是50%。