summaryrefslogtreecommitdiff
path: root/examples/mamdani/Laundry.java
blob: 95cbe7c2160a5a7daf41efdcd9a7b8f3cd3e8e5d (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
79
80
81
82
83
84
85
86
87
88
89
import com.fuzzylite.*;
import com.fuzzylite.activation.*
import com.fuzzylite.defuzzifier.*;
import com.fuzzylite.factory.*;
import com.fuzzylite.hedge.*;
import com.fuzzylite.imex.*;
import com.fuzzylite.norm.*;
import com.fuzzylite.norm.s.*;
import com.fuzzylite.norm.t.*;
import com.fuzzylite.rule.*;
import com.fuzzylite.term.*;
import com.fuzzylite.variable.*;

public class Laundry{
public static void main(String[] args){
//Code automatically generated with fuzzylite 6.0.

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", 0.000, 1.000, 1.000, 1.000, 2.000, 0.800, 5.000, 0.000));
Load.addTerm(Discrete.create("normal", 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", 0.000, 1.000, 2.000, 0.800, 5.000, 0.000));
Dirt.addTerm(Discrete.create("high", 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(Double.NaN);
Detergent.setLockPreviousValue(false);
Detergent.addTerm(Discrete.create("less_than_usual", 10.000, 0.000, 40.000, 1.000, 50.000, 0.000));
Detergent.addTerm(Discrete.create("usual", 40.000, 0.000, 50.000, 1.000, 60.000, 1.000, 80.000, 0.000));
Detergent.addTerm(Discrete.create("more_than_usual", 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(Double.NaN);
Cycle.setLockPreviousValue(false);
Cycle.addTerm(Discrete.create("short", 0.000, 1.000, 10.000, 1.000, 20.000, 0.000));
Cycle.addTerm(Discrete.create("long", 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);


}
}