Forum Replies Created

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • in reply to: Jfuzzylite classes not found error in eclipse #2615
    Chandana
    Chandana
    Participant

    import jfuzzylite-6.0.1.jar to your project.

    in reply to: FuzzyLite Use in Android #2614
    Chandana
    Chandana
    Participant

    /*
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */
    package mytest;

    import com.fuzzylite.Engine;
    import com.fuzzylite.rule.Rule;
    import com.fuzzylite.rule.RuleBlock;
    import com.fuzzylite.term.Activated;
    import com.fuzzylite.term.Aggregated;
    import com.fuzzylite.term.Triangle;
    import com.fuzzylite.variable.InputVariable;
    import com.fuzzylite.variable.OutputVariable;

    /**
    *
    * @author pc
    */
    public class MyTest {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    ////2.2,1.1,2.2
    //1.1,0.9,2.2
    //2.2,1.3,2.2
    //1.3,2.2,1.3
    //0.7,2.2,3.3
    //3.3,1.3,1.3

    fuzzy(1.3,2.2,1.3);
    }

    public static String fuzzy(double eye_color,double tongue_color,double wound_color) {

    Engine engine = new Engine();
    engine.setName(“snake-detector”);

    InputVariable red = new InputVariable();
    red.setName(“Eye_Color”);
    red.setRange(0.5, 3.5);
    red.addTerm(new Triangle(“one”, 2, 2.2, 2.4));
    red.addTerm(new Triangle(“two”, 0.9, 1.1, 1.3));
    red.addTerm(new Triangle(“three”, 0.7, 0.9, 1.1));
    red.addTerm(new Triangle(“four”, 1.1, 1.3, 1.5));
    red.addTerm(new Triangle(“five”, 0.5, 0.7, 0.9));
    red.addTerm(new Triangle(“six”, 3.1, 3.3, 3.5));
    engine.addInputVariable(red);

    InputVariable green = new InputVariable();
    green.setName(“Toung_Color”);
    green.setRange(0.5, 3.5);
    green.addTerm(new Triangle(“one”, 2, 2.2, 2.4));
    green.addTerm(new Triangle(“two”, 0.9, 1.1, 1.3));
    green.addTerm(new Triangle(“three”, 0.7, 0.9, 1.1));
    green.addTerm(new Triangle(“four”, 1.1, 1.3, 1.5));
    green.addTerm(new Triangle(“five”, 0.5, 0.7, 0.9));
    green.addTerm(new Triangle(“six”, 3.1, 3.3, 3.5));
    engine.addInputVariable(green);

    InputVariable blue = new InputVariable();
    blue.setName(“Wound_Color”);
    blue.setRange(0.5, 3.5);
    blue.addTerm(new Triangle(“one”, 2, 2.2, 2.4));
    blue.addTerm(new Triangle(“two”, 0.9, 1.1, 1.3));
    blue.addTerm(new Triangle(“three”, 0.7, 0.9, 1.1));
    blue.addTerm(new Triangle(“four”, 1.1, 1.3, 1.5));
    blue.addTerm(new Triangle(“five”, 0.5, 0.7, 0.9));
    blue.addTerm(new Triangle(“six”, 3.1, 3.3, 3.5));
    engine.addInputVariable(blue);

    OutputVariable snake = new OutputVariable();
    snake.setName(“snake”);
    snake.setRange(0, 12);
    snake.setDefaultValue(Double.NaN);
    snake.addTerm(new Triangle(“Cobra”, 0, 1, 2));
    snake.addTerm(new Triangle(“Russell’s_viper”, 2, 3, 4));
    snake.addTerm(new Triangle(“Krait”, 4, 5, 6));
    snake.addTerm(new Triangle(“Sea_snake”, 6, 7, 8));
    snake.addTerm(new Triangle(“Hump_nosed_viper”, 8, 9, 10));
    snake.addTerm(new Triangle(“Saw_scaled_viper”, 10, 11, 12));
    engine.addOutputVariable(snake);

    RuleBlock ruleBlock = new RuleBlock();
    ruleBlock.addRule(Rule.parse(
    “if Eye_Color is one and Toung_Color is two and Wound_Color is one then snake is Cobra”, engine));
    ruleBlock.addRule(Rule.parse(
    “if Eye_Color is two and Toung_Color is three and Wound_Color is one then snake is Russell’s_viper”,
    engine));
    ruleBlock.addRule(Rule.parse(
    “if Eye_Color is one and Toung_Color is four and Wound_Color is one then snake is Krait”, engine));
    ruleBlock.addRule(Rule.parse(
    “if Eye_Color is four and Toung_Color is one and Wound_Color is four then snake is Sea_snake”, engine));
    ruleBlock.addRule(Rule.parse(
    “if Eye_Color is five and Toung_Color is one and Wound_Color is six then snake is Hump_nosed_viper”,
    engine));
    ruleBlock.addRule(Rule.parse(
    “if Eye_Color is six and Toung_Color is four and Wound_Color is four then snake is Saw_scaled_viper”,
    engine));
    engine.addRuleBlock(ruleBlock);

    engine.configure(“Minimum”, “Maximum”, “Minimum”, “Maximum”, “Centroid”, null);
    engine.setInputValue(“Eye_Color”, eye_color);
    engine.setInputValue(“Wound_Color”, wound_color);
    engine.setInputValue(“Toung_Color”, tongue_color);
    engine.process();
    String snakeName = “”;
    Aggregated fuzzyOutput = engine.getOutputVariable(“snake”).fuzzyOutput();
    for (Activated activated : fuzzyOutput.getTerms()) {
    System.out.println(String.format(“%f %s”, activated.getDegree(), activated.getTerm().getName()));
    snakeName = String.format(“%s”, activated.getTerm().getName());
    }
    System.out.println(snakeName);
    return snakeName;
    }
    }

    in reply to: How to get single string output #2613
    Chandana
    Chandana
    Participant

    Thank you for great help. its work well.

    in reply to: Help to resolve error #2610
    Chandana
    Chandana
    Participant

    Thank 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.NullPointerException

    import 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.NullPointerException

    return String.format(“”, engine.getOutputVariable(“snake”).fuzzyOutputValue());
    }
    }

    in reply to: Help to resolve error #2609
    Chandana
    Chandana
    Participant

    Thank you for reply i have used lib/jfuzzylite-6.0.1.jar is this old version.

    in reply to: Help to resolve error #2607
    Chandana
    Chandana
    Participant

    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”, .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 that

    in reply to: Help to resolve error #2606
    Chandana
    Chandana
    Participant

    Thank you for reply.but there is no
    engine.configure(“”, “”, “Minimum”, “Maximum”,”Centroid”, “General”);
    engine.getOutputVariable(“Power”).highestActivatedTerm().getTerm().getName(); such way

    under engine.getOutputVariable(“Power”) there is no highestActivatedTerm() fucntion.

    How can i get this??

    in reply to: Help to resolve error #2598
    Chandana
    Chandana
    Participant

    I need get output of Power?
    LOW or MEDIUM or HIGH

    in reply to: Help to resolve error #2597
    Chandana
    Chandana
    Participant

    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”));
    }

Viewing 9 posts - 1 through 9 (of 9 total)