fuzzy_set.triangular_fuzzy_number module#
- class fuzzy_set.triangular_fuzzy_number.TriangularFuzzyNumber(a1: float, a2: float, a3: float)[source]#
Bases:
TrapezoidalFuzzyNumberA Triangular Fuzzy Number is a Trapezoidal Fuzzy Number whose core is reduced to a single value. Therefore, it is piecewise linear and continuous and has a triangular shape. As a consequence, it is fully characterized by a triple of real numbers, denoted by \([x_1, x_2, x_3]\), where:
\(a_1 \le a_2 \le a_3\);
\([a_1, a_3]\) is its support;
\(\{a_2\}\) is its core.
Example:
>>> from fuzzy_set import TriangularFuzzyNumber >>> t1 = TriangularFuzzyNumber(1, 3, 10) >>> t2 = TriangularFuzzyNumber(2, 5, 8) >>> t1 + t2 TriangularFuzzyNumber<(3, 8, 18)> >>> t1 - t2 TriangularFuzzyNumber<(-7, -2, 8)> >>> t1 * t2 TriangularFuzzyNumber<(2, 15, 80)> >>> t1 / t2 TriangularFuzzyNumber<(0.125, 0.6, 5.0)>
Example:
import matplotlib.pyplot as plt from operator import __add__, __sub__, __mul__, __truediv__ (fig, axs) = plt.subplots(2, 2) for (ij, (op, opname)) in { (0, 0): (__add__, "+"), (0, 1): (__sub__, "-"), (1, 0): (__mul__, "\cdot"), (1, 1): (__truediv__, "/"), }.items(): ax = axs[ij] title = f"$a_1 {opname} a_2$" ax.set_title(title) t1.plot(ax=ax, label="$a_1$") t2.plot(ax=ax, label="$a_2$") op(t1, t2).plot(ax=axs[ij], label=title) ax.grid() ax.legend() ax.legend(bbox_to_anchor=(1, 0.5), loc="center left") plt.tight_layout()
- property a1: float#
- property a2: float#
- property a3: float#