| 1 | #include <fl/Headers.h> |
| 2 | |
| 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("sugeno_tip_calculator"); |
| 10 | engine->setDescription(""); |
| 11 | |
| 12 | InputVariable* FoodQuality = new InputVariable; |
| 13 | FoodQuality->setName("FoodQuality"); |
| 14 | FoodQuality->setDescription(""); |
| 15 | FoodQuality->setEnabled(true); |
| 16 | FoodQuality->setRange(1.000, 10.000); |
| 17 | FoodQuality->setLockValueInRange(false); |
| 18 | FoodQuality->addTerm(new Trapezoid("Bad", 0.000, 1.000, 3.000, 7.000)); |
| 19 | FoodQuality->addTerm(new Trapezoid("Good", 3.000, 7.000, 10.000, 11.000)); |
| 20 | engine->addInputVariable(FoodQuality); |
| 21 | |
| 22 | InputVariable* Service = new InputVariable; |
| 23 | Service->setName("Service"); |
| 24 | Service->setDescription(""); |
| 25 | Service->setEnabled(true); |
| 26 | Service->setRange(1.000, 10.000); |
| 27 | Service->setLockValueInRange(false); |
| 28 | Service->addTerm(new Trapezoid("Bad", 0.000, 1.000, 3.000, 7.000)); |
| 29 | Service->addTerm(new Trapezoid("Good", 3.000, 7.000, 10.000, 11.000)); |
| 30 | engine->addInputVariable(Service); |
| 31 | |
| 32 | OutputVariable* CheapTip = new OutputVariable; |
| 33 | CheapTip->setName("CheapTip"); |
| 34 | CheapTip->setDescription(""); |
| 35 | CheapTip->setEnabled(true); |
| 36 | CheapTip->setRange(5.000, 25.000); |
| 37 | CheapTip->setLockValueInRange(false); |
| 38 | CheapTip->setAggregation(fl::null); |
| 39 | CheapTip->setDefuzzifier(new WeightedAverage("TakagiSugeno")); |
| 40 | CheapTip->setDefaultValue(fl::nan); |
| 41 | CheapTip->setLockPreviousValue(false); |
| 42 | CheapTip->addTerm(new Constant("Low", 10.000)); |
| 43 | CheapTip->addTerm(new Constant("Medium", 15.000)); |
| 44 | CheapTip->addTerm(new Constant("High", 20.000)); |
| 45 | engine->addOutputVariable(CheapTip); |
| 46 | |
| 47 | OutputVariable* AverageTip = new OutputVariable; |
| 48 | AverageTip->setName("AverageTip"); |
| 49 | AverageTip->setDescription(""); |
| 50 | AverageTip->setEnabled(true); |
| 51 | AverageTip->setRange(5.000, 25.000); |
| 52 | AverageTip->setLockValueInRange(false); |
| 53 | AverageTip->setAggregation(fl::null); |
| 54 | AverageTip->setDefuzzifier(new WeightedAverage("TakagiSugeno")); |
| 55 | AverageTip->setDefaultValue(fl::nan); |
| 56 | AverageTip->setLockPreviousValue(false); |
| 57 | AverageTip->addTerm(new Constant("Low", 10.000)); |
| 58 | AverageTip->addTerm(new Constant("Medium", 15.000)); |
| 59 | AverageTip->addTerm(new Constant("High", 20.000)); |
| 60 | engine->addOutputVariable(AverageTip); |
| 61 | |
| 62 | OutputVariable* GenerousTip = new OutputVariable; |
| 63 | GenerousTip->setName("GenerousTip"); |
| 64 | GenerousTip->setDescription(""); |
| 65 | GenerousTip->setEnabled(true); |
| 66 | GenerousTip->setRange(5.000, 25.000); |
| 67 | GenerousTip->setLockValueInRange(false); |
| 68 | GenerousTip->setAggregation(fl::null); |
| 69 | GenerousTip->setDefuzzifier(new WeightedAverage("TakagiSugeno")); |
| 70 | GenerousTip->setDefaultValue(fl::nan); |
| 71 | GenerousTip->setLockPreviousValue(false); |
| 72 | GenerousTip->addTerm(new Constant("Low", 10.000)); |
| 73 | GenerousTip->addTerm(new Constant("Medium", 15.000)); |
| 74 | GenerousTip->addTerm(new Constant("High", 20.000)); |
| 75 | engine->addOutputVariable(GenerousTip); |
| 76 | |
| 77 | RuleBlock* ruleBlock = new RuleBlock; |
| 78 | ruleBlock->setName(""); |
| 79 | ruleBlock->setDescription(""); |
| 80 | ruleBlock->setEnabled(true); |
| 81 | ruleBlock->setConjunction(new EinsteinProduct); |
| 82 | ruleBlock->setDisjunction(fl::null); |
| 83 | ruleBlock->setImplication(fl::null); |
| 84 | ruleBlock->setActivation(new General); |
| 85 | 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)); |
| 86 | 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)); |
| 87 | 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)); |
| 88 | 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)); |
| 89 | 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)); |
| 90 | 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)); |
| 91 | 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)); |
| 92 | 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)); |
| 93 | 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)); |
| 94 | 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)); |
| 95 | engine->addRuleBlock(ruleBlock); |
| 96 | |
| 97 | |
| 98 | } |