This commit is contained in:
Shreya123714 2023-10-28 11:17:21 +05:30
commit cb77a2a22d

View File

@ -10,7 +10,7 @@ import numpy as np
class FuzzySet:
"""
A class for representing and
A class for representing and
manipulating triangular fuzzy sets.
Attributes:
@ -20,27 +20,29 @@ class FuzzySet:
c (float): The right boundary of the fuzzy set.
Methods:
membership(x): Calculate the membership value
membership(x): Calculate the membership value
of an input 'x' in the fuzzy set.
union(other): Calculate the union of this fuzzy set
union(other): Calculate the union of this fuzzy set
with another fuzzy set.
intersection(other): Calculate the intersection of this fuzzy set
intersection(other): Calculate the intersection of this fuzzy set
with another fuzzy set.
complement(): Calculate the complement (negation)
complement(): Calculate the complement (negation)
of this fuzzy set.
plot(): Plot the membership function of the fuzzy set.
"""
def __init__(self, name: str, left_boundary: float, peak: float, right_boundary: float) -> None:
"""
Initializes a triangular fuzzy set with the given parameters.
Initializes a triangular fuzzy set
with the given parameters.
Args:
name (str): The name or label of the fuzzy set.
left_boundary (float): The left boundary of the fuzzy set.
peak (float): The peak (central) value of the fuzzy set.
right_boundary (float): The right boundary of the fuzzy set.
"""
Args:
name (str): The name or label of the fuzzy set.
a (float): The left boundary of the fuzzy set.
b (float): The peak (central) value of
the fuzzy set.
c (float): The right boundary of the fuzzy set.
"""
self.name = name # Fuzzy set name
self.left_boundary = left_boundary # Left boundary
self.peak = peak # Peak value
@ -49,15 +51,15 @@ class FuzzySet:
def membership(self, x):
"""
Calculate the membership value of
Calculate the membership value of
an input 'x' in the fuzzy set.
Args:
x (float): The input value for
x (float): The input value for
which the membership is calculated.
Returns:
float: The membership value of 'x' in
float: The membership value of 'x' in
the fuzzy set.
"""
@ -70,7 +72,7 @@ class FuzzySet:
def union(self, other):
"""
Calculate the union of this fuzzy set
Calculate the union of this fuzzy set
with another fuzzy set.
Args:
@ -78,7 +80,7 @@ class FuzzySet:
to union with.
Returns:
FuzzySet: A new fuzzy
FuzzySet: A new fuzzy
set representing the union.
"""
@ -92,7 +94,7 @@ class FuzzySet:
def intersection(self, other):
"""
Calculate the intersection of this
Calculate the intersection of this
fuzzy set with another fuzzy set.
Args: