home › Forums › # Technical Support › getOutputValue() missing
- This topic has 1 reply, 2 voices, and was last updated 8 years, 4 months ago by
Juan Rada-Vilela (admin).
-
AuthorPosts
-
May 17, 2015 at 13:05 #1811
Unknown
MemberHello, well I´m trying to run the java example that is in the fuzzylite documenation for java, but it throws an error, at the end in the part of getOutputValue()))); As well I recieve the same error in my own implementation, that is why I try the example 🙁
/*
* 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 testfuzzy;import com.fuzzylite.Engine;
import com.fuzzylite.FuzzyLite;
import com.fuzzylite.Op;
import com.fuzzylite.rule.Rule;
import com.fuzzylite.rule.RuleBlock;
import com.fuzzylite.term.Triangle;
import com.fuzzylite.variable.InputVariable;
import com.fuzzylite.variable.OutputVariable;
/**
*
* @author 7h3n3w3r4cr4ck3r
*/
public class TestFuzzy {/**
* @param args the command line arguments
*/
public static void main(String[] args) {Engine engine = new Engine();
engine.setName(“simple-dimmer”);InputVariable ambient = new InputVariable();
ambient.setName(“Ambient”);
ambient.setRange(0.000, 1.000);
ambient.addTerm(new Triangle(“DARK”, 0.000, 0.250, 0.500));
ambient.addTerm(new Triangle(“MEDIUM”, 0.250, 0.500, 0.750));
ambient.addTerm(new Triangle(“BRIGHT”, 0.500, 0.750, 1.000));
engine.addInputVariable(ambient);OutputVariable power = new OutputVariable();
power.setName(“Power”);
power.setRange(0.000, 1.000);
power.setDefaultValue(Double.NaN);
power.addTerm(new Triangle(“LOW”, 0.000, 0.250, 0.500));
power.addTerm(new Triangle(“MEDIUM”, 0.250, 0.500, 0.750));
power.addTerm(new Triangle(“HIGH”, 0.500, 0.750, 1.000));
engine.addOutputVariable(power);RuleBlock ruleBlock = new RuleBlock();
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);engine.configure(“”, “”, “Minimum”, “Maximum”, “Centroid”);
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 = ambient.getMinimum() + i * (ambient.range() / 50);
ambient.setInputValue(light);
engine.process();
FuzzyLite.logger().info(String.format(
“Ambient.input = %s -> Power.output = %s”,
Op.str(light), Op.str(power.getOutputValue())));
}
}
}May 17, 2015 at 23:07 #1812Juan Rada-Vilela (admin)
KeymasterHi,
what error are you experimenting?
-
AuthorPosts
- You must be logged in to reply to this topic.