home Forums # Technical Support Help to resolve error Reply To: Help to resolve error

#2597
Unknown
Member

I did changes now it work well but output result is not working well

public static String fuzzy(){

Engine engine = new Engine();
engine.setName(“simple-dimmer”);

InputVariable service= new InputVariable();
service.setName(“service”);
service.setRange(0.000, 1.000);
service.addTerm(new Triangle(“poor”, 0.000, 0.250, 0.500));
service.addTerm(new Triangle(“good”, 0.250, 0.500, 0.750));
service.addTerm(new Triangle(“excellent”, 0.500, 0.750, 1.000));
engine.addInputVariable(service);

OutputVariable tip = new OutputVariable();
tip.setName(“Power”);
tip.setRange(0.000, 1.000);
tip.setDefaultValue(Double.NaN);
tip.addTerm(new Triangle(“LOW”, 0.000, 0.250, 0.500));
tip.addTerm(new Triangle(“MEDIUM”, 0.250, 0.500, 0.750));
tip.addTerm(new Triangle(“HIGH”, 0.500, 0.750, 1.000));
engine.addOutputVariable(tip);

RuleBlock ruleBlock = new RuleBlock();
ruleBlock.addRule(Rule.parse(“if service is poor then Power is HIGH”, engine));
ruleBlock.addRule(Rule.parse(“if service is good then Power is MEDIUM”, engine));
ruleBlock.addRule(Rule.parse(“if service is excellent then Power is LOW”, engine));
engine.addRuleBlock(ruleBlock);

engine.configure(“”, “”, “Minimum”, “Maximum”, “Centroid”, null);
engine.setInputValue(“service”,0.25);
engine.process();
return String.format(“0.3f”, engine.getOutputValue(“Power”));
}