fuzzy_dl_owl2.fuzzydl.concept.sugeno_integral
A composite structure representing a Sugeno integral functions as a fuzzy measure to aggregate multiple sub-concepts based on a corresponding set of numerical weights.
Description
It enforces strict validation during initialization to ensure that the number of provided weights exactly matches the number of concepts, thereby maintaining the integrity of the weighted decision structure. Beyond basic storage, the implementation supports recursive operations such as cloning the instance, retrieving all atomic concepts or roles contained within the hierarchy, and replacing specific sub-concepts with alternatives. Logical operations like negation, conjunction, and disjunction are handled through operator overloading, delegating the actual computation to a central operator utility to ensure consistency across the system. The internal state is managed through a specific interface for weighted concepts, and the object’s identity is derived from a formatted string representation that encapsulates its weights and components.
Classes
This class models a Sugeno integral, a fuzzy aggregation operator used to combine a collection of sub-concepts based on a corresponding set of weights. It serves as a composite concept within a logical framework, allowing for the representation of complex, weighted decision structures. To utilize this class, instantiate it with a list of floating-point weights and a list of Concept objects, ensuring that the number of weights exactly matches the number of concepts; a mismatch will trigger an error during initialization. Once created, the instance supports operations such as cloning, replacing specific sub-concepts, and recursively retrieving atomic concepts or roles, while also providing a string representation of the integral formula. |
Module Contents
UML Class Diagram for SugenoIntegral
- class SugenoIntegral[source]
- class SugenoIntegral(weights: list[float] | None, concepts: list[fuzzy_dl_owl2.fuzzydl.concept.concept.Concept])
Bases:
fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,fuzzy_dl_owl2.fuzzydl.concept.interface.has_weighted_concepts_interface.HasWeightedConceptsInterface
This class models a Sugeno integral, a fuzzy aggregation operator used to combine a collection of sub-concepts based on a corresponding set of weights. It serves as a composite concept within a logical framework, allowing for the representation of complex, weighted decision structures. To utilize this class, instantiate it with a list of floating-point weights and a list of Concept objects, ensuring that the number of weights exactly matches the number of concepts; a mismatch will trigger an error during initialization. Once created, the instance supports operations such as cloning, replacing specific sub-concepts, and recursively retrieving atomic concepts or roles, while also providing a string representation of the integral formula.
- __and__(value: Self) Self[source]
Computes the logical conjunction of the current instance with another Sugeno integral using the bitwise AND operator. This operation combines the two integrals according to the logic defined in OperatorConcept, typically representing an intersection or a specific fuzzy logic t-norm, and returns a new SugenoIntegral instance without modifying the original operands. The method relies on the OperatorConcept.and_ helper to perform the actual calculation, ensuring that the behavior is consistent with the module’s operator handling framework.
- Parameters:
value (Self) – The right-hand operand to perform the AND operation with.
- Returns:
The result of the AND operation between this instance and the provided value.
- Return type:
Self
- __hash__() int[source]
Calculates a hash code for the current instance to support its use in hash-based collections like dictionaries and sets. This method derives the hash value by converting the object to its string representation and hashing that string. Because the hash depends on the string output, any changes to the object’s state that affect its string representation will alter its hash value, which may lead to unexpected behavior if the object is used as a dictionary key after modification.
- Returns:
An integer hash value derived from the string representation of the object.
- Return type:
int
- __neg__() fuzzy_dl_owl2.fuzzydl.concept.concept.Concept[source]
Implements the unary negation operator, allowing the Sugeno integral instance to be inverted using the minus sign. This method returns a new Concept object representing the logical negation or complement of the current instance. The operation is performed by delegating to the static OperatorConcept.not_ method, ensuring consistent handling of logical complement across the module.
- Returns:
The logical negation of the current concept.
- Return type:
- __or__(value: Self) Self[source]
Implements the bitwise OR operation for the Sugeno integral, enabling the use of the | operator to combine the current instance with another Sugeno integral. This method delegates the underlying logic to the OperatorConcept.or_ function, which performs the specific algebraic or logical combination defined by the concept. It returns a new instance of the SugenoIntegral representing the result, leaving the original operands unchanged and ensuring no side effects occur on the input objects.
- Parameters:
value (Self) – Another instance of the same class to perform the OR operation with.
- Returns:
The result of the OR operation between this instance and the provided value.
- Return type:
Self
- __sugeno_init_1() None
Initializes the SugenoIntegral instance by delegating to the constructors of its parent classes to establish the object’s core identity and capabilities. Specifically, it registers the instance as a Concept of type SUGENO_INTEGRAL and initializes the HasWeightedConceptsInterface with a null weight set and an empty list of concepts, thereby preparing the object for subsequent data population or resetting it to a default state.
- __sugeno_init_2(weights: list[float] | None, concepts: list[fuzzy_dl_owl2.fuzzydl.concept.concept.Concept]) None
This internal initialization method configures a Sugeno Integral instance by establishing its inheritance chain and validating the relationship between weights and concepts. It initializes the Concept base class with the specific SUGENO_INTEGRAL type and invokes the HasWeightedConceptsInterface to handle the weighted concepts logic. If weights are provided, the method performs a strict validation to ensure the count of weights matches the count of concepts, raising an error if they differ, and subsequently computes the instance’s name. In the absence of provided weights, the method initializes the weights attribute as an empty list.
- Parameters:
weights (Optional[list[float]]) – Optional list of numerical weights corresponding to the concepts. If provided, the length must match the number of concepts.
concepts (list[Concept]) – A list of concepts that constitute the Sugeno integral. The number of concepts must match the number of provided weights.
- clone() Self[source]
Generates a distinct copy of the current instance, preserving the state of the fuzzy integral’s parameters. The method constructs a new object using shallow copies of the internal weights and concepts lists, thereby decoupling the clone’s data structure from the original. This ensures that subsequent modifications to the weights or concepts of the returned object will not impact the source instance, providing a safe way to manipulate or store the current configuration.
- Returns:
A new instance of the class with the same weights and concepts as the current object.
- Return type:
Self
- compute_atomic_concepts() set[fuzzy_dl_owl2.fuzzydl.concept.concept.Concept][source]
Retrieves the complete set of atomic concepts associated with the current instance by aggregating results from its constituent concepts. It iterates over the collection of concepts stored in the concepts attribute, invoking the compute_atomic_concepts method on each individual element to extract their fundamental components. The resulting atomic concepts are collected into a unified set to ensure uniqueness, effectively flattening the hierarchy of concepts. This method does not modify the state of the instance or its contained concepts, and it returns an empty set if the internal collection of concepts is empty.
- Returns:
A set containing the union of all atomic concepts derived from the object’s concepts.
- Return type:
set[Concept]
- compute_name() str[source]
Constructs a standardized string identifier for the current instance by formatting the object’s weights and concepts into a specific parenthetical syntax. The resulting string follows an S-expression-like structure, explicitly labeling the operation as “sugeno” and listing the weights and concepts as space-separated sequences within nested parentheses. This method is a pure function of the instance’s state, causing no side effects, and handles non-string elements within the weights or concepts lists by implicitly converting them to strings.
- Returns:
A string representation of the Sugeno model, formatted with its weights and concepts.
- Return type:
str
- get_roles() set[str][source]
Retrieves the union of all role identifiers defined across the concepts associated with this SugenoIntegral instance. It iterates through the internal collection of concepts, invoking the get_roles method on each to gather their specific roles, and aggregates them into a single set to ensure uniqueness. This method does not modify the internal state of the instance or its concepts, and it returns an empty set if no concepts are present.
- Returns:
A set of unique role strings aggregated from all associated concepts.
- Return type:
set[str]
- replace( ) fuzzy_dl_owl2.fuzzydl.concept.concept.Concept[source]
Replaces all occurrences of a specific concept within the integral’s underlying concepts with another concept. It constructs a new SugenoIntegral instance using the original weights and the transformed list of concepts, where each constituent concept has undergone the replacement. The method returns the logical negation of this newly constructed integral without modifying the original instance.
- Parameters:
- Returns:
Returns a new Concept representing the negation of the Sugeno Integral resulting from replacing concept ‘a’ with concept ‘c’ in the internal concepts.
- Return type: