fuzzy_dl_owl2.fuzzydl.degree.degree_numeric

Encapsulates a specific floating-point value to represent a degree of satisfaction within a fuzzy logic framework.

Description

Concrete floating-point values are wrapped to enable the quantification of concept satisfaction levels in a manner compatible with mathematical solvers. Arithmetic operations and inequality generation are supported to integrate these numeric values seamlessly into mixed-integer linear programming expressions. Utility functions for instance creation, cloning, and type verification ensure that the system can efficiently manage and distinguish numeric degrees from other abstract representations. Functionality is provided to handle comparisons, string representation, and specific checks for unit or zero values, fulfilling the requirements of the broader degree hierarchy.

Classes

DegreeNumeric

This concrete implementation of a degree encapsulates a specific numeric value, typically used to quantify the satisfaction level of a concept within a mathematical or logical model. Unlike abstract or symbolic degrees, this class stores a floating-point number that can be directly manipulated in arithmetic operations involving expressions and inequalities. Users can instantiate it directly with a float or utilize static factory methods such as get_one to retrieve standard values. The class provides utility methods to integrate the numeric value into larger expressions, perform comparisons, and generate inequality constraints based on the stored value.

Module Contents

UML Class Diagram for DegreeNumeric

UML Class Diagram for DegreeNumeric

class DegreeNumeric(numeric: float)[source]

Bases: fuzzy_dl_owl2.fuzzydl.degree.degree.Degree

Inheritance diagram of fuzzy_dl_owl2.fuzzydl.degree.degree_numeric.DegreeNumeric

This concrete implementation of a degree encapsulates a specific numeric value, typically used to quantify the satisfaction level of a concept within a mathematical or logical model. Unlike abstract or symbolic degrees, this class stores a floating-point number that can be directly manipulated in arithmetic operations involving expressions and inequalities. Users can instantiate it directly with a float or utilize static factory methods such as get_one to retrieve standard values. The class provides utility methods to integrate the numeric value into larger expressions, perform comparisons, and generate inequality constraints based on the stored value.

Parameters:

value (float) – The underlying floating-point number representing the magnitude of the degree.

__eq__(d: fuzzy_dl_owl2.fuzzydl.degree.degree.Degree) bool[source]

Checks for equality between the current instance and another object. The method returns True only if the provided argument is an instance of DegreeNumeric and its underlying numerical value matches the internal value of this instance. If the argument is of a different type or the numerical values do not align, the method returns False. This operation does not modify the state of either object.

Parameters:

d (Degree) – The Degree instance to compare with the current instance.

Returns:

True if the provided Degree object is a DegreeNumeric instance with the same numerical value as this instance, otherwise False.

Return type:

bool

__str__() str[source]

Returns a human-readable string representation of the DegreeNumeric instance, formatted to display the underlying numeric value. The output follows the pattern “Degree({value})”, where {value} corresponds to the instance’s value attribute. This method is implicitly invoked by the str() built-in and print functions, and it does not modify the object’s state, though it requires the value attribute to be present.

Returns:

A human-readable string representation of the object, formatted as “Degree(value)”.

Return type:

str

add_to_expression(expr: fuzzy_dl_owl2.fuzzydl.milp.expression.Expression) fuzzy_dl_owl2.fuzzydl.milp.expression.Expression[source]

Adds the numeric value stored in the current instance to the provided expression. This operation combines the input expression with the instance’s internal value using the addition operator, returning a new expression object that represents the result. The method does not modify the original expression or the instance itself, though it relies on the underlying compatibility between the expression type and the numeric value.

Parameters:

expr (Expression) – The expression to which the instance’s value is added.

Returns:

The Expression resulting from adding the instance’s value to the input expression.

Return type:

Expression

clone() Self[source]

Creates and returns a new instance of the class that replicates the current object’s state. This is accomplished by extracting the internal numeric value and passing it to the class’s factory method, get_degree. The method does not modify the original instance, ensuring that the returned object is a distinct copy, though the exact behavior relies on the implementation of the underlying factory method.

Returns:

A new instance of the class with the same value as the current instance.

Return type:

Self

create_inequality_with_degree_rhs(
expr: fuzzy_dl_owl2.fuzzydl.milp.expression.Expression,
inequation_type: fuzzy_dl_owl2.fuzzydl.util.constants.InequalityType,
) fuzzy_dl_owl2.fuzzydl.milp.inequation.Inequation[source]

Constructs an inequality object that compares the provided expression against the numeric degree value stored in the current instance. The method generates the inequality by subtracting the instance’s value from the input expression, effectively positioning the degree value as the right-hand side of the comparison. The specific relational operator, such as less-than or greater-than, is determined by the inequation_type argument.

Parameters:
  • expr (Expression) – The algebraic expression representing the left-hand side of the inequality.

  • inequation_type (InequalityType) – Specifies the relational operator or type of the inequality relation (e.g., less than, greater than).

Returns:

An Inequation object representing the comparison between the provided expression and the degree value, using the specified inequality type.

Return type:

Inequation

static get_degree(value: float) Self[source]

Instantiates a new DegreeNumeric object using the provided float value. This static method serves as a factory function, allowing for the explicit conversion of a raw numeric value into the class’s specific degree representation. The method delegates directly to the class constructor, meaning any validation or error handling is determined by the initialization logic of DegreeNumeric, and it produces no side effects other than the allocation of the new instance.

Parameters:

value (float) – The numeric value representing the angle in degrees.

Returns:

A new DegreeNumeric instance initialized with the provided value.

Return type:

Self

get_numerical_value() float[source]

Returns the underlying numeric value of the degree instance as a float. This method provides direct access to the internal value attribute without performing any calculations or modifications to the object state. It is a pure accessor function with no side effects.

Returns:

The numerical value stored in the object.

Return type:

float

static get_one() Self[source]

Returns a new instance of DegreeNumeric representing the value 1.0. This static method acts as a factory to provide a consistent unit value without requiring an existing object instance. The operation has no side effects and simply constructs and returns the object.

Returns:

Returns a new instance of the class representing the value one.

Return type:

Self

is_number_not_one() bool[source]

Determines whether the underlying numeric value of the instance is different from exactly 1.0. This method returns True if the value is not equal to 1.0 and False if it matches. It performs a direct comparison without modifying the object’s state, meaning floating-point values that are close to but not exactly 1.0 will be considered different.

Returns:

True if the value is not equal to 1.0, False otherwise.

Return type:

bool

is_number_zero() bool[source]

Determines whether the underlying numeric value of the instance is exactly zero. This is achieved by performing a strict equality comparison between the instance’s value attribute and the floating-point literal 0.0. Consequently, values that are extremely close to zero but not exactly equal to it will result in a return value of False. The method does not modify the state of the object.

Returns:

True if the value is zero, False otherwise.

Return type:

bool

is_numeric() bool[source]

Returns a boolean value indicating that the current instance represents a numeric degree. This method serves as a type flag, allowing calling code to distinguish between numeric and non-numeric degree representations within a potentially polymorphic class hierarchy. Since this class specifically defines a numeric type, the method unconditionally returns True. The operation has no side effects.

Returns:

True, indicating that the object is numeric.

Return type:

bool

multiply_constant(constant: float) fuzzy_dl_owl2.fuzzydl.milp.expression.Expression[source]

Multiplies the underlying numeric value of the instance by the specified floating-point constant and returns the result encapsulated in a new Expression object. This operation performs standard scalar multiplication without modifying the original instance, relying on the behavior of Python’s floating-point arithmetic for the calculation.

Parameters:

constant (float) – The numeric value to multiply the expression’s underlying value by.

Returns:

A new Expression object representing the product of the current value and the provided constant.

Return type:

Expression

subtract_from_expression(
expr: fuzzy_dl_owl2.fuzzydl.milp.expression.Expression,
) fuzzy_dl_owl2.fuzzydl.milp.expression.Expression[source]

Subtracts the numeric value stored in this instance from the given expression. This operation returns a new Expression object representing the result of the subtraction, ensuring that neither the input expression nor the current instance is mutated.

Parameters:

expr (Expression) – The expression from which the value is subtracted.

Returns:

The resulting Expression after subtracting the current value from the provided expression.

Return type:

Expression

value: float