| 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 sugeno_tip_calculator{ |
| 15 |
public static void main(String[] args){ |
| 16 |
|
| 17 |
|
| 18 |
Engine engine = new Engine(); |
| 19 |
engine.setName("sugeno_tip_calculator"); |
| 20 |
engine.setDescription(""); |
| 21 |
|
| 22 |
InputVariable FoodQuality = new InputVariable(); |
| 23 |
FoodQuality.setName("FoodQuality"); |
| 24 |
FoodQuality.setDescription(""); |
| 25 |
FoodQuality.setEnabled(true); |
| 26 |
FoodQuality.setRange(1.000, 10.000); |
| 27 |
FoodQuality.setLockValueInRange(false); |
| 28 |
FoodQuality.addTerm(new Trapezoid("Bad", 0.000, 1.000, 3.000, 7.000)); |
| 29 |
FoodQuality.addTerm(new Trapezoid("Good", 3.000, 7.000, 10.000, 11.000)); |
| 30 |
engine.addInputVariable(FoodQuality); |
| 31 |
|
| 32 |
InputVariable Service = new InputVariable(); |
| 33 |
Service.setName("Service"); |
| 34 |
Service.setDescription(""); |
| 35 |
Service.setEnabled(true); |
| 36 |
Service.setRange(1.000, 10.000); |
| 37 |
Service.setLockValueInRange(false); |
| 38 |
Service.addTerm(new Trapezoid("Bad", 0.000, 1.000, 3.000, 7.000)); |
| 39 |
Service.addTerm(new Trapezoid("Good", 3.000, 7.000, 10.000, 11.000)); |
| 40 |
engine.addInputVariable(Service); |
| 41 |
|
| 42 |
OutputVariable CheapTip = new OutputVariable(); |
| 43 |
CheapTip.setName("CheapTip"); |
| 44 |
CheapTip.setDescription(""); |
| 45 |
CheapTip.setEnabled(true); |
| 46 |
CheapTip.setRange(5.000, 25.000); |
| 47 |
CheapTip.setLockValueInRange(false); |
| 48 |
CheapTip.setAggregation(null); |
| 49 |
CheapTip.setDefuzzifier(new WeightedAverage("TakagiSugeno")); |
| 50 |
CheapTip.setDefaultValue(Double.NaN); |
| 51 |
CheapTip.setLockPreviousValue(false); |
| 52 |
CheapTip.addTerm(new Constant("Low", 10.000)); |
| 53 |
CheapTip.addTerm(new Constant("Medium", 15.000)); |
| 54 |
CheapTip.addTerm(new Constant("High", 20.000)); |
| 55 |
engine.addOutputVariable(CheapTip); |
| 56 |
|
| 57 |
OutputVariable AverageTip = new OutputVariable(); |
| 58 |
AverageTip.setName("AverageTip"); |
| 59 |
AverageTip.setDescription(""); |
| 60 |
AverageTip.setEnabled(true); |
| 61 |
AverageTip.setRange(5.000, 25.000); |
| 62 |
AverageTip.setLockValueInRange(false); |
| 63 |
AverageTip.setAggregation(null); |
| 64 |
AverageTip.setDefuzzifier(new WeightedAverage("TakagiSugeno")); |
| 65 |
AverageTip.setDefaultValue(Double.NaN); |
| 66 |
AverageTip.setLockPreviousValue(false); |
| 67 |
AverageTip.addTerm(new Constant("Low", 10.000)); |
| 68 |
AverageTip.addTerm(new Constant("Medium", 15.000)); |
| 69 |
AverageTip.addTerm(new Constant("High", 20.000)); |
| 70 |
engine.addOutputVariable(AverageTip); |
| 71 |
|
| 72 |
OutputVariable GenerousTip = new OutputVariable(); |
| 73 |
GenerousTip.setName("GenerousTip"); |
| 74 |
GenerousTip.setDescription(""); |
| 75 |
GenerousTip.setEnabled(true); |
| 76 |
GenerousTip.setRange(5.000, 25.000); |
| 77 |
GenerousTip.setLockValueInRange(false); |
| 78 |
GenerousTip.setAggregation(null); |
| 79 |
GenerousTip.setDefuzzifier(new WeightedAverage("TakagiSugeno")); |
| 80 |
GenerousTip.setDefaultValue(Double.NaN); |
| 81 |
GenerousTip.setLockPreviousValue(false); |
| 82 |
GenerousTip.addTerm(new Constant("Low", 10.000)); |
| 83 |
GenerousTip.addTerm(new Constant("Medium", 15.000)); |
| 84 |
GenerousTip.addTerm(new Constant("High", 20.000)); |
| 85 |
engine.addOutputVariable(GenerousTip); |
| 86 |
|
| 87 |
RuleBlock ruleBlock = new RuleBlock(); |
| 88 |
ruleBlock.setName(""); |
| 89 |
ruleBlock.setDescription(""); |
| 90 |
ruleBlock.setEnabled(true); |
| 91 |
ruleBlock.setConjunction(new EinsteinProduct()); |
| 92 |
ruleBlock.setDisjunction(null); |
| 93 |
ruleBlock.setImplication(null); |
| 94 |
ruleBlock.setActivation(new General()); |
| 95 |
ruleBlock.addRule(Rule.parse("if FoodQuality is extremely Bad and Service is extremely Bad then CheapTip is extremely Low and AverageTip is very Low and GenerousTip is Low", engine)); |
| 96 |
ruleBlock.addRule(Rule.parse("if FoodQuality is Good and Service is extremely Bad then CheapTip is Low and AverageTip is Low and GenerousTip is Medium", engine)); |
| 97 |
ruleBlock.addRule(Rule.parse("if FoodQuality is very Good and Service is very Bad then CheapTip is Low and AverageTip is Medium and GenerousTip is High", engine)); |
| 98 |
ruleBlock.addRule(Rule.parse("if FoodQuality is Bad and Service is Bad then CheapTip is Low and AverageTip is Low and GenerousTip is Medium", engine)); |
| 99 |
ruleBlock.addRule(Rule.parse("if FoodQuality is Good and Service is Bad then CheapTip is Low and AverageTip is Medium and GenerousTip is High", engine)); |
| 100 |
ruleBlock.addRule(Rule.parse("if FoodQuality is extremely Good and Service is Bad then CheapTip is Low and AverageTip is Medium and GenerousTip is very High", engine)); |
| 101 |
ruleBlock.addRule(Rule.parse("if FoodQuality is Bad and Service is Good then CheapTip is Low and AverageTip is Medium and GenerousTip is High", engine)); |
| 102 |
ruleBlock.addRule(Rule.parse("if FoodQuality is Good and Service is Good then CheapTip is Medium and AverageTip is Medium and GenerousTip is very High", engine)); |
| 103 |
ruleBlock.addRule(Rule.parse("if FoodQuality is very Bad and Service is very Good then CheapTip is Low and AverageTip is Medium and GenerousTip is High", engine)); |
| 104 |
ruleBlock.addRule(Rule.parse("if FoodQuality is very very Good and Service is very very Good then CheapTip is High and AverageTip is very High and GenerousTip is extremely High", engine)); |
| 105 |
engine.addRuleBlock(ruleBlock); |
| 106 |
|
| 107 |
|
| 108 |
} |
| 109 |
} |