1 import com.fuzzylite.*;
2 import com.fuzzylite.activation.*
3 import com.fuzzylite.defuzzifier.*;
4 import com.fuzzylite.factory.*;
5 import com.fuzzylite.hedge.*;
6 import com.fuzzylite.imex.*;
7 import com.fuzzylite.norm.*;
8 import com.fuzzylite.norm.s.*;
9 import com.fuzzylite.norm.t.*;
10 import com.fuzzylite.rule.*;
11 import com.fuzzylite.term.*;
12 import com.fuzzylite.variable.*;
13 
14 public class SimpleDimmerInverse{
main(String[] args)15 public static void main(String[] args){
16 //Code automatically generated with fuzzylite 6.0.
17 
18 Engine engine = new Engine();
19 engine.setName("SimpleDimmerInverse");
20 engine.setDescription("");
21 
22 InputVariable Ambient = new InputVariable();
23 Ambient.setName("Ambient");
24 Ambient.setDescription("");
25 Ambient.setEnabled(true);
26 Ambient.setRange(0.000, 1.000);
27 Ambient.setLockValueInRange(false);
28 Ambient.addTerm(new Triangle("DARK", 0.000, 0.250, 0.500));
29 Ambient.addTerm(new Triangle("MEDIUM", 0.250, 0.500, 0.750));
30 Ambient.addTerm(new Triangle("BRIGHT", 0.500, 0.750, 1.000));
31 engine.addInputVariable(Ambient);
32 
33 OutputVariable Power = new OutputVariable();
34 Power.setName("Power");
35 Power.setDescription("");
36 Power.setEnabled(true);
37 Power.setRange(0.000, 1.000);
38 Power.setLockValueInRange(false);
39 Power.setAggregation(new Maximum());
40 Power.setDefuzzifier(new Centroid(200));
41 Power.setDefaultValue(Double.NaN);
42 Power.setLockPreviousValue(false);
43 Power.addTerm(new Triangle("LOW", 0.000, 0.250, 0.500));
44 Power.addTerm(new Triangle("MEDIUM", 0.250, 0.500, 0.750));
45 Power.addTerm(new Triangle("HIGH", 0.500, 0.750, 1.000));
46 engine.addOutputVariable(Power);
47 
48 OutputVariable InversePower = new OutputVariable();
49 InversePower.setName("InversePower");
50 InversePower.setDescription("");
51 InversePower.setEnabled(true);
52 InversePower.setRange(0.000, 1.000);
53 InversePower.setLockValueInRange(false);
54 InversePower.setAggregation(new Maximum());
55 InversePower.setDefuzzifier(new Centroid(500));
56 InversePower.setDefaultValue(Double.NaN);
57 InversePower.setLockPreviousValue(false);
58 InversePower.addTerm(new Cosine("LOW", 0.200, 0.500));
59 InversePower.addTerm(new Cosine("MEDIUM", 0.500, 0.500));
60 InversePower.addTerm(new Cosine("HIGH", 0.800, 0.500));
61 engine.addOutputVariable(InversePower);
62 
63 RuleBlock ruleBlock = new RuleBlock();
64 ruleBlock.setName("");
65 ruleBlock.setDescription("");
66 ruleBlock.setEnabled(true);
67 ruleBlock.setConjunction(null);
68 ruleBlock.setDisjunction(null);
69 ruleBlock.setImplication(new Minimum());
70 ruleBlock.setActivation(new General());
71 ruleBlock.addRule(Rule.parse("if Ambient is DARK then Power is HIGH", engine));
72 ruleBlock.addRule(Rule.parse("if Ambient is MEDIUM then Power is MEDIUM", engine));
73 ruleBlock.addRule(Rule.parse("if Ambient is BRIGHT then Power is LOW", engine));
74 ruleBlock.addRule(Rule.parse("if Power is LOW then InversePower is HIGH", engine));
75 ruleBlock.addRule(Rule.parse("if Power is MEDIUM then InversePower is MEDIUM", engine));
76 ruleBlock.addRule(Rule.parse("if Power is HIGH then InversePower is LOW", engine));
77 engine.addRuleBlock(ruleBlock);
78 
79 
80 }
81 }
82