fuzzy_dl_owl2.fuzzydl.concept.threshold_concept
A Python class representing threshold constraints applied to fuzzy logic concepts to determine satisfaction based on a numerical boundary.
Description
The software models a threshold constraint within a graded or fuzzy logic framework, evaluating whether the degree of fulfillment of a nested concept meets a specific numerical weight. It supports both positive thresholds, requiring a degree to be greater than or equal to a value, and negative thresholds, requiring a degree to be less than or equal to a value. By encapsulating a base concept, this component allows for the construction of complex logical expressions that include boundary conditions, integrating seamlessly with a broader hierarchy of logical constructs. Standard operations such as conjunction, disjunction, and negation are supported through delegation to an operator handler, while structural manipulations like cloning and recursive replacement ensure that the threshold logic can be maintained across transformations of the concept tree. The design delegates the retrieval of atomic concepts and roles to the inner concept, ensuring that the threshold wrapper acts primarily as a modifier of the satisfaction degree rather than a fundamental change to the underlying semantic structure.
Attributes
Classes
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
- 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
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[source]
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[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 as a member of sets. The implementation delegates to the built-in hash function applied to the result of str(self). Note that if the object is mutable and its string representation changes over time, the hash value will also change, which can lead to unexpected behavior if the object is modified while stored in a hash-based collection.
- Returns:
An integer hash value computed 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 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:
- __or__(value: Self) Self[source]
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[source]
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][source]
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[source]
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][source]
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[source]
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[source]
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( ) fuzzy_dl_owl2.fuzzydl.concept.concept.Concept[source]
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.
- _weight: float
- 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 weight: float
Sets the weight of the ThresholdConcept instance to the specified floating-point value. This method updates the internal _weight attribute, effectively modifying the object’s state without performing additional validation or triggering side effects beyond the assignment. It allows the weight to be redefined dynamically, accepting any float provided as an argument.
- Parameters:
value (float) – The new weight value.
- NegThreshold
- PosThreshold