Skip to content

Activation

Activation

Bases: ABC

Abstract class for activation methods.

Activation methods implement the criteria to activate the rules in a rule block. Activation methods should process every rule and determine whether the rule is to be activated or deactivated.

related

Functions

__repr__

__repr__() -> str

Returns the code to construct the activation method in Python.

Returns:

Type Description
str

code to construct the activation method in Python.

__str__

__str__() -> str

Return the code to construct the activation method in the FuzzyLite Language.

Returns:

Type Description
str

code to construct the activation method in the FuzzyLite Language.

activate abstractmethod

activate(rule_block: RuleBlock) -> None

Implement the activation method of the rule block.

Parameters:

Name Type Description Default
rule_block RuleBlock

rule block to activate

required

assert_is_not_vector

assert_is_not_vector(activation_degree: Scalar) -> None

Assert that the activation degree is not a vector.

Parameters:

Name Type Description Default
activation_degree Scalar

activation degree to assert

required

Raises:

Type Description
ValueError

if the activation degree contains more than one element

configure

configure(parameters: str) -> None

Configure the activation method with the parameters.

Parameters:

Name Type Description Default
parameters str

list of space-separated parameter values

required

parameters

parameters() -> str

Return the parameters of the activation method.

Returns:

Type Description
str

parameters of the activation method.

First

Bases: Activation

Activate the first \(n\) rules (in insertion order) whose activation degrees are greater than or equal to the threshold.

related

Attributes

rules instance-attribute

rules = rules

threshold instance-attribute

threshold = threshold

Functions

__init__

__init__(rules: int = 1, threshold: float = 0.0) -> None

Constructor.

Parameters:

Name Type Description Default
rules int

maximum number of rules to activate

1
threshold float

minimum activation degree required to activate the rule.

0.0

activate

activate(rule_block: RuleBlock) -> None

Activate the first \(n\) rules (in insertion order) whose activation degrees are greater than or equal to the threshold.

Parameters:

Name Type Description Default
rule_block RuleBlock

rule block to activate.

required

configure

configure(parameters: str) -> None

Configure the activation method with the parameters.

Parameters:

Name Type Description Default
parameters str

number of rules and threshold (eg, 3 0.5).

required

parameters

parameters() -> str

Return the number of rules and threshold.

Returns:

Type Description
str

number of rules and threshold.

General

Bases: Activation

Activation method that activates every rule of a rule block in insertion order.

related

Functions

activate

activate(rule_block: RuleBlock) -> None

Activate every rule in the rule block in the order they were added.

Parameters:

Name Type Description Default
rule_block RuleBlock

rule block to activate.

required

Highest

Bases: Activation

Activation method that activates only the rules with the highest activation degrees in descending order.

related

Attributes

rules instance-attribute

rules = rules

Functions

__init__

__init__(rules: int = 1) -> None

Constructor.

Parameters:

Name Type Description Default
rules int

number of rules to activate.

1

activate

activate(rule_block: RuleBlock) -> None

Activate the rules with the highest activation degrees.

Parameters:

Name Type Description Default
rule_block RuleBlock

rule block to activate.

required

configure

configure(parameters: str) -> None

Configure the activation method with the parameters.

Parameters:

Name Type Description Default
parameters str

number of rules (eg, 3).

required

parameters

parameters() -> str

Return the number of rules.

Returns:

Type Description
str

number of rules.

Last

Bases: Activation

Activation method that activates the first \(n\) rules (in reverse insertion order) whose activation degrees are greater than or equal to the threshold.

related

Attributes

rules instance-attribute

rules = rules

threshold instance-attribute

threshold = threshold

Functions

__init__

__init__(rules: int = 1, threshold: float = 0.0) -> None

Constructor.

Parameters:

Name Type Description Default
rules int

maximum number of rules to activate

1
threshold float

minimum activation degree required to activate the rule.

0.0

activate

activate(rule_block: RuleBlock) -> None

Activate the last \(n\) rules (in reverse insertion order) whose activation degrees are greater than or equal to the threshold.

Parameters:

Name Type Description Default
rule_block RuleBlock

rule block to activate.

required

configure

configure(parameters: str) -> None

Configure the activation method with the parameters.

Parameters:

Name Type Description Default
parameters str

number of rules and threshold (eg, 3 0.5).

required

parameters

parameters() -> str

Return the number of rules and threshold.

Returns:

Type Description
str

number of rules and threshold.

Lowest

Bases: Activation

Activation method that activates only the rules with the lowest activation degrees in ascending order.

related

Attributes

rules instance-attribute

rules = rules

Functions

__init__

__init__(rules: int = 1) -> None

Constructor.

Parameters:

Name Type Description Default
rules int

number of rules to activate.

1

activate

activate(rule_block: RuleBlock) -> None

Activate the rules with the lowest activation degrees.

Parameters:

Name Type Description Default
rule_block RuleBlock

rule block to activate.

required

configure

configure(parameters: str) -> None

Configure the activation method with the parameters.

Parameters:

Name Type Description Default
parameters str

number of rules (eg, 3).

required

parameters

parameters() -> str

Return the number of rules.

Returns:

Type Description
str

number of rules.

Proportional

Bases: Activation

Activation method that activates the rules utilizing normalized activation degrees, thus the sum of the activation degrees is equal to one.

related

Functions

activate

activate(rule_block: RuleBlock) -> None

Activate the rules using normalized activation degrees.

Parameters:

Name Type Description Default
rule_block RuleBlock

rule block to activate.

required

Threshold

Bases: Activation

Activation method that activates the rules whose activation degrees satisfy the comparison operator and the threshold, and deactivates the rest.

related

Attributes

comparator instance-attribute

comparator = comparator

threshold instance-attribute

threshold = threshold

Classes

Comparator

Bases: Enum

Six comparison operators between the activation degree \(a\) and the threshold \(\theta\).

Attributes
EqualTo class-attribute instance-attribute
EqualTo = '=='
GreaterThan class-attribute instance-attribute
GreaterThan = '>'
GreaterThanOrEqualTo class-attribute instance-attribute
GreaterThanOrEqualTo = '>='
LessThan class-attribute instance-attribute
LessThan = '<'
LessThanOrEqualTo class-attribute instance-attribute
LessThanOrEqualTo = '<='
NotEqualTo class-attribute instance-attribute
NotEqualTo = '!='
__operator__ class-attribute instance-attribute
__operator__: dict[str, Callable[[Scalar, Scalar], bool | Array[bool_]]] = {
    LessThan: lt,
    LessThanOrEqualTo: le,
    EqualTo: eq,
    NotEqualTo: ne,
    GreaterThanOrEqualTo: ge,
    GreaterThan: gt,
}
operator property
operator: Callable[[Scalar, Scalar], bool | Array[bool_]]

Return the function reference for the operator.

Returns:

Type Description
Callable[[Scalar, Scalar], bool | Array[bool_]]

function reference for the operator.

Functions
__repr__
__repr__() -> str

Return the code to construct the comparator in Python.

Returns:

Type Description
str

code to construct the comparator in Python.

Functions

__init__

__init__(comparator: Comparator | str = GreaterThan, threshold: float = 0.0) -> None

Constructor.

Parameters:

Name Type Description Default
comparator Comparator | str

comparison operator

GreaterThan
threshold float

value for activation degrees.

0.0

activate

activate(rule_block: RuleBlock) -> None

Activates the rules whose activation degrees satisfy the comparator and threshold, and deactivate the rest.

Parameters:

Name Type Description Default
rule_block RuleBlock

rule block to activate.

required

configure

configure(parameters: str) -> None

Configure the activation method with the parameters.

Parameters:

Name Type Description Default
parameters str

comparator and threshold (eg, > 0.5).

required

parameters

parameters() -> str

Return the comparator and threshold.

Returns:

Type Description
str

comparator and threshold.