1 #include <fl/Headers.h>
2 
main(int argc,char ** argv)3 int main(int argc, char** argv){
4 //Code automatically generated with fuzzylite 6.0.
5 
6 using namespace fl;
7 
8 Engine* engine = new Engine;
9 engine->setName("SimpleDimmerChained");
10 engine->setDescription("");
11 
12 InputVariable* Ambient = new InputVariable;
13 Ambient->setName("Ambient");
14 Ambient->setDescription("");
15 Ambient->setEnabled(true);
16 Ambient->setRange(0.000, 1.000);
17 Ambient->setLockValueInRange(false);
18 Ambient->addTerm(new Triangle("DARK", 0.000, 0.250, 0.500));
19 Ambient->addTerm(new Triangle("MEDIUM", 0.250, 0.500, 0.750));
20 Ambient->addTerm(new Triangle("BRIGHT", 0.500, 0.750, 1.000));
21 engine->addInputVariable(Ambient);
22 
23 OutputVariable* Power = new OutputVariable;
24 Power->setName("Power");
25 Power->setDescription("");
26 Power->setEnabled(true);
27 Power->setRange(0.000, 1.000);
28 Power->setLockValueInRange(false);
29 Power->setAggregation(new Maximum);
30 Power->setDefuzzifier(new Centroid(200));
31 Power->setDefaultValue(fl::nan);
32 Power->setLockPreviousValue(false);
33 Power->addTerm(new Triangle("LOW", 0.000, 0.250, 0.500));
34 Power->addTerm(new Triangle("MEDIUM", 0.250, 0.500, 0.750));
35 Power->addTerm(new Triangle("HIGH", 0.500, 0.750, 1.000));
36 engine->addOutputVariable(Power);
37 
38 OutputVariable* InversePower = new OutputVariable;
39 InversePower->setName("InversePower");
40 InversePower->setDescription("");
41 InversePower->setEnabled(true);
42 InversePower->setRange(0.000, 1.000);
43 InversePower->setLockValueInRange(false);
44 InversePower->setAggregation(new Maximum);
45 InversePower->setDefuzzifier(new Centroid(500));
46 InversePower->setDefaultValue(fl::nan);
47 InversePower->setLockPreviousValue(false);
48 InversePower->addTerm(new Cosine("LOW", 0.200, 0.500));
49 InversePower->addTerm(new Cosine("MEDIUM", 0.500, 0.500));
50 InversePower->addTerm(new Cosine("HIGH", 0.800, 0.500));
51 engine->addOutputVariable(InversePower);
52 
53 RuleBlock* ruleBlock = new RuleBlock;
54 ruleBlock->setName("");
55 ruleBlock->setDescription("");
56 ruleBlock->setEnabled(true);
57 ruleBlock->setConjunction(fl::null);
58 ruleBlock->setDisjunction(fl::null);
59 ruleBlock->setImplication(new Minimum);
60 ruleBlock->setActivation(new General);
61 ruleBlock->addRule(Rule::parse("if Ambient is DARK then Power is HIGH", engine));
62 ruleBlock->addRule(Rule::parse("if Ambient is MEDIUM then Power is MEDIUM", engine));
63 ruleBlock->addRule(Rule::parse("if Ambient is BRIGHT then Power is LOW", engine));
64 ruleBlock->addRule(Rule::parse("if Power is LOW then InversePower is HIGH", engine));
65 ruleBlock->addRule(Rule::parse("if Power is MEDIUM then InversePower is MEDIUM", engine));
66 ruleBlock->addRule(Rule::parse("if Power is HIGH then InversePower is LOW", engine));
67 engine->addRuleBlock(ruleBlock);
68 
69 
70 }
71