fuzzy_dl_owl2.fuzzydl.concept.choquet_integral

A Python class representing a Choquet integral concept that aggregates sub-concepts using weighted values within a fuzzy description logic framework.

Description

The software implements a specialized fuzzy logic construct known as a Choquet integral, which allows for the aggregation of multiple sub-concepts based on associated numerical weights. By inheriting from a base concept class and an interface for weighted components, the implementation ensures that the number of weights strictly corresponds to the number of concepts provided during initialization, enforcing structural integrity. It supports standard logical operations such as conjunction, disjunction, and negation by delegating the logic to an operator utility, while also providing mechanisms to traverse the concept hierarchy to extract atomic concepts and roles. To facilitate use in collections and comparisons, the implementation includes custom cloning, replacement, and hashing methods that rely on the specific configuration of weights and the identity of the contained concepts.

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])

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

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

Return a hash value for this object, computed from its string representation. This approach ensures that the hash value reflects the structural identity of the object without relying on cached values or additional methods. The hash is derived from the output of the __str__ method, which provides a consistent and unique representation of the concept’s structure. This implementation does not utilize any internal caching mechanism and directly computes the hash each time it is called.

Returns:

An integer hash value representing the structural identity of this object.

Return type:

int

__neg__() fuzzy_dl_owl2.fuzzydl.concept.concept.Concept

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

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

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]

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

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]

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

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