home Forums # Technical Support jar jfuzzylite

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1533
    Unknown
    Member

    Hello,
    I have downloaded the jar for Android and java(Version 4.0) from your website, i have also downloaded the QtFuzzyLite(Version 5.0). But now i’m having some troubles implementing and testing the test case simple-dimmer in android. The source on the http://fuzzylite.com/java/ is different than the QtFuzzyLite returns in the export, i presume that the later is more correct, since it is more similar to the ones in the examples folder. The problem is that when i try to test the case the engine returns an error:
    – Rule block <> has no Conjunction
    – Rule block <> has 1 rules that require Conjunction- Rule block <> has no Disjunction
    – Rule block <> has 1 rules that require Disjunction.
    I believe that the jars might be outdated (or am i missing something?), i have a version jfuzzylite-1.0 and i was wondering if you might have any newer. I’m also interested in buying the licence for QtFuzzyLite, and i was wondering if the one on the website is the latest? Are the exported models “plug&play” or do they require any additional integration beside running the engine? Here is the code i tried out:

    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 outputVariable = new OutputVariable();
    outputVariable.setEnabled(true);
    outputVariable.setName(“Power”);
    outputVariable.setRange(0.000, 1.000);
    outputVariable.fuzzyOutput().setAccumulation(new Maximum());
    outputVariable.setDefuzzifier(new Centroid(200));
    outputVariable.setDefaultValue(Double.NaN);
    outputVariable.setLockValidOutput(false);
    outputVariable.setLockOutputRange(false);
    outputVariable.addTerm(new Triangle(“LOW”, 0.000, 0.250, 0.500));
    outputVariable.addTerm(new Triangle(“MEDIUM”, 0.250, 0.500, 0.750));
    outputVariable.addTerm(new Triangle(“HIGH”, 0.500, 0.750, 1.000));
    engine.addOutputVariable(outputVariable);

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

    StringBuilder status = new StringBuilder();
    if (!engine.isReady(status))
    throw new RuntimeException(“Engine not ready. ” +
    “The following errors were encountered:\n” + status.toString());

    for (int i = 0; i < 50; ++i){
    double light = inputVariable.getMinimum() + i * (inputVariable.range() / 50);
    inputVariable.setInputValue(light);
    engine.process();
    FuzzyLite.logger().info(String.format(
    “Ambient.input = %s -> Power.output = %s”,
    Op.str(light), Op.str(outputVariable.defuzzify())));
    }

    Best regards,
    Rg

    #1545

    Hi,

    jfuzzylite 1.0 is different from fuzzylite 5.0 in several aspects. I am currently working on getting the next version out this month.

    For jfuzzylite 1.0, you always need to specify the conjunction and disjunction norms. In the rule block, change this as follows:

    ruleBlock.setConjunction(new Minimum());
    ruleBlock.setDisjunction(new Maximum());
    

    These are dummy values as they will not be used.

    For jfuzzylite 1.0, perhaps it is better to utilize QtFuzzyLite 4.0 to export your engine to java.

    Cheers.

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