-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
130 lines (116 loc) · 4.1 KB
/
tests.py
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from fuzzy_system import *
def print_degree(x : float, fs : FuzzySet) -> None:
print("Degree at value %f : %f" % (x, fs.degree_at_value(x)))
def print_degrees(fs : FuzzySet) -> None:
print_degree(-2, fs)
print_degree(0, fs)
print_degree(25, fs)
print_degree(30, fs)
print_degree(48, fs)
print_degree(50, fs)
print_degree(60, fs)
print_degree(75, fs)
print_degree(100, fs)
print_degree(120, fs)
fz = FuzzySet(0, 100)
pt1 = Point2D(0, 1)
pt2 = Point2D(50, 0)
pt3 = Point2D(100, 0)
fz.add_point(pt3)
fz.add_point(pt2)
fz.add_point(pt1)
tifz = TriangularFuzzySet(0, 100, 30, 50, 70)
itifz = ~tifz
trfz = TrapezoidalFuzzySet(0, 100, 30, 50, 70, 80)
trfz2 = TrapezoidalFuzzySet(0, 100, 30, 50, 70, 80)
lfz = LeftFuzzySet(0, 100, 30, 50)
rfz = RightFuzzySet(0, 100, 70, 80)
# Calcul des degrés
#print("**** Degree Fuzzy Set quelconque ****")
#print_degrees(fz)
#print("\n**** Test Triangular Fuzzy Set ****")
#print_degrees(tifz)
#print("\n**** Test Inversed Triangular Fuzzy Set ****")
#print_degrees(itifz)
#print("\n**** Test Trapezoidal Fuzzy Set ****")
#print_degrees(trfz)
#print("\n**** Test Left Fuzzy Set ****")
#print_degrees(lfz)
#print("\n**** Test Right Fuzzy Set ****")
#print_degrees(rfz)
#print("\n**** Print ****")
#print("Trap Fuzzy Set :")
#print(trfz)
#print("Left Fuzzy Set :")
#print(lfz)
#print("Triang Fuzzy Set :")
#print(tifz)
#print("Inverse triang Fuzzy Set :")
#print(itifz)
# Test des opérateurs
#print("\n**** Test operators ****")
#print("1/2 Trap Fuzzy Set :")
#print((trfz * 0.5))
#print("1/4 Left Fuzzy Set :")
#print((lfz * 0.25))
## Test égalité
#print("\n**** Test equality ****")
#print("Trap Fuzzy Set 1 :")
#print(trfz)
#print("Trap Fuzzy Set 2 :")
#print(trfz2)
#print("TRFZ == TRFZ2 (true) : " + str(trfz == trfz2))
#print("TRFZ != TRFZ2 (false) : " + str(trfz != trfz2))
#print("TRFZ == LFZ (false) : " + str(trfz == lfz))
## Test intersection
#print("\n**** Test intersection")
#print("FS1 : " + str(trfz))
#print("FS2 : " + str(lfz))
#print("TIFS : " + str(tifz))
#print("FS : " + str(fz))
#print("****")
#print("FS1 & FS2 : " + str(trfz & lfz))
#print("FS2 & FS1 : " + str(lfz & trfz))
#print("FS1 & FS1 : " + str(trfz & trfz))
#print("FS1 & 0.5 * FS2 : " + str(trfz & (lfz * 0.5)))
#print("0.5 * FS1 & FS2 : " + str((trfz * 0.5) & lfz))
#print("FS1 & TIFS : " + str(trfz & tifz))
#print("FS1 & FS : " + str(trfz & fz))
#print("FS2 & TIFS : " + str(lfz & tifz))
#print("FS2 & FS : " + str(lfz & fz))
#print("tri1 & tri2 : " + str(TriangularFuzzySet(20, 100, 40, 50, 60) & TriangularFuzzySet(0, 80, 30, 40, 50)))
#print("tri2 & tri1 : " + str(TriangularFuzzySet(0, 80, 30, 40, 50) & TriangularFuzzySet(20, 100, 40, 50, 60)))
## Test union
#print("\n**** Test union")
#print("FS1 : " + str(trfz))
#print("FS2 : " + str(lfz))
#print("TIFS : " + str(tifz))
#print("FS : " + str(fz))
#print("****")
#print("FS1 | FS2 : " + str((trfz | lfz)))
#print("FS2 | FS1 : " + str((lfz | trfz)))
#print("FS1 | FS1 : " + str((trfz | trfz)))
#print("FS1 | 0.5 * FS2 : " + str((trfz | (lfz * 0.5))))
#print("0.5 * FS1 | FS2 : " + str(((trfz * 0.5) | lfz)))
#print("FS1 | TIFS : " + str((trfz | tifz)))
#print("FS1 | FS : " + str((trfz | fz)))
#print("FS2 | TIFS : " + str((lfz | tifz)))
#print("FS2 | FS : " + str((lfz | fz)))
#print("tri1 | tri2 : " + str((TriangularFuzzySet(20, 100, 40, 50, 60) | TriangularFuzzySet(0, 80, 30, 40, 50))))
#print("tri2 | tri1 : " + str((TriangularFuzzySet(0, 80, 30, 40, 50) | TriangularFuzzySet(20, 100, 40, 50, 60))))
## Test centre de gravité
#print("\n**** Test centre de gravité")
#print("TRFS : " + str(trfz))
#print("TRFS CoG : " + str(trfz.centroid()))
#print("1/2 TRFS : " + str((trfz*0.5)))
#print("1/2 TRFS CoG : " + str((trfz*0.5).centroid()))
#print("TIFS : " + str(tifz))
#print("TIFS CoG : " + str(tifz.centroid()))
#print("LFS : " + str(lfz))
#print("LFS CoG : " + str(lfz.centroid()))
#print("FS : " + str(fz))
#print("FS CoG : " + str(fz.centroid()))
#print("TRFS & LFZ : " + str((trfz & lfz)))
#print("TRFS & LFZ CoG : " + str((trfz & lfz).centroid()))
#print("TRFS | LFZ : " + str((trfz | lfz)))
#print("TRFS | LFZ CoG : " + str((trfz | lfz).centroid()))