summaryrefslogtreecommitdiff
path: root/examples/mamdani/SimpleDimmerInverse.cpp
diff options
context:
space:
mode:
authorJohannes 'josch' Schauer <josch@debian.org>2019-01-27 13:56:24 +0100
committerJohannes 'josch' Schauer <josch@debian.org>2019-01-27 13:56:33 +0100
commit6ce553563bc795f389f639a3a8cdfe356de71441 (patch)
treeda4c9ede3087ca534d93bc1ac5a14f044f036600 /examples/mamdani/SimpleDimmerInverse.cpp
parentbbefa170378553e5a6e0d72e4d52328b61f3e8ac (diff)
new upstream version 6.0
Diffstat (limited to 'examples/mamdani/SimpleDimmerInverse.cpp')
-rw-r--r--examples/mamdani/SimpleDimmerInverse.cpp105
1 files changed, 57 insertions, 48 deletions
diff --git a/examples/mamdani/SimpleDimmerInverse.cpp b/examples/mamdani/SimpleDimmerInverse.cpp
index cad1100..1c22275 100644
--- a/examples/mamdani/SimpleDimmerInverse.cpp
+++ b/examples/mamdani/SimpleDimmerInverse.cpp
@@ -1,60 +1,69 @@
#include <fl/Headers.h>
int main(int argc, char** argv){
+//Code automatically generated with fuzzylite 6.0.
+
using namespace fl;
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(fl::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);
-
-OutputVariable* outputVariable2 = new OutputVariable;
-outputVariable2->setEnabled(true);
-outputVariable2->setName("InversePower");
-outputVariable2->setRange(0.000, 1.000);
-outputVariable2->fuzzyOutput()->setAccumulation(new Maximum);
-outputVariable2->setDefuzzifier(new Centroid(500));
-outputVariable2->setDefaultValue(fl::nan);
-outputVariable2->setLockPreviousOutputValue(false);
-outputVariable2->setLockOutputValueInRange(false);
-outputVariable2->addTerm(new Cosine("LOW", 0.200, 0.500));
-outputVariable2->addTerm(new Cosine("MEDIUM", 0.500, 0.500));
-outputVariable2->addTerm(new Cosine("HIGH", 0.800, 0.500));
-engine->addOutputVariable(outputVariable2);
+engine->setName("SimpleDimmerInverse");
+engine->setDescription("");
+
+InputVariable* Ambient = new InputVariable;
+Ambient->setName("Ambient");
+Ambient->setDescription("");
+Ambient->setEnabled(true);
+Ambient->setRange(0.000, 1.000);
+Ambient->setLockValueInRange(false);
+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->setDescription("");
+Power->setEnabled(true);
+Power->setRange(0.000, 1.000);
+Power->setLockValueInRange(false);
+Power->setAggregation(new Maximum);
+Power->setDefuzzifier(new Centroid(200));
+Power->setDefaultValue(fl::nan);
+Power->setLockPreviousValue(false);
+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);
+
+OutputVariable* InversePower = new OutputVariable;
+InversePower->setName("InversePower");
+InversePower->setDescription("");
+InversePower->setEnabled(true);
+InversePower->setRange(0.000, 1.000);
+InversePower->setLockValueInRange(false);
+InversePower->setAggregation(new Maximum);
+InversePower->setDefuzzifier(new Centroid(500));
+InversePower->setDefaultValue(fl::nan);
+InversePower->setLockPreviousValue(false);
+InversePower->addTerm(new Cosine("LOW", 0.200, 0.500));
+InversePower->addTerm(new Cosine("MEDIUM", 0.500, 0.500));
+InversePower->addTerm(new Cosine("HIGH", 0.800, 0.500));
+engine->addOutputVariable(InversePower);
RuleBlock* ruleBlock = new RuleBlock;
-ruleBlock->setEnabled(true);
ruleBlock->setName("");
-ruleBlock->setConjunction(NULL);
-ruleBlock->setDisjunction(NULL);
-ruleBlock->setActivation(new Minimum);
-ruleBlock->addRule(fl::Rule::parse("if Ambient is DARK then Power is HIGH", engine));
-ruleBlock->addRule(fl::Rule::parse("if Ambient is MEDIUM then Power is MEDIUM", engine));
-ruleBlock->addRule(fl::Rule::parse("if Ambient is BRIGHT then Power is LOW", engine));
-ruleBlock->addRule(fl::Rule::parse("if Power is LOW then InversePower is HIGH", engine));
-ruleBlock->addRule(fl::Rule::parse("if Power is MEDIUM then InversePower is MEDIUM", engine));
-ruleBlock->addRule(fl::Rule::parse("if Power is HIGH then InversePower is LOW", engine));
+ruleBlock->setDescription("");
+ruleBlock->setEnabled(true);
+ruleBlock->setConjunction(fl::null);
+ruleBlock->setDisjunction(fl::null);
+ruleBlock->setImplication(new Minimum);
+ruleBlock->setActivation(new General);
+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));
+ruleBlock->addRule(Rule::parse("if Power is LOW then InversePower is HIGH", engine));
+ruleBlock->addRule(Rule::parse("if Power is MEDIUM then InversePower is MEDIUM", engine));
+ruleBlock->addRule(Rule::parse("if Power is HIGH then InversePower is LOW", engine));
engine->addRuleBlock(ruleBlock);