home › Forums › # Technical Support › FIS returns NAN
- This topic has 4 replies, 2 voices, and was last updated 8 years, 6 months ago by
Unknown.
-
AuthorPosts
-
March 28, 2015 at 04:47 #1713
Unknown
MemberHello,
I’m currently a student using jfuzzylite in my final year project.
I’m attempting to develop a simple FIS, however my defuzzified output variable is returning as NaN no matter what values are set as my input variables.
Any help would be greatly appreciated. Thank you 🙂
I’ve entered my code below :
int widthOne = 0; int widthTwo = 25; int widthThree = 50; int persWidthOne = 0; int persWidthTwo = 17; int persWidthThree = 34; int persWidthFour = 51; int persWidthFive = 68; int persMidOne = 17; int persMidTwo = 34; int persMidThree = 51; int persMidFour = 68; int persMidFive = 85; /** * Setup inputs for FIS. */ inPersOne.setName("Open"); inPersOne.setRange(0, 100); inPersOne.addTerm(new Triangle("HARDLY", widthOne, midOne)); inPersOne.addTerm(new Triangle("SOMEWHAT", widthTwo, midTwo)); inPersOne.addTerm(new Triangle("VERY", widthThree, midThree)); inPersTwo.setName("Conscientious"); inPersTwo.setRange(0, 100); inPersTwo.addTerm(new Triangle("HARDLY", widthOne, midOne)); inPersTwo.addTerm(new Triangle("SOMEWHAT", widthTwo, midTwo)); inPersTwo.addTerm(new Triangle("VERY", widthThree, midThree)); inPersThree.setName("Neurotic"); inPersThree.setRange(0, 100); inPersThree.addTerm(new Triangle("HARDLY", widthOne, midOne)); inPersThree.addTerm(new Triangle("SOMEWHAT", widthTwo, midTwo)); inPersThree.addTerm(new Triangle("VERY", widthThree, midThree)); enginePers.addInputVariable(inPersOne); enginePers.addInputVariable(inPersTwo); enginePers.addInputVariable(inPersThree); /** * Setup outputs for FIS. */ outPers.setName("Personality"); outPers.setRange(0, 100); outPers.setDefaultValue(Double.NaN); outPers.addTerm(new Triangle("Open", persWidthOne, persMidOne)); outPers.addTerm(new Triangle("Conscientious", persWidthTwo, persMidTwo)); outPers.addTerm(new Triangle("Neurotic", persWidthThree, persMidThree)); outPers.addTerm(new Triangle("Agreeable", persWidthFour, persMidFour)); outPers.addTerm(new Triangle("Extraverted", persWidthFive, persMidFive)); enginePers.addOutputVariable(outPers); //1 ruleBlckPers.addRule(Rule.parse("if Open is VERY and Neurotic is VERY and Conscientious is VERY then Personality is Agreeable", enginePers)); //2 ruleBlckPers.addRule(Rule.parse("if Open is HARDLY and Neurotic is HARDLY and Conscientious is HARDLY then Personality is Extraverted", enginePers)); //3 ruleBlckPers.addRule(Rule.parse("if Open is SOMEWHAT and Neurotic is SOMEWHAT and Conscientious is SOMEWHAT then Personality is Conscientious", enginePers)); //4 ruleBlckPers.addRule(Rule.parse("if Open is VERY and Neurotic is HARDLY and Conscientious is HARDLY then Personality is Open", enginePers)); //5 ruleBlckPers.addRule(Rule.parse("if Open is HARDLY and Neurotic is VERY and Conscientious is HARDLY then Personality is Neurotic", enginePers)); //6 ruleBlckPers.addRule(Rule.parse("if Open is HARDLY and Neurotic is HARDLY and Conscientious is VERY then Personality is Conscientious", enginePers)); //7 ruleBlckPers.addRule(Rule.parse("if Open is SOMEWHAT and Neurotic is VERY and Conscientious is VERY then Personality is Extraverted", enginePers)); //8 ruleBlckPers.addRule(Rule.parse("if Open is VERY and Neurotic is SOMEWHAT and Conscientious is VERY then Personality is Agreeable", enginePers)); //9 ruleBlckPers.addRule(Rule.parse("if Open is VERY and Neurotic is VERY and Conscientious is SOMEWHAT then Personality is Neurotic", enginePers)); //10 ruleBlckPers.addRule(Rule.parse("if Open is SOMEWHAT and Neurotic is HARDLY and Conscientious is HARDLY then Personality is Open", enginePers)); //11 ruleBlckPers.addRule(Rule.parse("if Open is HARDLY and Neurotic is SOMEWHAT and Conscientious is HARDLY then Personality is Neurotic", enginePers)); //12 ruleBlckPers.addRule(Rule.parse("if Open is HARDLY and Neurotic is HARDLY and Conscientious is SOMEWHAT then Personality is Conscientious", enginePers)); //13 ruleBlckPers.addRule(Rule.parse("if Open is SOMEWHAT and Neurotic is SOMEWHAT and Conscientious is VERY then Personality is Conscientious", enginePers)); //14 ruleBlckPers.addRule(Rule.parse("if Open is SOMEWHAT and Neurotic is VERY and Conscientious is SOMEWHAT then Personality is Neurotic", enginePers)); //15 ruleBlckPers.addRule(Rule.parse("if Open is VERY and Neurotic is SOMEWHAT and Conscientious is SOMEWHAT then Personality is Open", enginePers)); //16 ruleBlckPers.addRule(Rule.parse("if Open is SOMEWHAT and Neurotic is SOMEWHAT and Conscientious is HARDLY then Personality is Open", enginePers)); //17 ruleBlckPers.addRule(Rule.parse("if Open is SOMEWHAT and Neurotic is HARDLY and Conscientious is SOMEWHAT then Personality is Agreeable", enginePers)); //18 ruleBlckPers.addRule(Rule.parse("if Open is HARDLY and Neurotic is SOMEWHAT and Conscientious is SOMEWHAT then Personality is Neurotic", enginePers)); //19 ruleBlckPers.addRule(Rule.parse("if Open is HARDLY and Neurotic is SOMEWHAT and Conscientious is VERY then Personality is Conscientious", enginePers)); //20 ruleBlckPers.addRule(Rule.parse("if Open is HARDLY and Neurotic is VERY and Conscientious is SOMEWHAT then Personality is Neurotic", enginePers)); //21 ruleBlckPers.addRule(Rule.parse("if Open is VERY and Neurotic is SOMEWHAT and Conscientious is HARDLY then Personality is Open", enginePers)); //22 ruleBlckPers.addRule(Rule.parse("if Open is SOMEWHAT and Neurotic is VERY and Conscientious is HARDLY then Personality is Neurotic", enginePers)); //23 ruleBlckPers.addRule(Rule.parse("if Open is SOMEWHAT and Neurotic is HARDLY and Conscientious is VERY then Personality is Conscientious", enginePers)); //24 ruleBlckPers.addRule(Rule.parse("if Open is VERY and Neurotic is SOMEWHAT and Conscientious is SOMEWHAT then Personality is Open", enginePers)); //Conjunction & Disjunction enginePers.configure("AlgebraicProduct", "AlgebraicSum", "AlgebraicProduct", "AlgebraicSum", "Centroid"); inPersOne.setInputValue(10); inPersTwo.setInputValue(20); inPersThree.setInputValue(30); enginePers.process(); double outValPers; outValPers = outPers.defuzzify();
March 28, 2015 at 08:56 #1714Juan Rada-Vilela (admin)
KeymasterHi,
could you please post the FLL code? You can print the FLL by using
System.out.println(new FllExporter().toString(engine))
. Also, you could try verifying the engine using QtFuzzyLite to check for errors.Cheers,
March 28, 2015 at 09:05 #1715Unknown
MemberHi Juan,
Thanks for the quick reply, it’s greatly appreciated.
Here’s the output using the method you suggested:
Engine: personality-analyser InputVariable: Open enabled: true range: 0.000 100.000 term: HARDLY Triangle 0.000 12.500 25.000 term: SOMEWHAT Triangle 25.000 37.500 50.000 term: VERY Triangle 50.000 62.500 75.000 InputVariable: Conscientious enabled: true range: 0.000 100.000 term: HARDLY Triangle 0.000 12.500 25.000 term: SOMEWHAT Triangle 25.000 37.500 50.000 term: VERY Triangle 50.000 62.500 75.000 InputVariable: Neurotic enabled: true range: 0.000 100.000 term: HARDLY Triangle 0.000 12.500 25.000 term: SOMEWHAT Triangle 25.000 37.500 50.000 term: VERY Triangle 50.000 62.500 75.000 OutputVariable: Personality enabled: true range: 0.000 100.000 accumulation: AlgebraicSum defuzzifier: Centroid 200 default: nan lock-valid: false lock-range: false term: Open Triangle 0.000 8.500 17.000 term: Conscientious Triangle 17.000 25.500 34.000 term: Neurotic Triangle 34.000 42.500 51.000 term: Agreeable Triangle 51.000 59.500 68.000 term: Extraverted Triangle 68.000 76.500 85.000
I will look into QtFuzzyLite too 🙂
March 28, 2015 at 09:29 #1716Juan Rada-Vilela (admin)
KeymasterHi,
you are not adding the rule block to the engine. Found your error using QtFuzzyLite.
Cheers.
March 29, 2015 at 04:13 #1717Unknown
MemberThanks you so much Juan! The issue is now fixed 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.