summaryrefslogtreecommitdiff
path: root/examples/mamdani/Laundry.cpp
blob: cc7492c286628cdff7121c163d89412468344260 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#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("Laundry");
engine->setDescription("");

InputVariable* Load = new InputVariable;
Load->setName("Load");
Load->setDescription("");
Load->setEnabled(true);
Load->setRange(0.000, 6.000);
Load->setLockValueInRange(false);
Load->addTerm(Discrete::create("small", 8, 0.000, 1.000, 1.000, 1.000, 2.000, 0.800, 5.000, 0.000));
Load->addTerm(Discrete::create("normal", 6, 3.000, 0.000, 4.000, 1.000, 6.000, 0.000));
engine->addInputVariable(Load);

InputVariable* Dirt = new InputVariable;
Dirt->setName("Dirt");
Dirt->setDescription("");
Dirt->setEnabled(true);
Dirt->setRange(0.000, 6.000);
Dirt->setLockValueInRange(false);
Dirt->addTerm(Discrete::create("low", 6, 0.000, 1.000, 2.000, 0.800, 5.000, 0.000));
Dirt->addTerm(Discrete::create("high", 8, 1.000, 0.000, 2.000, 0.200, 4.000, 0.800, 6.000, 1.000));
engine->addInputVariable(Dirt);

OutputVariable* Detergent = new OutputVariable;
Detergent->setName("Detergent");
Detergent->setDescription("");
Detergent->setEnabled(true);
Detergent->setRange(0.000, 80.000);
Detergent->setLockValueInRange(false);
Detergent->setAggregation(new Maximum);
Detergent->setDefuzzifier(new MeanOfMaximum(500));
Detergent->setDefaultValue(fl::nan);
Detergent->setLockPreviousValue(false);
Detergent->addTerm(Discrete::create("less_than_usual", 6, 10.000, 0.000, 40.000, 1.000, 50.000, 0.000));
Detergent->addTerm(Discrete::create("usual", 8, 40.000, 0.000, 50.000, 1.000, 60.000, 1.000, 80.000, 0.000));
Detergent->addTerm(Discrete::create("more_than_usual", 4, 50.000, 0.000, 80.000, 1.000));
engine->addOutputVariable(Detergent);

OutputVariable* Cycle = new OutputVariable;
Cycle->setName("Cycle");
Cycle->setDescription("");
Cycle->setEnabled(true);
Cycle->setRange(0.000, 20.000);
Cycle->setLockValueInRange(false);
Cycle->setAggregation(new Maximum);
Cycle->setDefuzzifier(new MeanOfMaximum(500));
Cycle->setDefaultValue(fl::nan);
Cycle->setLockPreviousValue(false);
Cycle->addTerm(Discrete::create("short", 6, 0.000, 1.000, 10.000, 1.000, 20.000, 0.000));
Cycle->addTerm(Discrete::create("long", 4, 10.000, 0.000, 20.000, 1.000));
engine->addOutputVariable(Cycle);

RuleBlock* ruleBlock = new RuleBlock;
ruleBlock->setName("");
ruleBlock->setDescription("");
ruleBlock->setEnabled(true);
ruleBlock->setConjunction(new Minimum);
ruleBlock->setDisjunction(new Maximum);
ruleBlock->setImplication(new Minimum);
ruleBlock->setActivation(new General);
ruleBlock->addRule(Rule::parse("if Load is small and Dirt is not high then Detergent is less_than_usual", engine));
ruleBlock->addRule(Rule::parse("if Load is small and Dirt is high then  Detergent is usual", engine));
ruleBlock->addRule(Rule::parse("if Load is normal and Dirt is low then Detergent is less_than_usual", engine));
ruleBlock->addRule(Rule::parse("if Load is normal and Dirt is high then Detergent is more_than_usual", engine));
ruleBlock->addRule(Rule::parse("if Detergent is usual  or Detergent is less_than_usual  then Cycle is short", engine));
ruleBlock->addRule(Rule::parse("if Detergent is more_than_usual  then Cycle is long", engine));
engine->addRuleBlock(ruleBlock);


}