forked from alvesoaj/eFLL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFuzzySet.cpp
executable file
·77 lines (67 loc) · 1.72 KB
/
FuzzySet.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
/*
* Robotic Research Group (RRG)
* State University of Piaui (UESPI), Brazil - Piauí - Teresina
*
* FuzzySet.cpp
*
* Author: Msc. Marvin Lemos <[email protected]>
* Co authors: AJ Alves <[email protected]>
* Douglas S. Kridi <[email protected]>
* Kannya Leal <[email protected]>
*/
#include "FuzzySet.h"
FuzzySet::FuzzySet(float a, float b, float c, float d){
this->a = a;
this->b = b;
this->c = c;
this->d = d;
this->pertinence = 0.0;
}
float FuzzySet::getPointA(){
return this->a;
}
float FuzzySet::getPointB(){
return this->b;
}
float FuzzySet::getPointC(){
return this->c;
}
float FuzzySet::getPointD(){
return this->d;
}
bool FuzzySet::calculatePertinence(float crispValue){
float slope;
if (crispValue < this->a){
if (this->a == this->b && this->b != this->c && this->c != this->d){
this->pertinence = 1;
}else{
this->pertinence = 0;
}
}else if (crispValue >= this->a && crispValue < this->b){
slope = 1 / (this->b - this->a);
this->pertinence = slope * (crispValue - this->b) + 1;
}else if (crispValue >= this->b && crispValue <= this->c){
this->pertinence = 1;
}else if (crispValue > this->c && crispValue <= this->d){
slope = 1 / (this->c - this->d);
this->pertinence = slope * (crispValue - this->c) + 1;
}else if (crispValue > this->d){
if (this->c == this->d && this->c != this->b && this->b != this->a){
this->pertinence = 1;
}else{
this->pertinence = 0;
}
}
return true;
}
void FuzzySet::setPertinence(float pertinence){
if(this->pertinence < pertinence){
this->pertinence = pertinence;
}
}
float FuzzySet::getPertinence(){
return this->pertinence;
}
void FuzzySet::reset(){
this->pertinence = 0.0;
}