-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrule.py
More file actions
25 lines (18 loc) · 671 Bytes
/
rule.py
File metadata and controls
25 lines (18 loc) · 671 Bytes
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
class Rule():
def __init__(self, antecedents, consequents, operator):
self.antecedents = antecedents
self.consequents = consequents
self.operator = operator
def calculate_fire(self, ant_memberships):
ant_values = [membership[ant] for membership,
ant in zip(ant_memberships, self.antecedents)]
consequent_fires = {}
if self.operator == FuzzyOperator.AND:
return min(ant_values)
elif self.operator == FuzzyOperator.OR:
return max(ant_values)
else:
raise Exception("Invalid Fuzzy Operator")
class FuzzyOperator():
AND = 0
OR = 1