-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRule.py
23 lines (15 loc) · 922 Bytes
/
Rule.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Rule:
def __init__(self, inputVariables, outputVariable, linguisticMembershipFunctions):
self.inputVariables = inputVariables
self.outputVariable = outputVariable
self.linguisticMembershipFunctions = linguisticMembershipFunctions
def EvaluateMamdani(self, inputVariablesValues):
alpha = min([self.linguisticMembershipFunctions[variable](inputVariablesValues[variable]) for variable in self.inputVariables])
def evaluate(x):
return min(alpha, self.linguisticMembershipFunctions[self.outputVariable](x))
return evaluate
def EvaluateLarsen(self, inputVariablesValues):
alpha = min([self.linguisticMembershipFunctions[variable](inputVariablesValues[variable]) for variable in self.inputVariables])
def evaluate(x):
return alpha * self.linguisticMembershipFunctions[self.outputVariable](x)
return evaluate