将jFuzzyLogic结果作为double值返回时出错

时间:2016-06-28 14:41:50

标签: java fuzzy-logic jfuzzylogic

我想将模糊逻辑的结果作为double返回给另一个类使用。 我使用以下java代码:

公共类MyFuzzyClass {

public double getFuzzy() {
    String fileName = "tipper.fcl";  //we have to add this file
    FIS fis = FIS.load(fileName,true);

    if( fis == null ) { // Error while loading?
        System.err.println("Can't load file: '" + fileName + "'");
        return;
    }

    // show rule set
    FunctionBlock functionBlock = fis.getFunctionBlock(null);

    JFuzzyChart.get().chart(functionBlock);

    // set inputs
    functionBlock.setVariable("service", 3);
    functionBlock.setVariable("food", 7);

    // evaluate
    functionBlock.evaluate();

    Variable tip = functionBlock.getVariable("tip");
    Double tip_new = tip.getValue(); 
    System.out.println("Tip:" + functionBlock.getVariable("tip").getValue());
    return tip_new;

}

}

但是我在这个回复声明中收到错误:

if( fis == null ) { // Error while loading?
        System.err.println("Can't load file: '" + fileName + "'");
        return;
    }

如何解决此错误?

0 个答案:

没有答案