home Forums # Technical Support jFuzzyLite Assigning Values

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2109
    Unknown
    Member

    Hi I am trying to edit the example “simple-dimer” code given. But am not sure how do I pass values for ambient into the code, e.g. I want to assign the value 0.5 to ambient and then have only the rule where ambient is “MEDIUM” print to console what Power value is. I can’t find any documentation on this.

    Code for reference:

    public void anotherTest(){
    Engine engine = new Engine();
    engine.setName(“simple-dimmer”);

    InputVariable inputVariable = new InputVariable();
    inputVariable.setEnabled(true);
    inputVariable.setName(“Ambient”);
    inputVariable.setRange(0.000, 1.000);
    inputVariable.addTerm(new Triangle(“DARK”, 0.000, 0.250, 0.500));
    inputVariable.addTerm(new Triangle(“MEDIUM”, 0.250, 0.500, 0.750));
    inputVariable.addTerm(new Triangle(“BRIGHT”, 0.500, 0.750, 1.000));
    engine.addInputVariable(inputVariable);

    OutputVariable outputVariable1 = new OutputVariable();
    outputVariable1.setEnabled(true);
    outputVariable1.setName(“Power”);
    outputVariable1.setRange(0.000, 1.000);
    outputVariable1.fuzzyOutput().setAccumulation(new Maximum());
    outputVariable1.setDefuzzifier(new Centroid(200));
    outputVariable1.setDefaultValue(Double.NaN);
    outputVariable1.setLockPreviousOutputValue(false);
    outputVariable1.setLockOutputValueInRange(false);
    outputVariable1.addTerm(new Triangle(“LOW”, 0.000, 0.250, 0.500));
    outputVariable1.addTerm(new Triangle(“MEDIUM”, 0.250, 0.500, 0.750));
    outputVariable1.addTerm(new Triangle(“HIGH”, 0.500, 0.750, 1.000));
    engine.addOutputVariable(outputVariable1);

    RuleBlock ruleBlock = new RuleBlock();
    ruleBlock.setEnabled(true);
    ruleBlock.setName(“”);
    ruleBlock.setConjunction(null);
    ruleBlock.setDisjunction(null);
    ruleBlock.setActivation(new Minimum());
    ruleBlock.addRule(Rule.parse(“if Ambient is DARK then Power is HIGH”, engine));
    ruleBlock.addRule(Rule.parse(“if Ambient is MEDIUM then Power is MEDIUM”, engine));
    ruleBlock.addRule(Rule.parse(“if Ambient is BRIGHT then Power is LOW”, engine));
    engine.addRuleBlock(ruleBlock);

    FuzzyLite.logger().info(new FldExporter().toString(engine));
    }

    #2110

    Hi,

    thank you for your email.

    Please, refer to http://fuzzylite.github.io/fuzzylite/index.html for source code documentation. It is for the next version 6.0, where a quite a few things have changed, but you still should be able to find most of the information you require. For the rest, please check the fuzzylite source code, which should be rather easy to read and understand.

    Cheers.

    #2111
    Unknown
    Member

    Thanks! The source is very easy to understand after going through it for some time, I was just thrown off at first. If anyone is wondering how I fixed my problem I used:

    //input values
    engine1.setInputValue(“Inputvar1”, int i);
    engine1.setInputValue(“Inputvar2”, int j);
    engine1.setInputValue(“Inputvar3”, int x);
    engine1.process();

    //output value
    engine1.getOutputValue(“Outputvar”);

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.