forked from alvesoaj/eFLL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFuzzyOutput.cpp
executable file
·92 lines (76 loc) · 2.3 KB
/
FuzzyOutput.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* Robotic Research Group (RRG)
* State University of Piaui (UESPI), Brazil - Piauí - Teresina
*
* FuzzyOutput.cpp
*
* Author: Msc. Marvin Lemos <[email protected]>
* Co authors: AJ Alves <[email protected]>
* Douglas S. Kridi <[email protected]>
* Kannya Leal <[email protected]>
*/
#include "FuzzyOutput.h"
// CONSTRUTORES
FuzzyOutput::FuzzyOutput(int index) : FuzzyIO(index){
}
// DESTRUTOR
FuzzyOutput::~FuzzyOutput(){
}
// MÉTODOS PÚBLICOS
bool FuzzyOutput::truncate(){
fuzzySetArray *aux;
float point, point1, point2, slope = 0.0;
// esvaziando a composição
this->fuzzyComposition.empty();
aux = this->fuzzySets;
while(aux != NULL){
if(aux->fuzzySet->getPertinence() > 0.0){
if(this->fuzzyComposition.checkPoint(aux->fuzzySet->getPointA(), 0.0) == false){
this->fuzzyComposition.addPoint(aux->fuzzySet->getPointA(), 0.0);
}
if(this->fuzzyComposition.checkPoint(aux->fuzzySet->getPointB(), aux->fuzzySet->getPertinence()) == false){
this->fuzzyComposition.addPoint(aux->fuzzySet->getPointB(), aux->fuzzySet->getPertinence());
}
if(this->fuzzyComposition.checkPoint(aux->fuzzySet->getPointC(), aux->fuzzySet->getPertinence()) == false){
this->fuzzyComposition.addPoint(aux->fuzzySet->getPointC(), aux->fuzzySet->getPertinence());
}
if(this->fuzzyComposition.checkPoint(aux->fuzzySet->getPointD(), 0.0) == false){
this->fuzzyComposition.addPoint(aux->fuzzySet->getPointD(), 0.0);
}
}
aux = aux->next;
}
this->fuzzyComposition.build();
return true;
}
float FuzzyOutput::getCrispOutput(){
return this->fuzzyComposition.avaliate();
}
// Um simples Bubble Sort
bool FuzzyOutput::order(){
fuzzySetArray *aux1;
fuzzySetArray *aux2;
aux1 = this->fuzzySets;
aux2 = this->fuzzySets;
while(aux1 != NULL){
while(aux2 != NULL){
if(aux2->next != NULL){
if(aux2->fuzzySet->getPointA() > aux2->next->fuzzySet->getPointA()){
this->swap(aux2, aux2->next);
}
}
aux2 = aux2->next;
}
aux2 = this->fuzzySets;
aux1 = aux1->next;
}
return true;
}
// MÉTODOS PRIVADOS
bool FuzzyOutput::swap(fuzzySetArray* fuzzySetA, fuzzySetArray* fuzzySetB){
FuzzySet* aux;
aux = fuzzySetA->fuzzySet;
fuzzySetA->fuzzySet = fuzzySetB->fuzzySet;
fuzzySetB->fuzzySet = aux;
return true;
}