fuzzy_dl_owl2.fuzzydl.concept.concrete.modified_concrete_concept
A fuzzy concrete concept wrapper that applies a linguistic modifier to the membership degree of an underlying base concept.
Description
The implementation models a composite fuzzy concept where a specific linguistic modifier, such as “very” or “somewhat,” transforms the truth values of a base concrete concept. By wrapping an existing fuzzy concept, the logic applies a mathematical transformation to the membership degrees, effectively allowing the creation of complex expressions like “very tall” from simpler primitives. During evaluation, the software strictly enforces a domain constraint where inputs outside the range of zero to one result in a zero membership degree, while valid inputs are processed by first determining the base concept’s membership and then applying the modifier’s function to that intermediate result. The design integrates with broader fuzzy logic operations by delegating logical conjunctions, disjunctions, and negations to a central operator handler, ensuring consistent behavior across the system while maintaining a distinct identity through a generated naming convention.
Classes
This class models a fuzzy concrete concept that has been altered by a specific modifier, such as "very" or "somewhat," effectively creating a composite concept like "very tall." It operates by wrapping an existing fuzzy concrete concept and applying a transformation function to the membership degrees generated by that base concept. When evaluating the membership degree of an input value, the implementation strictly enforces a domain constraint: if the input is less than or equal to zero or greater than one, the resulting membership degree is zero. For inputs within the valid range, the class calculates the membership degree using the underlying concept and then applies the modifier's membership function to that intermediate value to determine the final degree of satisfaction. This mechanism allows for the dynamic construction of complex linguistic expressions by mathematically adjusting the truth values of simpler concepts. |
Module Contents
UML Class Diagram for ModifiedConcreteConcept
- class ModifiedConcreteConcept(
- name: str,
- modifier: fuzzy_dl_owl2.fuzzydl.modifier.modifier.Modifier,
- f: fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_concrete_concept.FuzzyConcreteConcept,
Bases:
fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_concrete_concept.FuzzyConcreteConcept
This class models a fuzzy concrete concept that has been altered by a specific modifier, such as “very” or “somewhat,” effectively creating a composite concept like “very tall.” It operates by wrapping an existing fuzzy concrete concept and applying a transformation function to the membership degrees generated by that base concept. When evaluating the membership degree of an input value, the implementation strictly enforces a domain constraint: if the input is less than or equal to zero or greater than one, the resulting membership degree is zero. For inputs within the valid range, the class calculates the membership degree using the underlying concept and then applies the modifier’s membership function to that intermediate value to determine the final degree of satisfaction. This mechanism allows for the dynamic construction of complex linguistic expressions by mathematically adjusting the truth values of simpler concepts.
- Parameters:
k1 (float) – The lower bound of the support interval for the fuzzy concept, defining the minimum value for which the membership degree is non-zero.
k2 (float) – The upper bound of the support interval, defining the threshold above which the membership degree is zero.
_modifier (Modifier) – The fuzzy logic modifier applied to the underlying concept to transform its membership degree.
_modified (FuzzyConcreteConcept) – The fuzzy concrete concept that is subject to modification by the associated modifier.
- __and__(value: Self) Self[source]
Implements the bitwise AND operation for the instance, allowing it to be combined with another object of the same type using the & operator. This method delegates the actual logic to the and_ function within the OperatorConcept class, ensuring consistent behavior across the module. It returns a new instance representing the result of the conjunction without modifying the original objects.
- Parameters:
value (Self) – Another instance of the same class to perform the AND operation with.
- Returns:
A new instance representing the result of the AND operation between the current object and the provided value.
- Return type:
Self
- __hash__() int[source]
Computes the hash value for the instance by generating a hash of the object’s string representation. This implementation delegates the hashing logic to the result of str(self), ensuring that objects with identical string representations produce the same hash code. Consequently, any modification to the object that alters its string representation will result in a different hash value, which can lead to unexpected behavior if the object is used as a key in a dictionary or stored in a set.
- Returns:
An integer hash value derived from the string representation of the object.
- Return type:
int
- __neg__() fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_concrete_concept.FuzzyConcreteConcept[source]
Implements the unary negation operator, allowing the concept to be negated using the minus sign syntax. This method computes the logical NOT of the current concept by delegating to the OperatorConcept.not_ static method. It returns a new FuzzyConcreteConcept representing the negated value, leaving the original instance unchanged.
- Returns:
Returns the logical negation (complement) of the current concept.
- Return type:
- __or__(value: Self) Self[source]
Implements the bitwise OR operator (|) for the instance, allowing it to be combined with another value of the same type. This method delegates the actual computation to the OperatorConcept.or_ static method, passing the current instance and the provided value as arguments. It returns a new instance of the same class representing the result of the operation, leaving the original operands unmodified.
- Parameters:
value (Self) – Another instance of the same class to perform the OR operation with.
- Returns:
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 ModifiedConcreteConcept that replicates the state of the current object. The new object is initialized using the existing values of the name, modifier, and modified attributes. This operation performs a shallow copy, meaning that while the instance itself is distinct, any mutable attributes will be shared by reference between the original and the clone. The method has no side effects on the original instance.
- Returns:
A new instance of the class initialized with the same name, modifier, and modified values as the current object.
- Return type:
Self
- compute_name() str[source]
Generates a formatted string representation of the concept’s name by combining the modifier and modified attributes. The output follows the specific pattern “modified(modifier modified)”, utilizing the string conversion of the underlying attribute values. This method is read-only and does not alter the state of the object, though it assumes that the modifier and modified attributes are defined.
- Returns:
A string formatted as “modified({modifier} {modified})”, incorporating the object’s modifier and modified attributes.
- Return type:
str
- get_membership_degree(x: float) float[source]
Calculates the membership degree of a value x by composing the membership functions of a base concept and a modifier. If the input x is less than or equal to 0.0 or greater than 1.0, the method returns 0.0, treating values outside this interval as having no membership. For valid inputs, it first computes the membership degree of x using the modified object and then passes that result to the modifier object to determine the final, transformed membership degree.
- Parameters:
x (float) – The input value for which the membership degree is calculated. Values outside the range (0, 1] result in a degree of 0.0.
- Returns:
The membership degree of the input value x, calculated by applying the modifier to the membership degree of the modified set. Returns 0.0 if x is outside the range (0, 1].
- Return type:
float
- k1: float = 0.0
Sets the value of the k1 attribute for the instance, converting the input to a float to ensure type consistency. This method updates the private _k1 variable, effectively modifying the internal state of the FuzzyConcreteConcept object. Any subsequent operations relying on this parameter will reflect the new value.
- Parameters:
value (float) – The new value for the k1 attribute.
- k2: float = 1.0
Sets the upper bound parameter k2 for the fuzzy concrete concept. This method enforces a constraint ensuring that the new value is greater than or equal to the existing k1 parameter; if k1 is larger than the provided value, a ValueError is raised. Upon successful validation, the input is converted to a float and stored in the internal state.
- Parameters:
value (float) – The value to assign to the k2 parameter, which must be greater than or equal to k1.
- Raises:
ValueError – Raised if the provided value is less than k1, as k2 must be greater than or equal to k1.
- property modified: fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_concrete_concept.FuzzyConcreteConcept
Sets the internal modification state of the object to the provided FuzzyConcreteConcept value. This method acts as the setter for the modified property, replacing the existing value stored in the private _modified attribute. It directly mutates the instance’s state and does not perform any validation or return a value.
- Parameters:
value (FuzzyConcreteConcept) – The concept instance to assign as the modified state.
- property modifier: fuzzy_dl_owl2.fuzzydl.modifier.modifier.Modifier
Sets the value of the modifier property for the ModifiedConcreteConcept instance. This method accepts a Modifier object and assigns it to the internal _modifier attribute, effectively updating the instance’s state. No validation or additional side effects are performed during this assignment.
- Parameters:
value (Modifier) – The new modifier instance to assign to the object.