fuzzy_dl_owl2.fuzzydl.concept.owa_concept
An implementation of an Ordered Weighted Averaging (OWA) concept that aggregates a collection of sub-concepts using corresponding numerical weights within a fuzzy description logic framework.
Description
The software models an Ordered Weighted Averaging (OWA) operator, functioning as a composite structure that combines multiple sub-concepts based on a parallel list of numerical weights. During initialization, the logic ensures that the number of provided weights exactly matches the number of concepts, raising an error if a mismatch is detected to maintain structural integrity. By inheriting from specific base classes, the implementation integrates seamlessly into a broader semantic system, enabling the retrieval of atomic concepts and roles, as well as the creation of deep or shallow copies of the conceptual structure. Logical operations such as negation, conjunction, and disjunction are supported through operator overloading, which delegates the actual computation to a central operator utility, while a custom hash function allows instances to be used efficiently in hash-based collections.
Classes
This entity models an Ordered Weighted Averaging (OWA) concept, serving as a composite structure that aggregates a list of sub-concepts using a corresponding list of numerical weights. To utilize this class, instantiate it with two parallel lists: one of floating-point weights and another of Concept objects, ensuring they are of the same length to satisfy validation requirements. The class automatically generates a standardized string representation and supports operations such as cloning, retrieving atomic concepts and roles, and replacing specific nested components. By inheriting from Concept and HasWeightedConceptsInterface, it integrates seamlessly into a broader system of logical or semantic operators, allowing for weighted combinations of complex conceptual definitions. |
Module Contents
UML Class Diagram for OwaConcept
- class OwaConcept(weights: list[float], concepts: list[fuzzy_dl_owl2.fuzzydl.concept.concept.Concept])[source]
Bases:
fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,fuzzy_dl_owl2.fuzzydl.concept.interface.has_weighted_concepts_interface.HasWeightedConceptsInterface
This entity models an Ordered Weighted Averaging (OWA) concept, serving as a composite structure that aggregates a list of sub-concepts using a corresponding list of numerical weights. To utilize this class, instantiate it with two parallel lists: one of floating-point weights and another of Concept objects, ensuring they are of the same length to satisfy validation requirements. The class automatically generates a standardized string representation and supports operations such as cloning, retrieving atomic concepts and roles, and replacing specific nested components. By inheriting from Concept and HasWeightedConceptsInterface, it integrates seamlessly into a broader system of logical or semantic operators, allowing for weighted combinations of complex conceptual definitions.
- Parameters:
name (Any) – The canonical string representation of the OWA concept, automatically generated during initialization.
- __and__(value: Self) Self[source]
Implements the behavior of the bitwise AND operator (&) for the concept, allowing it to be combined with another instance of the same type. The operation delegates the actual computation to the OperatorConcept.and_ method, which determines the specific logic for merging the two concepts. This method returns a new instance representing the combined result and does not modify the original objects in place.
- Parameters:
value (Self) – The right-hand operand of the bitwise AND operation.
- Returns:
A new instance representing the result of the AND operation between the current instance and the provided value.
- Return type:
Self
- __hash__() int[source]
Computes an integer hash value for the instance based on its string representation, enabling the object to be used as a key in dictionaries or as an element in sets. The implementation delegates to the built-in hash function applied to the result of the object’s string conversion. It is critical that the string representation remains consistent throughout the object’s lifetime; if the string output changes due to internal state mutation, the hash value will also change, potentially causing the object to become inaccessible or behave incorrectly within hash-based collections.
- 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, enabling the use of the minus sign to represent the logical complement of the concept. This method returns a new Concept instance that corresponds to the logical NOT of the current object, effectively delegating the operation to OperatorConcept.not_. It does not modify the original instance in place but rather produces a new representation of the negated concept.
- Returns:
The logical negation of the current concept.
- Return type:
- __or__(value: Self) Self[source]
Implements the bitwise OR operation for the concept, enabling the use of the pipe operator (|) to combine two instances. This method delegates the logic to OperatorConcept.or_, passing the current instance and the provided value to perform the disjunction. It returns a new instance of the same type, representing the result of the operation without modifying the original operands.
- Parameters:
value (Self) – The right-hand operand to combine with the current instance using the OR operation.
- Returns:
The result of the OR operation between the current instance and the provided value.
- Return type:
Self
- clone() Self[source]
Creates and returns a new instance of OwaConcept that serves as a shallow copy of the current object. The method constructs the clone by creating independent copies of the internal weights and concepts lists, ensuring that structural modifications to these lists in the clone do not affect the original instance. However, because the copy is shallow, the elements contained within the lists are shared by reference, meaning mutations to the actual concept objects or weight values will be reflected in both the original and the clone.
- Returns:
A new instance of the class with copies of the weights and concepts.
- Return type:
Self
- compute_atomic_concepts() set[fuzzy_dl_owl2.fuzzydl.concept.concept.Concept][source]
Computes and returns the set of atomic concepts represented by this entity by aggregating the atomic concepts of its immediate children. The method iterates through the collection of concepts stored in the concepts attribute, recursively invoking compute_atomic_concepts on each element and collecting the results into a unified set. Since the return value is a set, duplicate atomic concepts are automatically removed. If the instance contains no sub-concepts, an empty set is returned.
- Returns:
A set of all atomic concepts derived from the concepts contained in this object.
- Return type:
set[Concept]
- compute_name() str[source]
Generates a string representation of the Ordered Weighted Averaging (OWA) concept by formatting the internal weights and concepts into a specific parenthesized syntax. The method joins the string representations of the weights and concepts with spaces, embedding them within a structure that follows the pattern (owa (<weights>) (<concepts>)). This output serves as a computed name or identifier for the concept based on its current state.
- Returns:
A string representation of the OWA operator formatted as ‘(owa (weights) (concepts))’.
- Return type:
str
- get_roles() set[str][source]
Retrieves the union of roles associated with the underlying concepts contained within this instance. It iterates through the collection of concepts, aggregating the results of their individual role retrieval calls into a single set to ensure uniqueness. This method does not modify the internal state of the object or its sub-concepts, and it returns an empty set if no concepts are present.
- Returns:
A set of unique roles aggregated from all concepts.
- Return type:
set[str]
- replace( ) fuzzy_dl_owl2.fuzzydl.concept.concept.Concept | None[source]
Returns a new instance of OwaConcept where every sub-concept within self.concepts has been transformed by recursively replacing occurrences of concept a with concept c. The method preserves the original weights of the current instance while constructing the new object, but applies a logical negation to the final result before returning it. This operation does not modify the original object in place, ensuring that side effects are avoided.