fuzzy_dl_owl2.fuzzydl.concept.concrete.trapezoidal_concrete_concept
Defines a trapezoidal concrete concept that models fuzzy membership degrees using a geometric shape defined by four distinct parameters.
Description
The implementation extends the base fuzzy concrete concept to represent a specific type of membership function characterized by a trapezoidal shape. By utilizing four distinct parameters to define the support and core intervals, the logic ensures that membership degrees transition linearly from zero to one and back to zero, creating a plateau of full certainty in the center. Initialization includes strict validation to guarantee that the geometric parameters are ordered correctly and that the definition domain fully encompasses the support interval, preventing invalid mathematical states. Beyond calculating membership for specific values, the class integrates with broader logical operations by delegating conjunctions, disjunctions, and negations to an operator handler, allowing these concepts to be combined within complex fuzzy expressions. Property accessors and a cloning mechanism are provided to manage the internal state and facilitate the creation of independent instances without side effects.
Classes
This class represents a trapezoidal concrete concept within a fuzzy logic framework, defining a membership function that follows a trapezoidal shape. It is defined by a universe of discourse interval [k1, k2] and four shape parameters a, b, c, and d, which establish the support [a, d] and the core [b, c] of the concept. The membership degree is 0 for values less than or equal to a or greater than or equal to d, equals 1 for values between b and c, and transitions linearly for values in the intervals (a, b) and (c, d). To use this class, instantiate it with a descriptive name and the required float parameters, ensuring that the shape parameters adhere to the strict ordering a <= b <= c <= d and that the definition interval fully encompasses the support interval (k1 <= a and k2 >= d). The class provides functionality to calculate membership degrees, clone instances, and supports logical operations such as AND, OR, and NOT via operator overloading. |
Module Contents
UML Class Diagram for TrapezoidalConcreteConcept
- class TrapezoidalConcreteConcept(name: str, k1: float, k2: float, a: float, b: float, c: float, d: float)
Bases:
fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_concrete_concept.FuzzyConcreteConcept
This class represents a trapezoidal concrete concept within a fuzzy logic framework, defining a membership function that follows a trapezoidal shape. It is defined by a universe of discourse interval [k1, k2] and four shape parameters a, b, c, and d, which establish the support [a, d] and the core [b, c] of the concept. The membership degree is 0 for values less than or equal to a or greater than or equal to d, equals 1 for values between b and c, and transitions linearly for values in the intervals (a, b) and (c, d). To use this class, instantiate it with a descriptive name and the required float parameters, ensuring that the shape parameters adhere to the strict ordering a <= b <= c <= d and that the definition interval fully encompasses the support interval (k1 <= a and k2 >= d). The class provides functionality to calculate membership degrees, clone instances, and supports logical operations such as AND, OR, and NOT via operator overloading.
- Parameters:
name (str) – Identifier for the concept, used for identification and debugging purposes.
k1 (float) – The lower bound of the interval [k1, k2] defining the domain over which the concept is defined.
k2 (float) – The upper bound of the interval for which the concept is defined.
_a (float) – The lower bound of the support interval, marking the point where the membership degree begins to increase from zero.
_b (float) – The lower bound of the plateau region where the membership degree is 1.
_c (float) – The upper bound of the plateau where the membership degree is 1.
_d (float) – The upper bound of the interval for which the concept is satisfied, representing the point where the membership degree drops to zero.
- __and__(value: Self) Self
Performs a logical conjunction (AND) operation between the current instance and another instance of the same type, typically invoked via the & operator. The method delegates the core logic to the OperatorConcept.and_ function, returning a new instance that represents the result while leaving the original operands unchanged.
- Parameters:
value (Self) – The right-hand operand to perform the AND operation with.
- Returns:
The result of the 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.concrete.fuzzy_concrete_concept.FuzzyConcreteConcept
Implements the unary negation operator for the trapezoidal fuzzy concept, returning a new concept that represents the logical complement of the current instance. This operation delegates the calculation to the not_ method of the OperatorConcept class, effectively inverting the membership function. The method does not modify the original object but instead produces a new FuzzyConcreteConcept instance reflecting the negated state.
- Returns:
Returns the logical negation of the current concept.
- Return type:
- __or__(value: Self) Self
Implements the bitwise OR operation for the concept, allowing the use of the pipe operator (|) to combine two instances. This method delegates the logic to the OperatorConcept.or_ method, which computes the logical disjunction between the current object and the provided value. It returns a new instance of the same type representing the result of the operation, leaving the original operands unchanged.
- Parameters:
value (Self) – The right-hand operand to combine with the current instance using the OR operator.
- Returns:
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 that is an independent copy of the current object. The method instantiates a new object using the current values of the name, k1, k2, a, b, c, and d attributes. This operation has no side effects on the original instance, ensuring that modifications to the returned copy do not affect the source data.
- Returns:
A new instance of the class initialized with the same attribute values as the current object.
- Return type:
Self
- compute_name() str
Constructs a human-readable string identifier that encapsulates the specific parameters of the trapezoidal concept. The output is formatted as a function-like string containing the values of the six defining attributes—k1, k2, a, b, c, and d—enclosed in parentheses. This method relies on the existence of these instance attributes and will raise an error if any are undefined.
- Returns:
A string representation of the trapezoidal configuration with the current parameter values.
- Return type:
str
- get_membership_degree(x: float) float
Computes the degree of membership for a given input value within a trapezoidal fuzzy set defined by the instance’s boundary parameters. The function returns 0.0 if the input lies outside the range defined by the lower and upper bounds, and returns 1.0 if the input falls within the central plateau. For values located on the rising or falling edges of the trapezoid, the method performs linear interpolation to return a fractional membership value between 0.0 and 1.0. This calculation is stateless and does not modify the object’s attributes.
- Parameters:
x (float) – The input value to evaluate against the membership function.
- Returns:
The degree of membership of the input value x, ranging from 0.0 to 1.0.
- Return type:
float
- _a: float
- _b: float
- _c: float
- _d: float
- property a: float
Returns the left-most breakpoint of the trapezoidal membership function, i.e. the start of the support interval where the membership degree begins rising from zero. The value is held internally as a float and is read without modifying the instance.
- Returns:
The lower support bound
aof the trapezoid.- Return type:
float
- property b: float
Returns the second breakpoint of the trapezoidal membership function, i.e. the lower bound of the core plateau where the membership degree first reaches
1. The value is held internally as a float and is read without modifying the instance.- Returns:
The lower core bound
bof the trapezoid.- Return type:
float
- property c: float
Returns the third breakpoint of the trapezoidal membership function, i.e. the upper bound of the core plateau where the membership degree starts dropping below
1. The value is held internally as a float and is read without modifying the instance.- Returns:
The upper core bound
cof the trapezoid.- Return type:
float
- property d: float
Returns the right-most breakpoint of the trapezoidal membership function, i.e. the end of the support interval where the membership degree falls back to zero. The value is held internally as a float and is read without modifying the instance.
- Returns:
The upper support bound
dof the trapezoid.- Return type:
float
- k1: float
- k2: float
- name: str