21 lines
609 B
Python
21 lines
609 B
Python
class FuzzyRule:
|
|
def __init__(self):
|
|
self.condition: dict[str, str] = {}
|
|
self.resout: (str, str) = None
|
|
|
|
def add_condition(self, variable: str, value: str):
|
|
self.condition[variable] = value
|
|
return self
|
|
|
|
def add_resout(self, variable: str, value: str):
|
|
self.resout = (variable, value)
|
|
return self
|
|
|
|
def calculate_res(self, variables: dict[str, dict[str, float]]) -> (str, str, float):
|
|
res = 1
|
|
|
|
for i in self.condition:
|
|
res = min(res, variables[i][self.condition[i]])
|
|
|
|
return self.resout[0], self.resout[1], res
|