soft.fuzzy.sets package

Subpackages

Submodules

soft.fuzzy.sets.discrete module

Implements the discrete fuzzy sets.

class soft.fuzzy.sets.discrete.BaseDiscreteFuzzySet(formulas: list, name: str)

Bases: ABC

A parent class for all fuzzy sets to inherit. Allows the user to visualize the fuzzy set.

abstract degree(element) NoReturn

Calculates degree of membership for the provided “element” where element is a(n) int/float.

Parameters:

element – The element is from the universe of discourse.

Returns:

NotImplementedError as this is an abstract method.

fetch(element: int | float)

Fetch the corresponding formula for the provided element where element is a(n) int/float.

Parameters:

element ('float') – The element is from the universe of discourse X.

Returns:

formula – Returns the tuple containing the formula and corresponding Interval. Returns None if a formula for the element could not be found.

Return type:

‘tuple’/’None’

plot(lower: float = 0, upper: float = 100, samples: int = 100) -> (<class 'matplotlib.figure.Figure'>, <class 'matplotlib.axes._axes.Axes'>)

Graphs the fuzzy set in the universe of elements.

Parameters:
  • lower ('float', optional) – Default value is 0. Specifies the infimum value for the graph.

  • upper ('float', optional) – Default value is 100. Specifies the supremum value for the graph.

  • samples ('int', optional) – Default value is 100. Specifies the number of values to test in the domain to approximate the graph. A higher sample value will yield a higher resolution of the graph, but large values will lead to performance issues.

class soft.fuzzy.sets.discrete.DiscreteFuzzySet(formulas: List[tuple], name: str | None = None)

Bases: BaseDiscreteFuzzySet

An ordinary fuzzy set that is of type 1 and level 1.

degree(element: int | float)

Calculates degree of membership for the provided element where element is a(n) int/float.

Parameters:

element ('float') – The element is from the universe of discourse X.

Returns:

mu – The degree of membership for the element.

Return type:

‘float’

height() float

Calculates the height of the fuzzy set.

Returns:

The height, or supremum, of the fuzzy set.

class soft.fuzzy.sets.discrete.FuzzyVariable(fuzzy_sets: List[BaseDiscreteFuzzySet], name=None)

Bases: BaseDiscreteFuzzySet

A fuzzy variable, or linguistic variable, that contains fuzzy sets.

degree(element: int | float) Tuple[float]

Calculates the degree of membership for the provided element value where element is a(n) int/float.

Parameters:

element – The element from the universe of discourse.

Returns:

The degree of membership for the element.

plot(lower: float = 0, upper: float = 100, samples: int = 100) -> (<class 'matplotlib.figure.Figure'>, <class 'matplotlib.axes._axes.Axes'>)

Graphs the fuzzy set in the universe of elements.

Parameters:
  • lower – Default value is 0. Specifies the infimum value for the graph.

  • upper – Default value is 100. Specifies the supremum value for the graph.

  • samples – Default value is 100. Specifies the number of values to test in the domain

  • resolution (to approximate the graph. A higher sample value will yield a higher)

  • graph (of the)

  • issues. (but large values will lead to performance)

Returns:

None

Module contents