Skip to content

RuleBlock

RuleBlock

Block of rules and fuzzy logic operators required to control an engine.

related

Attributes

activation instance-attribute

activation = activation

conjunction instance-attribute

conjunction = conjunction

description instance-attribute

description = description

disjunction instance-attribute

disjunction = disjunction

enabled instance-attribute

enabled = enabled

implication instance-attribute

implication = implication

name instance-attribute

name = name

rules instance-attribute

rules = list(rules or [])

Functions

__getitem__

__getitem__(item: int | slice) -> Rule | list[Rule]

Allow indexing rules in rule block (eg, rule_block[0]).

Parameters:

Name Type Description Default
item int | slice

rule index or slice

required

Returns:

Type Description
Rule | list[Rule]

rule at index or slice of rules

__init__

__init__(
    name: str = "",
    description: str = "",
    enabled: bool = True,
    conjunction: TNorm | None = None,
    disjunction: SNorm | None = None,
    implication: TNorm | None = None,
    activation: Activation | None = None,
    rules: Iterable[Rule] | None = None,
) -> None

Constructor.

Parameters:

Name Type Description Default
name str

name of the rule block

''
description str

description of the rule block

''
enabled bool

enable the rule block

True
conjunction TNorm | None

conjunction operator

None
disjunction SNorm | None

disjunction operator

None
implication TNorm | None

implication operator

None
activation Activation | None

activation method

None
rules Iterable[Rule] | None

list of rules.

None

__iter__

__iter__() -> Iterator[Rule]

Return the iterator of the rules.

Returns:

Type Description
Iterator[Rule]

iterator of the rules

__len__

__len__() -> int

Return the number of rules.

Returns:

Type Description
int

number of rules

__repr__

__repr__() -> str

Return the code to construct the rule block in Python.

Returns:

Type Description
str

code to construct the rule block in Python.

__str__

__str__() -> str

Return the code to construct the rule block in the FuzzyLite Language.

Returns:

Type Description
str

code to construct the rule block in the FuzzyLite Language.

activate

activate() -> None

Activate the rule block.

load_rules

load_rules(engine: Engine) -> None

Load all the rules in the rule block.

Parameters:

Name Type Description Default
engine Engine

engine where this rule block is registered.

required

reload_rules

reload_rules(engine: Engine) -> None

Reload all the rules in the rule block.

Parameters:

Name Type Description Default
engine Engine

engine where this rule block is registered.

required

rule

rule(index: int) -> Rule

Get the rule at the index.

Parameters:

Name Type Description Default
index int

index of the rule.

required

Returns:

Type Description
Rule

rule at the index

unload_rules

unload_rules() -> None

Unload all the rules in the rule block.