Variable
Variable
¶
Base class for linguistic variables.
Attributes¶
drange
property
¶
drange: float
Return the magnitude of the range of the variable.
Returns:
Type | Description |
---|---|
float
|
|
range
property
writable
¶
Functions¶
__getitem__
¶
__init__
¶
__init__(
name: str = "",
description: str = "",
enabled: bool = True,
minimum: float = -inf,
maximum: float = inf,
lock_range: bool = False,
terms: Iterable[Term] | None = None,
) -> None
Constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
name of the variable |
''
|
description |
str
|
description of the variable |
''
|
enabled |
bool
|
enable the variable |
True
|
minimum |
float
|
minimum value of the range |
-inf
|
maximum |
float
|
maximum value of the range |
inf
|
lock_range |
bool
|
lock the value to the range of the variable |
False
|
terms |
Iterable[Term] | None
|
list of terms |
None
|
__iter__
¶
__repr__
¶
__repr__() -> str
Return the code to construct the variable in Python.
Returns:
Type | Description |
---|---|
str
|
code to construct the variable in Python. |
__str__
¶
__str__() -> str
Return the code to construct the variable in the FuzzyLite Language.
Returns:
Type | Description |
---|---|
str
|
code to construct the variable in the FuzzyLite Language. |
fuzzify
¶
Return the fuzzy representation of \(x\).
The fuzzy representation is computed by evaluating the membership function of \(x\) for each term \(i\), resulting in a fuzzy value in the form \(\tilde{x}=\sum_i{\mu_i(x)/i}\)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Scalar
|
value to fuzzify |
required |
Returns:
Type | Description |
---|---|
Array[str_]
|
fuzzy value expressed as \(\sum_i{\mu_i(x)/i}\). |
highest_membership
¶
term
¶
Find the term by the name or index.
The best performance is \(O(1)\) when using indices, and the worst performance is \(O(n)\) when using names, where \(n\) is the number terms.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name_or_index |
str | int
|
name or index of the term |
required |
Returns:
Type | Description |
---|---|
Term
|
term by the name or index |
Raises:
Type | Description |
---|---|
ValueError
|
when there is no term by the given name. |
IndexError
|
when the index is out of range |