summaryrefslogtreecommitdiff
path: root/examples/takagi-sugeno/SimpleDimmer.cpp
diff options
context:
space:
mode:
authorJohannes 'josch' Schauer <josch@mister-muffin.de>2020-10-23 08:27:38 +0200
committerJohannes 'josch' Schauer <josch@mister-muffin.de>2020-10-23 08:27:38 +0200
commit3b91637afd9716881bec3a34c3ace369c82ef61c (patch)
tree2445bd2a7aadd1fd90bc76e5ab7491a8403d6f75 /examples/takagi-sugeno/SimpleDimmer.cpp
parent2b00fcb77bb6e7b769ee34a114679838e00156d1 (diff)
New upstream version 6.0+dfsg
Diffstat (limited to 'examples/takagi-sugeno/SimpleDimmer.cpp')
-rw-r--r--examples/takagi-sugeno/SimpleDimmer.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/examples/takagi-sugeno/SimpleDimmer.cpp b/examples/takagi-sugeno/SimpleDimmer.cpp
new file mode 100644
index 0000000..735096b
--- /dev/null
+++ b/examples/takagi-sugeno/SimpleDimmer.cpp
@@ -0,0 +1,52 @@
+#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("SimpleDimmer");
+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(fl::null);
+Power->setDefuzzifier(new WeightedAverage("TakagiSugeno"));
+Power->setDefaultValue(fl::nan);
+Power->setLockPreviousValue(false);
+Power->addTerm(new Constant("LOW", 0.250));
+Power->addTerm(new Constant("MEDIUM", 0.500));
+Power->addTerm(new Constant("HIGH", 0.750));
+engine->addOutputVariable(Power);
+
+RuleBlock* ruleBlock = new RuleBlock;
+ruleBlock->setName("");
+ruleBlock->setDescription("");
+ruleBlock->setEnabled(true);
+ruleBlock->setConjunction(fl::null);
+ruleBlock->setDisjunction(fl::null);
+ruleBlock->setImplication(fl::null);
+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));
+engine->addRuleBlock(ruleBlock);
+
+
+}