home › Forums › # Technical Support › jFuzzyLite Assigning Values
Tagged: jfuzzylogic
- This topic has 2 replies, 2 voices, and was last updated 6 years, 11 months ago by
Unknown.
-
AuthorPosts
-
March 26, 2016 at 04:29 #2109
Unknown
MemberHi 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));
}March 29, 2016 at 14:16 #2110Juan Rada-Vilela (admin)
KeymasterHi,
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.
March 30, 2016 at 00:59 #2111Unknown
MemberThanks! 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”); -
AuthorPosts
- You must be logged in to reply to this topic.