This repository has been archived by the owner on Jun 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
fuzzy_operators.bmx
166 lines (146 loc) · 3.97 KB
/
fuzzy_operators.bmx
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
Rem
Copyright (c) 2010 Christiaan Kras
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
End Rem
Rem
bbdoc: a fuzzy AND operator type
about: Type to provider the fuzzy AND operator to be used in the creation of a fuzzy rule base
End Rem
Type TFzAND Extends TFuzzyTerm
'an instance of this class may AND together up to 4 terms
Field m_Terms:TList
Rem
bbdoc:
End Rem
Method New()
Self.m_Terms = New TList
End Method
Rem
bbdoc: Creates AND operator
End Rem
Method Create:TFzAND(ops:TFuzzyTerm[])
For Local op:TFuzzyTerm = EachIn ops
Self.m_Terms.AddLast(op.Clone())
Next
Return Self
End Method
Rem
bbdoc: Clones AND operator
End Rem
Method Clone:TFuzzyTerm()
Local term:TFzAND = New TFzAND
term.m_Terms = Self.m_Terms.Copy()
Return term
End Method
Rem
bbdoc: the AND operator returns the minimum DOM of the sets it is operating on
End Rem
Method GetDOM:Double()
Local smallest:Double = 10 ^ 308
For Local curTerm:TFuzzyTerm = EachIn Self.m_Terms
If curTerm.GetDOM() < smallest
smallest = curTerm.GetDOM()
End If
Next
Return smallest
End Method
Rem
bbdoc: Clears DOM
End Rem
Method ClearDOM()
For Local curTerm:TFuzzyTerm = EachIn Self.m_Terms
curTerm.ClearDOM()
Next
End Method
Rem
bbdoc:
End Rem
Method ORwithDOM(val:Double)
For Local curTerm:TFuzzyTerm = EachIn Self.m_Terms
curTerm.ORwithDOM(val)
Next
End Method
End Type
Rem
bbdoc: Create AND operator with any number of terms
about: This is a shortcut to New TFzAND.Create(ops)
End Rem
Function FzAND:TFzAND(ops:TFuzzyTerm[])
Return New TFzAND.Create(ops)
End Function
Rem
bbdoc: a fuzzy OR operator type
about: Type to provider the fuzzy OR operator to be used in the creation of a fuzzy rule base
End Rem
Type TFzOR Extends TFuzzyTerm
'an instance of this class may OR together up to 4 terms
Field m_Terms:TList
Rem
bbdoc:
End Rem
Method New()
Self.m_Terms = New TList
End Method
Rem
bbdoc: Creates OR operator
End Rem
Method Create:TFzOR(ops:TFuzzyTerm[])
For Local op:TFuzzyTerm = EachIn ops
Self.m_Terms.AddLast(op.Clone())
Next
Return Self
End Method
Rem
bbdoc: Clones OR operator
End Rem
Method Clone:TFuzzyTerm()
Local term:TFzOR = New TFzOR
term.m_Terms = Self.m_Terms.Copy()
Return term
End Method
Rem
bbdoc: the OR operator returns the maximum DOM of the sets it is operating on
End Rem
Method GetDOM:Double()
Local largest:Double = -(10 ^ -38)
For Local curTerm:TFuzzyTerm = EachIn Self.m_Terms
If curTerm.GetDOM() > largest
largest = curTerm.GetDOM()
End If
Next
Return largest
End Method
Rem
bbdoc: Clears DOM
End Rem
Method ClearDOM()
Assert 0, "TFzOr.ClearDOM: invalid context"
End Method
Rem
bbdoc:
End Rem
Method ORwithDOM(val:Double)
Assert 0, "TFzOr.ORwithDOM: invalid context"
End Method
End Type
Rem
bbdoc: Create OR operator with any number of terms
about: This is a shortcut to New TFzOR.Create(ops)
End Rem
Function FzOR:TFzOR(ops:TFuzzyTerm[])
Return New TFzOR.Create(ops)
End Function