fuzzy_dl_owl2.fuzzydl.concept.threshold_concept

A Python class that models threshold constraints applied to fuzzy logic concepts to determine satisfaction based on numerical boundaries.

Description

The software implements a logical construct that enforces numerical boundaries on the degree of fulfillment for a nested concept within a graded or fuzzy logic framework. By encapsulating a base concept and associating it with a specific weight, the implementation allows for the evaluation of satisfaction conditions based on whether the membership degree meets a positive or negative threshold. Design decisions include the use of static factory methods to simplify the instantiation of specific threshold directions, ensuring that the creation of positive and negative constraints remains intuitive and type-safe. The logic integrates seamlessly into a broader hierarchy by delegating complex operations such as conjunction, disjunction, and negation to a dedicated operator handler, while also providing mechanisms for structural manipulation like cloning and recursive replacement of sub-concepts. Furthermore, the implementation ensures that the retrieval of atomic components and roles is handled by the wrapped concept, maintaining a clean separation of concerns between the threshold logic and the underlying data structure.

Attributes

NegThreshold

PosThreshold

Classes

ThresholdConcept

This class models a threshold constraint applied to a base concept within a graded or fuzzy logic framework, determining satisfaction based on a numerical boundary. It evaluates whether the degree of fulfillment of a nested concept meets a specific weight, supporting both positive thresholds (greater than or equal to) and negative thresholds (less than or equal to). Users can construct instances via the standard constructor or convenient static factory methods designed for specific threshold directions. Functionally, it integrates into a larger hierarchy of logical constructs, enabling standard operations such as conjunction, disjunction, and negation, while delegating the retrieval of atomic concepts and roles to the encapsulated inner concept.

Module Contents

UML Class Diagram for ThresholdConcept

UML Class Diagram for ThresholdConcept

class ThresholdConcept(
c_type: fuzzy_dl_owl2.fuzzydl.util.constants.ConceptType,
c: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
weight: float,
)

Bases: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept, fuzzy_dl_owl2.fuzzydl.concept.interface.has_concept_interface.HasConceptInterface

Inheritance diagram of fuzzy_dl_owl2.fuzzydl.concept.threshold_concept.ThresholdConcept

This class models a threshold constraint applied to a base concept within a graded or fuzzy logic framework, determining satisfaction based on a numerical boundary. It evaluates whether the degree of fulfillment of a nested concept meets a specific weight, supporting both positive thresholds (greater than or equal to) and negative thresholds (less than or equal to). Users can construct instances via the standard constructor or convenient static factory methods designed for specific threshold directions. Functionally, it integrates into a larger hierarchy of logical constructs, enabling standard operations such as conjunction, disjunction, and negation, while delegating the retrieval of atomic concepts and roles to the encapsulated inner concept.

Parameters:
  • _weight (float) – Numeric threshold value used to compare against the satisfaction degree of the nested concept.

  • name (Any) – The computed string representation of the threshold concept, formatted as ([>= w] C) or ([<= w] C) and generated automatically upon initialization.

__and__(value: Self) Self

Performs a logical conjunction between the current instance and another value of the same type using the bitwise AND operator. This operation delegates the underlying logic to OperatorConcept.and_, returning a new instance that represents the combination of the two concepts without modifying the original operands. The method is designed to work with compatible types, ensuring that the resulting object adheres to the same conceptual constraints as the inputs.

Parameters:

value (Self) – The right-hand operand for the AND operation, which must be an instance of the same type.

Returns:

The result of the conjunction (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 concept, enabling the use of the minus sign to invert its logical state. This method returns a new Concept instance representing the logical negation of the current ThresholdConcept by delegating to the OperatorConcept.not_ method. The operation is non-destructive, leaving the original concept unchanged while producing a derived expression that signifies the opposite condition.

Returns:

The logical negation of the concept.

Return type:

Concept

__or__(value: Self) Self

Performs a logical OR operation between the current concept and another concept, enabling the use of the pipe operator (|) to combine them. This method delegates the combination logic to OperatorConcept.or_, returning a new composite concept that represents the union of the two operands. The operation is side-effect free, as it does not modify the original instances but produces a new instance of the same type.

Parameters:

value (Self) – The right-hand operand to combine with the current instance using the OR operation.

Returns:

A new instance representing the result of the OR operation between the current instance and the provided value.

Return type:

Self

clone() Self

Creates and returns a new instance of ThresholdConcept that duplicates the state of the current object. The returned object is initialized with the same type, curr_concept, and weight attributes as the original. This method ensures that the returned instance is independent of the source, meaning modifications to the clone will not affect the original object, although it performs a shallow copy of the internal attributes.

Returns:

A new instance of the class initialized with the same attributes as the current object.

Return type:

Self

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

Computes the set of atomic concepts that constitute the underlying concept stored in curr_concept. This method acts as a delegation wrapper, forwarding the call to the compute_atomic_concepts method of the curr_concept attribute to retrieve the fundamental, indivisible components of the concept. The result is returned as a set of Concept objects, ensuring uniqueness among the atomic constituents.

Returns:

A set of the atomic concepts that constitute the current concept.

Return type:

set[Concept]

compute_name() str | None

Generates a formatted string representation of the threshold condition based on the concept’s type and weight. For positive thresholds, the output indicates a greater-than-or-equal-to relationship, while negative thresholds indicate a less-than-or-equal-to relationship, embedding the underlying concept name within the result. If the concept type does not correspond to a defined threshold category, the method returns None.

Returns:

A formatted string representing the concept with its threshold condition and weight for positive or negative threshold types, or None if the type is not a threshold.

Return type:

Optional[str]

get_roles() set[str]

Retrieves the set of role identifiers associated with the underlying concept currently referenced by the instance. This method delegates the operation to the get_roles method of the internal curr_concept object, returning the resulting set of strings directly. Because the return value is a set, callers should be aware that modifying the returned collection may inadvertently alter the state of the underlying concept if the delegated method returns a direct reference to internal data.

Returns:

A set of strings representing the roles associated with the current concept.

Return type:

set[str]

static neg_threshold(w: float, c: Self) Self

This static method serves as a factory to instantiate a ThresholdConcept specifically defined as a negative threshold. It accepts a weight w and a concept c, passing them to the constructor along with the NEG_THRESHOLD type identifier. The method has no side effects and simply returns a new instance; any validation or errors raised will depend on the underlying ThresholdConcept constructor logic.

Parameters:
  • w (float) – The weight or value defining the negative threshold.

  • c (Self) – The concept to which the negative threshold is applied.

Returns:

A new ThresholdConcept instance representing a negative threshold with the specified weight and concept.

Return type:

Self

static pos_threshold(w: float, c: Self) Self

Constructs a new ThresholdConcept instance representing a positive threshold condition. This static method acts as a factory, accepting a floating-point weight and an existing concept instance to wrap. It initializes the new object with the POS_THRESHOLD type, associating the provided weight and concept with the resulting entity without modifying the original inputs.

Parameters:
  • w (float) – The numerical value defining the threshold.

  • c (Self) – The concept to which the positive threshold is applied.

Returns:

A new instance representing a positive threshold concept, configured with the provided weight and concept.

Return type:

Self

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 concept a with concept c within the nested curr_concept and transforms the current node into a new ThresholdConcept based on the type of c. If the replacement concept c is a positive threshold, the method returns a positive threshold concept; if it is a negative threshold, it returns a negative threshold concept. The original weight of the current node is preserved in the returned instance, ensuring that the structural hierarchy is maintained while the substitution is applied to the underlying concept.

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

  • c (Concept) – The concept to replace a with.

Returns:

A new Concept instance resulting from replacing the sub-concept a with c within the current structure, preserving the current weight.

Return type:

Concept

_weight: float
name
property weight: float

Returns the threshold value of this threshold concept, i.e. the cut-off degree against which the wrapped concept’s membership is compared (as a positive or negative threshold). The value is read from the private _weight attribute without modifying the instance.

Returns:

The threshold cut-off degree.

Return type:

float

NegThreshold
PosThreshold