fuzzy_dl_owl2.fuzzydl.concept.ext_threshold_concept
A Python class representing extended threshold concepts that apply variable-based constraints to the satisfaction degree of a nested concept within a fuzzy description logic framework.
Description
The software implements a specialized logical construct designed to evaluate fuzzy concepts against a dynamic threshold defined by a variable. By encapsulating a base concept and a weight variable, it determines satisfaction based on whether the nested concept’s degree meets or exceeds, or falls below, the specified threshold value. This design allows for the creation of both positive and negative constraints, effectively modeling complex conditions where the boundaries of concept satisfaction are not fixed but depend on external variables. Functionality includes static factory methods for instantiating specific threshold types, as well as mechanisms for cloning and replacing internal components to support structural manipulation. Logical operations such as negation, conjunction, and disjunction are handled by delegating to a central operator utility, ensuring consistent behavior across the system. Furthermore, the implementation delegates the extraction of atomic concepts and roles to the underlying nested concept, maintaining a clean separation of concerns while providing a comprehensive string representation for hashing and identification.
Attributes
Classes
This class models a logical construct that imposes a variable-based threshold on the satisfaction degree of another concept. It defines conditions where an individual satisfies the concept if the degree of satisfaction of a nested concept is either greater than or equal to, or less than or equal to, a specific variable value. The class provides static factory methods to easily create positive or negative threshold concepts and supports standard logical operations such as negation, conjunction, and disjunction. Additionally, it allows for the modification of the threshold variable and the replacement of nested concepts, while delegating the retrieval of atomic concepts and roles to the underlying concept structure. |
Module Contents
UML Class Diagram for ExtThresholdConcept
- class ExtThresholdConcept(
- c_type: fuzzy_dl_owl2.fuzzydl.util.constants.ConceptType,
- c: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
- weight_variable: fuzzy_dl_owl2.fuzzydl.milp.variable.Variable,
Bases:
fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,fuzzy_dl_owl2.fuzzydl.concept.interface.has_concept_interface.HasConceptInterface
This class models a logical construct that imposes a variable-based threshold on the satisfaction degree of another concept. It defines conditions where an individual satisfies the concept if the degree of satisfaction of a nested concept is either greater than or equal to, or less than or equal to, a specific variable value. The class provides static factory methods to easily create positive or negative threshold concepts and supports standard logical operations such as negation, conjunction, and disjunction. Additionally, it allows for the modification of the threshold variable and the replacement of nested concepts, while delegating the retrieval of atomic concepts and roles to the underlying concept structure.
- Parameters:
_weight_variable (Variable) – Internal storage for the threshold value $w$ in the extended threshold concept expression.
name (str) – The computed string representation of the extended threshold concept, formatted according to the threshold operator and weight variable.
- __and__(value: Self) Self[source]
Implements the bitwise AND operation (&) for the ExtThresholdConcept class, enabling logical conjunction between two instances. This method accepts another instance of the same type and delegates the actual computation to the OperatorConcept.and_ static method. The operation returns a new instance of ExtThresholdConcept representing the result of the conjunction.
- Parameters:
value (Self) – The right-hand operand of the AND operation.
- Returns:
Returns a new instance representing the result of the logical AND operation between this object and the provided value.
- Return type:
Self
- __hash__() int[source]
Computes the hash value for the instance by delegating to the hash of its string representation. This allows the object to be used as a dictionary key or stored in a set. The resulting integer hash depends entirely on the output of the object’s __str__ method.
- Returns:
An integer hash value computed from the string representation of the object, intended for use in hashed collections.
- Return type:
int
- __neg__() fuzzy_dl_owl2.fuzzydl.concept.concept.Concept[source]
Returns the logical negation of the current concept instance, allowing the use of the unary minus operator (e.g., -concept). This method delegates the operation to OperatorConcept.not_ to generate a new Concept representing the logical NOT of the original object without modifying it.
- Returns:
A new Concept representing the logical negation of this instance.
- Return type:
- __or__(value: Self) Self[source]
Performs a logical OR operation between the current instance and another instance of the same type, typically invoked using the pipe operator (|). This method delegates the actual logic to OperatorConcept.or_, combining the two concepts to produce a new result. The operation is non-destructive, returning a new instance of ExtThresholdConcept rather than modifying the original operands. The value argument must be compatible with the current instance type to ensure the operation succeeds.
- Parameters:
value (Self) – The right-hand operand for the OR operation, expected to be of the same type as the current instance.
- Returns:
A new instance representing the result of the OR operation between the current object and the provided value.
- Return type:
Self
- clone()[source]
Generates a duplicate of the current object by creating a new instance of ExtThresholdConcept initialized with the existing type, curr_concept, and weight_variable attributes. This method ensures that the original object remains unmodified, effectively providing a snapshot of the object’s state at the time of the call. Note that because the constructor receives direct references to the attributes, the resulting clone performs a shallow copy, meaning any mutable objects referenced by these attributes will be shared between the original and the new instance.
- compute_atomic_concepts() set[fuzzy_dl_owl2.fuzzydl.concept.concept.Concept][source]
Computes the set of atomic concepts associated with the current object by delegating the operation to the underlying curr_concept attribute. This method returns a collection of the fundamental, indivisible concepts that constitute the current state. As the logic is forwarded, the specific behavior, including potential side effects or exceptions, is determined by the implementation of compute_atomic_concepts within the referenced curr_concept object.
- Returns:
A set of atomic concepts that constitute the current concept.
- Return type:
set[Concept]
- compute_name() str | None[source]
Generates a descriptive string representation for the threshold concept by formatting the weight variable and current concept into a conditional expression. The specific operator used in the expression depends on the concept type: a positive threshold results in a ‘greater than or equal to’ operator, while other types default to a ‘less than or equal to’ operator. This method performs no side effects and relies entirely on the existing attributes of the instance.
- Returns:
A formatted string representing the concept combined with a threshold condition on the weight variable.
- Return type:
Optional[str]
- static extended_neg_threshold(v: fuzzy_dl_owl2.fuzzydl.milp.variable.Variable, c: Self) Self[source]
Constructs a new instance representing an extended negative threshold concept by combining a variable with an existing concept. This static method acts as a factory that initializes an ExtThresholdConcept with the specific type identifier EXT_NEG_THRESHOLD, passing the provided concept and variable to the constructor. The operation does not modify the input arguments but rather creates a new object that encapsulates the logical relationship defined by the negative threshold.
- Parameters:
v (Variable) – The variable component of the extended negative threshold concept.
c (Self) – The constant value defining the threshold boundary.
- Returns:
Returns a new instance representing an extended negative threshold concept derived from the provided variable and concept.
- Return type:
Self
- static extended_pos_threshold(v: fuzzy_dl_owl2.fuzzydl.milp.variable.Variable, c: Self) Self[source]
Creates a new instance of ExtThresholdConcept representing an extended positive threshold. This static method takes a Variable and an existing ExtThresholdConcept as inputs to construct the new object. It returns the newly created concept configured with the type EXT_POS_THRESHOLD, combining the provided variable and the existing concept without modifying the original arguments.
- Parameters:
v (Variable) – The variable representing the threshold value.
c (Self) – The concept instance to be wrapped by the extended positive threshold.
- Returns:
An ExtThresholdConcept instance representing an extended positive threshold involving the provided variable and concept.
- Return type:
Self
- get_roles() set[str][source]
Retrieves the collection of roles associated with the current concept instance. This method acts as a delegation to the get_roles method of the internal curr_concept object, returning the resulting set of role identifiers. The operation has no side effects on the ExtThresholdConcept instance itself, though the behavior depends entirely on the state and implementation of the wrapped concept object.
- Returns:
A set of strings representing the roles associated with the current concept.
- Return type:
set[str]
- replace( ) fuzzy_dl_owl2.fuzzydl.concept.concept.Concept[source]
Returns a new ExtThresholdConcept instance with all occurrences of concept a replaced by concept c within the underlying curr_concept structure. This method preserves the original instance’s type and weight variable attributes while delegating the recursive substitution logic to the nested concept. The operation is side-effect free, ensuring the original object remains unmodified, and returns a distinct object reflecting the updated conceptual structure.
- _weight_variable: fuzzy_dl_owl2.fuzzydl.milp.variable.Variable
- name: str
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_variable: fuzzy_dl_owl2.fuzzydl.milp.variable.Variable
Sets the weight variable associated with this concept instance. This method accepts a Variable object and assigns it to the internal _weight_variable attribute, replacing any existing value. It serves as the setter for the weight_variable property, enabling external modification of the concept’s internal state.
- Parameters:
value (Variable) – The instance to assign as the weight variable.
- ExtendedNegThreshold
- ExtendedPosThreshold