fuzzy_dl_owl2.fuzzydl.concept.concrete.left_concrete_concept

A Python implementation of a left shoulder fuzzy set that assigns full membership to lower values and linearly decreases to zero over a specified interval.

Description

The software models a left shoulder fuzzy set, a mathematical construct where membership degrees are maximized at lower numerical values and taper off linearly towards zero as values increase. It relies on four floating-point parameters to define the domain of validity and the specific transition interval, ensuring that inputs are validated to maintain a consistent mathematical structure where the lower bound of the domain does not exceed the start of the satisfaction interval. Central to its behavior is a membership calculation function that returns full membership for values below a threshold, zero membership for values above an upper limit, and a linearly interpolated score for values falling within the transition range. By inheriting from a base concrete concept class and delegating logical operations like negation, conjunction, and disjunction to an operator utility, the implementation integrates seamlessly into a broader fuzzy description logic system while supporting standard Python operator overloading for intuitive syntax.

Classes

LeftConcreteConcept

This class models a left shoulder fuzzy set, representing a concept where membership is maximized at lower values and decreases linearly towards zero. It is defined by a domain of validity [k1, k2] and a satisfaction interval [a, b], where membership is 1 for inputs less than or equal to a, 0 for inputs greater than or equal to b, and linearly interpolated for values in between. To use this class, instantiate it with a name and the four float parameters, ensuring that k1 is less than or equal to a and k2 is greater than or equal to b to satisfy validation constraints. Once instantiated, the membership degree of a specific value can be retrieved, and the object supports logical operations like negation, conjunction, and disjunction through standard Python operators.

Module Contents

UML Class Diagram for LeftConcreteConcept

UML Class Diagram for LeftConcreteConcept

class LeftConcreteConcept(name: str, k1: float, k2: float, a: float, b: float)[source]

Bases: fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_concrete_concept.FuzzyConcreteConcept

Inheritance diagram of fuzzy_dl_owl2.fuzzydl.concept.concrete.left_concrete_concept.LeftConcreteConcept

This class models a left shoulder fuzzy set, representing a concept where membership is maximized at lower values and decreases linearly towards zero. It is defined by a domain of validity [k1, k2] and a satisfaction interval [a, b], where membership is 1 for inputs less than or equal to a, 0 for inputs greater than or equal to b, and linearly interpolated for values in between. To use this class, instantiate it with a name and the four float parameters, ensuring that k1 is less than or equal to a and k2 is greater than or equal to b to satisfy validation constraints. Once instantiated, the membership degree of a specific value can be retrieved, and the object supports logical operations like negation, conjunction, and disjunction through standard Python operators.

Parameters:
  • k1 (float) – The lower bound of the domain interval [k1, k2] over which the concept is defined.

  • k2 (float) – The upper bound of the interval [k1, k2] defining the domain of the concept.

  • _a (float) – The lower bound of the transition interval, defining the point at which the membership degree begins to decrease from 1.0.

  • _b (float) – The upper bound of the satisfaction interval, representing the point at which the membership degree becomes zero.

__and__(value: Self) Self[source]

Implements the bitwise AND operation (&) for the concept, calculating the intersection between the current instance and another instance of the same type. This method delegates the actual computation to OperatorConcept.and_ and returns a new instance representing the result, ensuring that the original operands remain unmodified. It enables the combination of concepts to identify shared properties or elements.

Parameters:

value (Self) – The other operand to perform the AND operation with.

Returns:

The result of the bitwise AND operation between the instance and the provided value.

Return type:

Self

__hash__() int[source]

Calculates a hash value for the instance to support its use in hash-based collections like dictionaries and sets. The hash is derived from the string representation of the object, ensuring that the hash value is consistent with the textual output generated by the __str__ method. Consequently, any changes to the string representation logic will directly affect the hash value, potentially impacting lookups in previously populated hash tables.

Returns:

An integer hash value computed from the object’s string representation.

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 inverted using the minus sign. This method computes the logical negation of the current instance by delegating to the OperatorConcept.not_ static method. The operation returns a new FuzzyConcreteConcept representing the complement of the original concept, leaving the source instance unmodified.

Returns:

A new concept representing the logical negation of the current concept.

Return type:

FuzzyConcreteConcept

__or__(value: Self) Self[source]

Implements the bitwise OR operation for the concept, enabling the use of the pipe operator (|) to combine the current instance with another value of the same type. This method delegates the underlying logic to the OperatorConcept.or_ static method, which calculates the result. The operation returns a new instance of LeftConcreteConcept representing the union or disjunction of the operands, ensuring that the original objects remain unmodified.

Parameters:

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

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 that is a copy of the current object. The clone is instantiated with the same values for name, k1, k2, a, and b as the original. This method does not modify the existing instance, though the resulting clone may share references to mutable objects if the constructor does not perform deep copying.

Returns:

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

Return type:

Self

compute_name() str[source]

Generates a canonical string representation of the concept by formatting the instance’s defining parameters into a specific pattern. The returned string follows the format “left-shoulder(k1, k2, a, b)”, utilizing the values of the attributes k1, k2, a, and b. This method is read-only and does not modify the state of the object.

Returns:

A string representation of the left-shoulder function name, including its parameters.

Return type:

str

get_membership_degree(value: float) float[source]

Computes the degree of membership for a given numerical value within a left-shoulder fuzzy set defined by the parameters a and b. The function returns 1.0 for values less than or equal to a, indicating full membership, and returns 0.0 for values greater than or equal to b, indicating no membership. For values falling strictly between a and b, the method performs a linear interpolation to determine a partial membership value between 0.0 and 1.0. This implementation assumes that a is strictly less than b to avoid division by zero errors during the interpolation step.

Parameters:

value (float) – The numeric input value for which to calculate the membership degree.

Returns:

The degree of membership of the input value, ranging from 0.0 to 1.0. Returns 1.0 for values at or below the lower bound, 0.0 for values at or above the upper bound, and a linearly interpolated value for those in between.

Return type:

float

_a: float
_b: float
property a: float

Updates the internal state of the object by assigning a new value to the property ‘a’. The method explicitly converts the provided input to a float before storing it in the private attribute _a, ensuring type consistency. This operation modifies the object in place and may raise an exception if the input cannot be converted to a float.

Parameters:

value (float) – The new value to assign, which will be converted to a float.

property b: float

Sets the value of the ‘b’ attribute, ensuring it is stored as a floating-point number. The input value is explicitly cast to a float before being assigned to the internal private attribute ‘_b’. This operation modifies the object’s state in place and will raise an error if the conversion is not possible.

Parameters:

value (float) – The new value to assign to the b attribute, converted to a float.

k1: float

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

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.