forked from alvesoaj/eFLL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFuzzyRuleConsequent.cpp
executable file
·62 lines (56 loc) · 1.63 KB
/
FuzzyRuleConsequent.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Robotic Research Group (RRG)
* State University of Piaui (UESPI), Brazil - Piauí - Teresina
*
* FuzzyRuleConsequent.cpp
*
* Author: Msc. Marvin Lemos <marvinlemos@gmail.com>
* AJ Alves <aj.alves@zerokol.com>
* Co authors: Douglas S. Kridi <douglaskridi@gmail.com>
* Kannya Leal <kannyal@hotmail.com>
*/
#include "FuzzyRuleConsequent.h"
// CONSTRUTORES
FuzzyRuleConsequent::FuzzyRuleConsequent(){
this->fuzzySetOutputs = NULL;
this->fuzzySetOutputsCursor = NULL;
}
// DESTRUTOR
FuzzyRuleConsequent::~FuzzyRuleConsequent(){
this->cleanFuzzySets(this->fuzzySetOutputs);
}
// MÉTODOS PÚBLICOS
bool FuzzyRuleConsequent::addOutput(FuzzySet* fuzzySet){
fuzzySetOutputArray *aux;
// Alocando espaço na memória
if((aux = (fuzzySetOutputArray *) malloc(sizeof(fuzzySetOutputArray))) == NULL){
return false;
}
aux->fuzzySet = fuzzySet;
aux->next = NULL;
if(this->fuzzySetOutputs == NULL){
this->fuzzySetOutputs = aux;
this->fuzzySetOutputsCursor = aux;
}else{
this->fuzzySetOutputsCursor->next = aux;
this->fuzzySetOutputsCursor = aux;
}
return true;
}
bool FuzzyRuleConsequent::evaluate(float power){
fuzzySetOutputArray *aux;
aux = this->fuzzySetOutputs;
while(aux != NULL){
aux->fuzzySet->setPertinence(power);
aux = aux->next;
}
return true;
}
// MÉTODOS PRIVADOS
void FuzzyRuleConsequent::cleanFuzzySets(fuzzySetOutputArray* aux){
if(aux != NULL){
// Esvaziando a memória alocada
this->cleanFuzzySets(aux->next);
free(aux);
}
}