fuzzy_dl_owl2.fuzzydl.concept.choquet_integral

A class definition for modeling complex concepts within a fuzzy description logic system using the Choquet integral aggregation mechanism.

Description

The software implements a specialized concept structure that aggregates multiple sub-concepts using a Choquet integral, which allows for the representation of weighted importance among different criteria in fuzzy logic reasoning. It enforces strict data integrity by ensuring that the list of numerical weights provided during initialization corresponds exactly in length to the list of associated concepts, thereby maintaining a consistent mathematical model. Beyond storage, the implementation supports standard logical operations such as negation, conjunction, and disjunction by delegating to a central operator handler, while also enabling recursive traversal to extract atomic concepts and roles from the underlying hierarchy. To facilitate manipulation within the broader system, the logic includes capabilities for cloning the entire structure and dynamically replacing specific internal components without altering the original instance. Finally, the object provides a deterministic string representation and hash value based on its internal configuration, allowing it to function effectively within collections and hash-based data structures.

Classes

ChoquetIntegral

This class models a complex concept defined by the aggregation of sub-concepts using a Choquet integral mechanism. It serves as a container that pairs a list of floating-point weights with a corresponding list of Concept objects, requiring that both lists be of equal length during instantiation. Users can interact with this object to perform logical operations such as conjunction, disjunction, and negation, or to traverse the concept hierarchy to retrieve atomic concepts and roles. Additionally, the class provides functionality to clone the structure or replace specific internal concepts within the aggregation.

Module Contents

UML Class Diagram for ChoquetIntegral

UML Class Diagram for ChoquetIntegral

class ChoquetIntegral(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

Inheritance diagram of fuzzy_dl_owl2.fuzzydl.concept.choquet_integral.ChoquetIntegral

This class models a complex concept defined by the aggregation of sub-concepts using a Choquet integral mechanism. It serves as a container that pairs a list of floating-point weights with a corresponding list of Concept objects, requiring that both lists be of equal length during instantiation. Users can interact with this object to perform logical operations such as conjunction, disjunction, and negation, or to traverse the concept hierarchy to retrieve atomic concepts and roles. Additionally, the class provides functionality to clone the structure or replace specific internal concepts within the aggregation.

Parameters:
  • name (str) – The string representation of the concept, formatted as a Choquet integral containing its weights and sub-concepts.

  • weights (Any) – A list of numerical values representing the importance or contribution of each associated concept in the integral.

__and__(value: Self) Self[source]

Computes the logical conjunction of the current instance with another ChoquetIntegral by utilizing the bitwise AND operator (&). This method delegates the specific combination logic to the OperatorConcept.and_ static method, abstracting the implementation details of the operation. The result is a new ChoquetIntegral object representing the intersection or logical combination of the two inputs, without modifying the original instances.

Parameters:

value (Self) – The other operand to perform the AND operation with.

Returns:

The result of the logical AND operation between this instance and the provided value.

Return type:

Self

__hash__() int[source]

Computes the hash value for the instance, allowing it to be used as a key in dictionaries or as an element in sets. The hash is generated by converting the object to its string representation and hashing the resulting string. Consequently, the hash value is dependent on the implementation of the __str__ method, and any mutation of the object that alters its string representation will result in a different hash, potentially causing issues 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 for the Choquet integral, enabling the use of the minus sign (-) to represent logical negation. This method returns a new Concept object that encapsulates the complement of the current integral, effectively delegating the creation of this negated representation to OperatorConcept.not_. The operation does not modify the original instance in place but instead produces a distinct object representing the negated state.

Returns:

The logical negation of the current concept.

Return type:

Concept

__or__(value: Self) Self[source]

Implements the logical disjunction (OR) operation for the ChoquetIntegral class, enabling the use of the pipe operator (|) to combine instances. It accepts another instance of the same type and returns a new ChoquetIntegral representing the result of the disjunction, leaving the original operands unchanged. The specific logic for the operation is delegated to the OperatorConcept.or_ method.

Parameters:

value (Self) – Another instance of the same class to combine with the current instance using the OR operation.

Returns:

A new instance representing the logical OR of the current object and the provided value.

Return type:

Self

clone() Self[source]

Creates and returns a new instance of the ChoquetIntegral that is a copy of the current object. The method performs a shallow copy of the internal weights and concepts lists, ensuring that the new object contains independent list containers. This allows the clone to be modified without affecting the original object’s list structures, although changes to mutable elements within those lists will be reflected in both instances.

Returns:

A new instance of the class that is a copy of the current object, containing copies of the weights and concepts.

Return type:

Self

compute_atomic_concepts() set[fuzzy_dl_owl2.fuzzydl.concept.concept.Concept][source]

Aggregates the atomic concepts derived from the constituent concepts within the Choquet Integral by iterating through the collection stored in the instance. For each concept, it delegates the computation to the concept’s own compute_atomic_concepts method and collects the results into a unified set, ensuring that duplicate atomic concepts are removed. This method operates as a read-only aggregation, returning an empty set if the instance contains no constituent concepts.

Returns:

A set of all atomic concepts derived from the object’s concepts.

Return type:

set[Concept]

compute_name() str[source]

Generates a formatted string representation of the Choquet integral instance, intended for identification or display purposes. The method constructs the output by joining the string values of the instance’s concepts and, if present, its weights, separating them with spaces. If the weights attribute is None, the weights section of the resulting string is left empty. The final string follows the specific syntax “(choquet (weights) (concepts))”, encapsulating the integral’s configuration within a parenthetical structure.

Returns:

A string representation of the Choquet model, formatted to include the weights and concepts.

Return type:

str

get_roles() set[str][source]

Retrieves the union of roles defined across all concepts associated with this ChoquetIntegral instance. It iterates over the internal collection of concepts, aggregating the results of their individual get_roles methods into a single set to ensure uniqueness. The method returns an empty set if no concepts are present or if none define roles, and it does not modify the state of the instance or its concepts.

Returns:

A set of unique role names aggregated from all concepts.

Return type:

set[str]

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

Recursively replaces all occurrences of the concept a with the concept c within the list of concepts held by this integral. A new Choquet integral is instantiated using the original weights and the modified list of concepts, ensuring that the original object remains unmodified. The method returns the arithmetic negation of this newly constructed integral.

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

  • c (Concept) – The concept to substitute for ‘a’ in the underlying concepts.

Returns:

A new Concept representing the negation of a Choquet Integral constructed by replacing every occurrence of concept a with concept c in the original integral’s sub-concepts.

Return type:

Concept