| 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("linear_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* Tip = new OutputVariable; |
| 33 | Tip->setName("Tip"); |
| 34 | Tip->setDescription(""); |
| 35 | Tip->setEnabled(true); |
| 36 | Tip->setRange(10.000, 20.000); |
| 37 | Tip->setLockValueInRange(false); |
| 38 | Tip->setAggregation(fl::null); |
| 39 | Tip->setDefuzzifier(new WeightedAverage("TakagiSugeno")); |
| 40 | Tip->setDefaultValue(fl::nan); |
| 41 | Tip->setLockPreviousValue(false); |
| 42 | Tip->addTerm(Linear::create("TenPercent", engine, 0.000, 0.000, 10.000)); |
| 43 | Tip->addTerm(Linear::create("FifteenPercent", engine, 0.000, 0.000, 15.000)); |
| 44 | Tip->addTerm(Linear::create("TwentyPercent", engine, 0.000, 0.000, 20.000)); |
| 45 | engine->addOutputVariable(Tip); |
| 46 | |
| 47 | RuleBlock* ruleBlock = new RuleBlock; |
| 48 | ruleBlock->setName(""); |
| 49 | ruleBlock->setDescription(""); |
| 50 | ruleBlock->setEnabled(true); |
| 51 | ruleBlock->setConjunction(new Minimum); |
| 52 | ruleBlock->setDisjunction(fl::null); |
| 53 | ruleBlock->setImplication(fl::null); |
| 54 | ruleBlock->setActivation(new General); |
| 55 | ruleBlock->addRule(Rule::parse("if FoodQuality is Bad and Service is Bad then Tip is TenPercent", engine)); |
| 56 | ruleBlock->addRule(Rule::parse("if FoodQuality is Bad and Service is Good then Tip is FifteenPercent", engine)); |
| 57 | ruleBlock->addRule(Rule::parse("if FoodQuality is Good and Service is Bad then Tip is FifteenPercent", engine)); |
| 58 | ruleBlock->addRule(Rule::parse("if FoodQuality is Good and Service is Good then Tip is TwentyPercent", engine)); |
| 59 | engine->addRuleBlock(ruleBlock); |
| 60 | |
| 61 | |
| 62 | } |