Fuzzy libray for embedded targets developed by zerokol. Read more on: http://zerokol.com/product/51e93616e84c5571b7000018/2/en edit by Bruno Alfano - corrected deallocation of FuzzyOutput

Fuzzy library by Zerokol. Read more on: http://zerokol.com/product/51e93616e84c5571b7000018/2/en

edit by Bruno Alfano - corrected deallocation bug for FuzzyOutput

Committer:
astaff15
Date:
Wed Jun 24 15:08:13 2015 +0000
Revision:
2:460b409e26e8
Parent:
0:66cd67db4f1b
Corrected FuzzyOutput destructor bug

Who changed what in which revision?

UserRevisionLine numberNew contents of line
astaff15 0:66cd67db4f1b 1 /*
astaff15 0:66cd67db4f1b 2 * Robotic Research Group (RRG)
astaff15 0:66cd67db4f1b 3 * State University of Piaui (UESPI), Brazil - Piauí - Teresina
astaff15 0:66cd67db4f1b 4 *
astaff15 0:66cd67db4f1b 5 * FuzzyOutput.cpp
astaff15 0:66cd67db4f1b 6 *
astaff15 0:66cd67db4f1b 7 * Author: Msc. Marvin Lemos <marvinlemos@gmail.com>
astaff15 0:66cd67db4f1b 8 * AJ Alves <aj.alves@zerokol.com>
astaff15 0:66cd67db4f1b 9 * Co authors: Douglas S. Kridi <douglaskridi@gmail.com>
astaff15 0:66cd67db4f1b 10 * Kannya Leal <kannyal@hotmail.com>
astaff15 0:66cd67db4f1b 11 */
astaff15 0:66cd67db4f1b 12 #include "FuzzyRule.h"
astaff15 0:66cd67db4f1b 13
astaff15 0:66cd67db4f1b 14 FuzzyRule::FuzzyRule(){
astaff15 0:66cd67db4f1b 15 }
astaff15 0:66cd67db4f1b 16
astaff15 0:66cd67db4f1b 17 FuzzyRule::FuzzyRule(int index, FuzzyRuleAntecedent* fuzzyRuleAntecedent, FuzzyRuleConsequent* fuzzyRuleConsequent){
astaff15 0:66cd67db4f1b 18 this->index = index;
astaff15 0:66cd67db4f1b 19 this->fuzzyRuleAntecedent = fuzzyRuleAntecedent;
astaff15 0:66cd67db4f1b 20 this->fuzzyRuleConsequent = fuzzyRuleConsequent;
astaff15 0:66cd67db4f1b 21 this->fired = false;
astaff15 0:66cd67db4f1b 22 }
astaff15 0:66cd67db4f1b 23
astaff15 0:66cd67db4f1b 24 int FuzzyRule::getIndex(){
astaff15 0:66cd67db4f1b 25 return this->index;
astaff15 0:66cd67db4f1b 26 }
astaff15 0:66cd67db4f1b 27
astaff15 0:66cd67db4f1b 28 bool FuzzyRule::evaluateExpression(){
astaff15 0:66cd67db4f1b 29 if (this->fuzzyRuleAntecedent != NULL){
astaff15 0:66cd67db4f1b 30 float powerOfAntecedent = this->fuzzyRuleAntecedent->evaluate();
astaff15 0:66cd67db4f1b 31
astaff15 0:66cd67db4f1b 32 (powerOfAntecedent > 0.0) ? (this->fired = true) : (this->fired = false);
astaff15 0:66cd67db4f1b 33
astaff15 0:66cd67db4f1b 34 this->fuzzyRuleConsequent->evaluate(powerOfAntecedent);
astaff15 0:66cd67db4f1b 35 }
astaff15 0:66cd67db4f1b 36 return this->fired;
astaff15 0:66cd67db4f1b 37 }
astaff15 0:66cd67db4f1b 38
astaff15 0:66cd67db4f1b 39 bool FuzzyRule::isFired(){
astaff15 0:66cd67db4f1b 40 return this->fired;
astaff15 0:66cd67db4f1b 41 }