home › Forums › # Technical Support › Help to resolve error
Tagged: java android
- This topic has 8 replies, 2 voices, and was last updated 6 years, 2 months ago by
Unknown.
-
AuthorPosts
-
September 25, 2017 at 18:42 #2596
Unknown
MemberI did below function but error occurred while run time..
” java runtime exception consequent expected output variable but found <tip>”public 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 tip is HIGH”, engine));
ruleBlock.addRule(Rule.parse(“if service is good then tip is MEDIUM”, engine));
ruleBlock.addRule(Rule.parse(“if service is excellent then tip is LOW”, engine));
engine.addRuleBlock(ruleBlock);engine.configure(“”, “”, “Minimum”, “Maximum”, “Centroid”, null);
engine.setInputValue(“service”,0.1);
engine.process();
return String.format(“0.3f”, engine.getOutputValue(“Power”));
}Please help me to resolve this problem….
September 25, 2017 at 18:55 #2597Unknown
MemberI 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”));
}September 25, 2017 at 19:26 #2598Unknown
MemberI need get output of Power?
LOW or MEDIUM or HIGHSeptember 27, 2017 at 00:35 #2600Juan Rada-Vilela (admin)
KeymasterHi,
I think you should configure your engine with
engine.configure(“”, “”, “Minimum”, “Maximum”, “Centroid”, "General");
as for obtaining a linguistic result, you could do something like:
engine.getOutputVariable("Power").highestActivatedTerm().getTerm().getName()
It would be a good idea to check the source code of jfuzzylite. Specifically, the following:(1)
OutputVariable
: https://github.com/fuzzylite/jfuzzylite/blob/master/jfuzzylite/src/main/java/com/fuzzylite/variable/OutputVariable.java
(2) The fuzzy output value in anOutputVariable
is anAggregated
term:
https://github.com/fuzzylite/jfuzzylite/blob/master/jfuzzylite/src/main/java/com/fuzzylite/term/Aggregated.java
(3) ThehighestActivatedTerm
is anActive
term: https://github.com/fuzzylite/jfuzzylite/blob/master/jfuzzylite/src/main/java/com/fuzzylite/term/Activated.javaCheers.
September 28, 2017 at 15:35 #2606Unknown
MemberThank you for reply.but there is no
engine.configure(“”, “”, “Minimum”, “Maximum”,”Centroid”, “General”);
engine.getOutputVariable(“Power”).highestActivatedTerm().getTerm().getName(); such wayunder engine.getOutputVariable(“Power”) there is no highestActivatedTerm() fucntion.
How can i get this??
September 28, 2017 at 16:06 #2607Unknown
Memberpublic 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 snake = new OutputVariable();
snake.setName(“snake”);
snake.setRange(1, 3);
snake.setDefaultValue(Double.NaN);
snake.addTerm(new Constant(“Cobra”, 1));
snake.addTerm(new Constant(“SEA”, 2));
snake.addTerm(new Constant(“WIFE”, 3));
engine.addOutputVariable(snake);RuleBlock ruleBlock = new RuleBlock();
ruleBlock.setName(“rule”);
ruleBlock.addRule(Rule.parse(“if service is poor then snake is Cobra”, engine));
ruleBlock.addRule(Rule.parse(“if service is good then snake is SEA”, engine));
ruleBlock.addRule(Rule.parse(“if service is excellent then snake is WIFE”, engine));
engine.addRuleBlock(ruleBlock);engine.configure(“”, “”, “Minimum”, “Maximum”,”Centroid”, “General”);
engine.setInputValue(“service”, .7);
engine.process();
engine.getOutputVariable(“snake”);
System.out.print(engine.getOutputValue(“snake”));
return String.format(“”, engine.getOutputValue(“snake”));
}i need to get extract out put variable.
Cobra or SEA or WIFE please help me to do thatSeptember 28, 2017 at 16:06 #2608Juan Rada-Vilela (admin)
KeymasterHi,
I think you may be using version 5.0. Maybe you should take a look at the current version.
Cheers.
September 28, 2017 at 16:17 #2609Unknown
MemberThank you for reply i have used lib/jfuzzylite-6.0.1.jar is this old version.
September 28, 2017 at 16:57 #2610Unknown
MemberThank you for your reply.I found way to get it but some null point exception.
line engine.getOutputVariable(“snake”).fuzzyOutput().highestActivatedTerm()
//Exception in thread “main” java.lang.NullPointerExceptionimport com.fuzzylite.Engine;
import com.fuzzylite.rule.Rule;
import com.fuzzylite.rule.RuleBlock;
import com.fuzzylite.term.Constant;
import com.fuzzylite.term.Triangle;
import com.fuzzylite.variable.InputVariable;
import com.fuzzylite.variable.OutputVariable;
import com.fuzzylite.term.Activated;public class Test {
public static void main(String[] args) {
String inputOne = “colorOne”;
String inputTwo = “ColorTwo”;
String out = fuzzy();
System.out.println(out);
}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 snake = new OutputVariable();
snake.setName(“snake”);
snake.setRange(1, 3);
snake.setDefaultValue(Double.NaN);
snake.addTerm(new Constant(“Cobra”, 1));
snake.addTerm(new Constant(“SEA”, 2));
snake.addTerm(new Constant(“WIFE”, 3));
engine.addOutputVariable(snake);RuleBlock ruleBlock = new RuleBlock();
ruleBlock.setName(“rule”);
ruleBlock.addRule(Rule.parse(“if service is poor then snake is Cobra”, engine));
ruleBlock.addRule(Rule.parse(“if service is good then snake is SEA”, engine));
ruleBlock.addRule(Rule.parse(“if service is excellent then snake is WIFE”, engine));
engine.addRuleBlock(ruleBlock);engine.configure(“”, “”, “Minimum”, “Maximum”,”Centroid”, “General”);
engine.setInputValue(“service”,0.51 );
engine.process();System.out.print(engine.getOutputVariable(“snake”).fuzzyOutputValue());
// 0.000/Cobra + 0.960/SEA + 0.040/WIFE
System.out.print(engine.getOutputVariable(“snake”).fuzzyOutput().highestActivatedTerm().getTerm().getName());
//Exception in thread “main” java.lang.NullPointerExceptionreturn String.format(“”, engine.getOutputVariable(“snake”).fuzzyOutputValue());
}
} -
AuthorPosts
- You must be logged in to reply to this topic.