fuzzy_dl_owl2.fuzzydl.concept.qowa_concept

Implements a Quantified Ordered Weighted Averaging (QOWA) concept that dynamically calculates aggregation weights based on a provided fuzzy quantifier.

Description

The software defines a specialized fuzzy logic construct that performs aggregation over a collection of concepts by deriving weights from a linguistic quantifier rather than requiring explicit manual specification. By evaluating the membership degree of the quantifier at regular intervals across the input list, the system automatically generates a weighting scheme that reflects the semantics of the quantifier, such as “most” or “some”. This design allows for dynamic adjustment of the aggregation logic, as changing the quantifier immediately recalculates the weights and updates the internal representation. To ensure compatibility with the broader fuzzy description logic framework, the implementation supports standard logical operations like conjunction, disjunction, and negation, while also providing mechanisms for structural cloning and recursive replacement of sub-concepts.

Classes

QowaConcept

This class implements a quantified aggregation strategy that combines a collection of concepts using a fuzzy quantifier to dynamically determine the weighting scheme. Instead of requiring explicit weights, it calculates them by evaluating the membership degree of the provided quantifier across the range of input concepts. Users can instantiate this object by providing a fuzzy concrete concept as the quantifier and a list of concepts to be aggregated. During initialization, the system automatically computes the weights and generates a standardized string representation. It supports standard logical operations and ensures structural consistency through cloning and replacement methods.

Module Contents

UML Class Diagram for QowaConcept

UML Class Diagram for QowaConcept

class QowaConcept(
quantifier: fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_concrete_concept.FuzzyConcreteConcept,
concepts: list[fuzzy_dl_owl2.fuzzydl.concept.concept.Concept],
)[source]

Bases: fuzzy_dl_owl2.fuzzydl.concept.owa_concept.OwaConcept

Inheritance diagram of fuzzy_dl_owl2.fuzzydl.concept.qowa_concept.QowaConcept

This class implements a quantified aggregation strategy that combines a collection of concepts using a fuzzy quantifier to dynamically determine the weighting scheme. Instead of requiring explicit weights, it calculates them by evaluating the membership degree of the provided quantifier across the range of input concepts. Users can instantiate this object by providing a fuzzy concrete concept as the quantifier and a list of concepts to be aggregated. During initialization, the system automatically computes the weights and generates a standardized string representation. It supports standard logical operations and ensures structural consistency through cloning and replacement methods.

Parameters:
  • type (Any) – The classification identifier for the concept, indicating it is a quantified OWA.

  • _quantifier (FuzzyConcreteConcept) – Stores the fuzzy concrete concept representing the quantifier, which determines the aggregation weights for the OWA operation.

  • name (Any) – String representation of the concept formatted as (q-owa Q C1 … Cn), automatically generated during initialization and updated when the quantifier changes.

__and__(value: Self) Self[source]

Implements the bitwise AND operation (&) for the QowaConcept instance, allowing it to be combined with another instance of the same type. This method delegates the actual computation to OperatorConcept.and_, passing the current object and the provided value as operands. The operation returns a new instance representing the result of the conjunction, leaving the original operands unchanged.

Parameters:

value (Self) – The right-hand operand for the AND operation.

Returns:

A new instance representing the result of the AND operation between this object and the provided value.

Return type:

Self

__hash__() int[source]

Computes the hash value for the instance by hashing its string representation, enabling the object to be used as a key in dictionaries or stored in sets. This implementation delegates the hashing logic to the result of the __str__ method, ensuring that instances with identical string representations yield the same hash. Consequently, the efficiency of this operation is directly tied to the performance of the object’s string conversion, and any exceptions raised during string formatting will propagate to the hash calculation.

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]

Returns the logical negation of the current concept instance, corresponding to the unary minus operator. The method constructs an intermediate OwaConcept using the instance’s weights and concepts, then applies a logical NOT operation via OperatorConcept.not_. This results in a new Concept object representing the complement of the original logic without modifying the original instance.

Returns:

Returns a new Concept representing the logical negation of the current instance.

Return type:

Concept

__or__(value: Self) Self[source]

Implements the bitwise OR operation for the concept, allowing it to be combined with another instance of the same type using the pipe operator (|). This method delegates the actual combination logic to OperatorConcept.or_, which produces a new concept representing the logical disjunction or union of the two operands. The operation is non-destructive, ensuring that the original instances remain unmodified while a new object is returned to represent the result.

Parameters:

value (Self) – The right-hand operand for the OR operation.

Returns:

The result of the logical OR or union operation between this instance and the provided value.

Return type:

Self

clone() Self[source]

Creates and returns a new instance of QowaConcept that is a shallow copy of the current object. The new instance preserves the original quantifier and creates a new list containing references to the same underlying concept objects. This ensures that structural modifications to the clone’s list of concepts do not affect the original instance, although changes to the individual concept objects themselves will be reflected in both.

Returns:

A new instance of the class with the same quantifier and a copy of the concepts list.

Return type:

Self

compute_name() str[source]

Generates a standardized string representation of the QOWA concept by combining its quantifier and associated concepts into a specific parenthetical format. The returned string follows the pattern “(q-owa <quantifier> <concept1> <concept2> …)”, where the quantifier and the list of concepts are converted to strings and joined by spaces. This method does not modify the object’s state and relies on the string conversion methods of the underlying quantifier and concept objects.

Returns:

A string representation of the query name, formatted with the quantifier and concepts.

Return type:

str

compute_weights(n: int) None[source]

Calculates and appends a sequence of weights to the instance’s weight list based on the associated quantifier. The method iterates n times, calculating the normalized position w and determining the membership degree of the difference between the current and previous positions (which is constant at 1/n). If the input n is less than or equal to zero, the method returns without making changes. This operation modifies the internal state by appending to the weights attribute, meaning repeated calls will extend the list rather than replace it.

Parameters:

n (int) – The number of weights to generate, used as the denominator for calculating the step size.

replace(
a: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
c: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
) fuzzy_dl_owl2.fuzzydl.concept.concept.Concept | None[source]

Returns a new concept instance where all occurrences of the target concept a are substituted with the replacement concept c. This operation traverses the internal list of concepts recursively, applying the replacement to each sub-concept to ensure the substitution propagates through the entire structure. The method constructs a new OwaConcept using the original quantifier and the modified list of concepts, then returns the negation of that structure, leaving the original instance unmodified.

Parameters:
  • a (Concept) – The concept to be replaced.

  • c (Concept) – The concept to substitute for a within the structure.

Returns:

A new Concept instance where all occurrences of concept a have been replaced by concept c.

Return type:

Optional[Concept]

_quantifier: fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_concrete_concept.FuzzyConcreteConcept
name

Updates the name of the Concept instance to the specified string value. This setter modifies the object’s internal state by assigning the provided value to the private _name attribute, effectively replacing any previously stored name.

Parameters:

value (str) – The new name to assign to the object.

property quantifier: fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_concrete_concept.FuzzyConcreteConcept

Sets the quantifier for the concept to the provided FuzzyConcreteConcept value. This method updates the internal _quantifier attribute and automatically triggers a recalculation of the concept’s name by calling compute_name, ensuring that the display name remains consistent with the new quantifier state.

Parameters:

value (FuzzyConcreteConcept) – The fuzzy concrete concept to assign as the quantifier.

type

Updates the type classification of the Concept instance to the specified value. This setter method assigns the provided ConceptType to the internal _type attribute, effectively overwriting the previous type definition. The operation modifies the object’s state in place and does not return a value.

Parameters:

new_type (fuzzy_dl_owl2.fuzzydl.util.constants.ConceptType) – The classification or category to assign to the concept.