fuzzy_dl_owl2.fuzzydl.individual.created_individual
A class representing dynamically generated nodes within a completion forest for tableau-based reasoning, incorporating hierarchical tracking, blocking mechanisms, and state cloning capabilities.
Description
The software defines a specialized entity used in tableau-based reasoning algorithms to model abstract nodes generated dynamically within a completion forest. By extending the base individual structure, it maintains hierarchical context through attributes like parent references, role names, and depth calculations, which are essential for traversing the reasoning tree. To prevent infinite loops during the inference process, the implementation incorporates a comprehensive blocking mechanism that tracks both direct and indirect block statuses, allowing the system to identify and halt redundant expansions. Furthermore, the design supports deep cloning of internal states, including concept labels and representative individuals, enabling the preservation of snapshots during backtracking or branching operations. The entity also distinguishes between abstract placeholders and concrete instances, providing the necessary flexibility to handle complex constraints and fuzzy logic requirements within the broader reasoning framework.
Classes
This class models a dynamically generated node within a completion forest, typically utilized in tableau-based reasoning algorithms to represent abstract entities derived during the inference process. It extends the base individual structure by incorporating hierarchical context, tracking the parent node and the specific role relation that led to its creation, as well as calculating its depth within the tree. The entity is designed to manage optimization states known as blocking, which prevents infinite expansion by tracking direct and indirect block statuses alongside references to blocking ancestors. Furthermore, it maintains collections of concept labels and representative individuals for handling complex constraints, supports deep cloning for state preservation, and distinguishes between abstract nodes and concrete instances. |
Module Contents
UML Class Diagram for CreatedIndividual
- class CreatedIndividual(
- name: str,
- parent: fuzzy_dl_owl2.fuzzydl.individual.individual.Individual | None = None,
- role_name: str | None = None,
- class CreatedIndividual(name: str)
Bases:
fuzzy_dl_owl2.fuzzydl.individual.individual.Individual
This class models a dynamically generated node within a completion forest, typically utilized in tableau-based reasoning algorithms to represent abstract entities derived during the inference process. It extends the base individual structure by incorporating hierarchical context, tracking the parent node and the specific role relation that led to its creation, as well as calculating its depth within the tree. The entity is designed to manage optimization states known as blocking, which prevents infinite expansion by tracking direct and indirect block statuses alongside references to blocking ancestors. Furthermore, it maintains collections of concept labels and representative individuals for handling complex constraints, supports deep cloning for state preservation, and distinguishes between abstract nodes and concrete instances.
- Raises:
NotImplementedError – Raised when the constructor is invoked with an unsupported number of arguments; the class only supports initialization with a single name or with a name, parent, and role name.
- __created_ind_init_1(
- name: str,
- parent: fuzzy_dl_owl2.fuzzydl.individual.individual.Individual | None = None,
- role_name: str | None = None,
Initializes a new instance of a created individual within a completion forest structure, setting up attributes necessary for tableau reasoning or blocking algorithms. It accepts a name, an optional parent individual, and an optional role name that defines the relationship to the parent. The method initializes internal collections for representatives, concept labels, and roles, and sets blocking status flags to an unchecked state. The depth of the individual is calculated based on the parent’s depth if the parent is blockable; otherwise, it defaults to a depth of 2. Additionally, it marks the individual as abstract (non-concrete) by default and logs debug information if a parent is provided.
- Parameters:
name (str) – The unique identifier or label for the individual.
parent (Optional[Individual]) – The parent individual in the completion forest structure, used to determine the depth and lineage of the new individual.
role_name (Optional[str]) – The name of the role for which the individual is a filler.
- __created_ind_init_2(name: str) None
Initializes the individual instance by delegating to the primary initialization logic with a specific set of default arguments. Specifically, it invokes __created_ind_init_1 with the provided name and None for the remaining two parameters, effectively creating an individual without those specific attributes. As a side effect, it outputs a debug log message confirming the creation of the individual, displaying its name and the assigned integer ID.
- Parameters:
name (str) – The name or identifier assigned to the individual being created.
- __eq__(value: Self) bool[source]
Determines equality between the current instance and another CreatedIndividual object by comparing their name attributes. The method returns True if the names are identical and False otherwise. It is important to note that passing an argument that lacks a name attribute will raise an AttributeError.
- Parameters:
value (Self) – The object to compare against, where equality is determined by comparing the ‘name’ attribute.
- Returns:
True if the name attribute of the current instance is equal to the name attribute of the provided instance, otherwise False.
- Return type:
bool
- __ge__(value: Self) bool[source]
Implements the greater-than-or-equal-to comparison operator for instances of the class. The method returns True if the current instance is not less than the provided value, effectively delegating the logic to the __lt__ (less-than) implementation. This approach ensures consistency with the defined ordering but means that any side effects or exceptions raised by the less-than comparison will also occur here.
- Parameters:
value (Self) – The object to compare against the current instance.
- Returns:
True if the object is greater than or equal to the specified value, otherwise False.
- Return type:
bool
- __gt__(value: Self) bool[source]
Determines whether the current instance is strictly greater than the provided value. The operation is implemented by returning the logical negation of the less-than-or-equal-to comparison (<=). This method ensures that the greater-than relationship is consistent with the defined ordering for the class and expects the argument to be an instance of the same type.
- Parameters:
value (Self) – The object to compare against.
- Returns:
True if the current instance is strictly greater than the specified value, False otherwise.
- Return type:
bool
- __hash__() int[source]
Returns an integer hash value for the instance, derived from the string representation of the object. This method enables CreatedIndividual instances to be used as keys in dictionaries or members of sets. Because the hash is calculated based on the output of __str__, any changes to the object’s state that affect its string representation will alter its hash value, potentially causing issues if the object is already stored in a hash-based collection. Consequently, instances should be treated as immutable regarding their string representation if used in such contexts.
- Returns:
An integer hash value computed from the string representation of the object.
- Return type:
int
- __le__(value: Self) bool[source]
Determines whether the current instance is less than or equal to another instance of the same class by comparing their integer identifiers. The method retrieves the integer ID of both the current object and the provided value, returning True if the current object’s ID is less than or equal to the other’s ID, and False otherwise. This comparison relies on the availability and comparability of the integer identifiers returned by the get_integer_id method.
- Parameters:
value (Self) – The object to compare against, evaluated based on its integer ID.
- Returns:
True if the integer ID of the current instance is less than or equal to the integer ID of the specified value, otherwise False.
- Return type:
bool
- __lt__(value: Self) bool[source]
Determines whether the current instance is considered less than another instance of the same class by comparing their underlying integer identifiers. The method retrieves the integer ID for both the current object and the provided value, returning True only if the current object’s ID is numerically smaller. This comparison does not modify the state of either object and assumes that both instances provide valid integer identifiers via the get_integer_id method.
- Parameters:
value (Self) – Another instance of the class to compare against based on its integer ID.
- Returns:
True if the integer ID of the current instance is less than the integer ID of the specified value.
- Return type:
bool
- __ne__(value: Self) bool[source]
Determines whether the current instance is not equal to the provided value. This method is invoked by the inequality operator (!=) and returns the logical negation of the equality comparison (self == value). Consequently, its behavior is entirely dependent on the implementation of the __eq__ method, and it does not perform any direct attribute comparison itself. If the equality check raises an exception, this method will also fail.
- Parameters:
value (Self) – The object to compare against.
- Returns:
True if the current instance is not equal to the specified value, otherwise False.
- Return type:
bool
- __str__() str[source]
Returns a human-readable string representation of the instance, which consists solely of the value stored in the name attribute. This method is invoked implicitly by the built-in str() function and the print() statement whenever the object needs to be displayed as a string. It performs no modification to the object’s state, though it will raise an AttributeError if the name attribute has not been defined.
- Returns:
The string representation of the object, which is the value of the name attribute.
- Return type:
str
- clone() Self[source]
Creates and returns a new instance that is a copy of the current object. The clone is initialized using the string representation of the original instance, a None value for the parent reference, and the original role name. Additionally, the method invokes clone_special_attributes to transfer any specific internal properties from the source to the new instance, ensuring the duplicate maintains the relevant state of the original.
- Returns:
A new instance of the same class that is a clone of the current object.
- Return type:
Self
- clone_special_attributes(ind: Self) None[source]
Copies specialized attributes from the current instance to the target instance ind, effectively populating ind with a snapshot of the source’s state. The method initiates by calling the general clone_attributes method and then proceeds to handle fields requiring specific logic, such as deep copying mutable collections like representatives, concept_list, and indirectly_blocked to prevent shared references. It also handles the cloning of the parent node recursively if it exists, ensuring the target maintains an independent structural link. Finally, it transfers scalar values and flags, including depth, directly_blocked, _is_concrete, and role_name, directly to the target.
- Parameters:
ind (Self) – The target instance of the same class to receive the cloned special attributes.
- get_depth() int[source]
Retrieves the depth value associated with the current CreatedIndividual instance. This method serves as a straightforward accessor for the internal depth attribute, returning the integer that typically represents the entity’s hierarchical level or generation within a tree-like structure. As a read-only operation, it has no side effects on the object’s state or the wider system.
- Returns:
The depth of the object.
- Return type:
int
- get_integer_id() int[source]
Extracts the unique numeric identifier from the individual’s name by stripping the standard default name prefix and converting the remaining characters into an integer. The method relies on the name being formatted with the default prefix followed by a valid numeric suffix; consequently, it will raise a ValueError if the name is shorter than the prefix or if the trailing characters cannot be parsed as an integer.
- Returns:
The integer suffix of the object’s name, obtained by stripping the default prefix.
- Return type:
int
- get_parent() fuzzy_dl_owl2.fuzzydl.individual.individual.Individual | None[source]
Retrieves the parent entity associated with this instance. The method returns the object referenced by the internal parent attribute, which represents the progenitor or source of the current individual. If no parent relationship has been established, the method returns None. This operation is a read-only accessor and does not modify the state of the object or its parent.
- Returns:
The parent Individual associated with this instance, or None if no parent is set.
- Return type:
Optional[Individual]
- get_parent_name() str[source]
Retrieves the name of the parent entity associated with this individual. The method performs a safe check to determine if a parent object exists before attempting to access its attributes. If a parent is present, the value of the parent’s name attribute is returned; otherwise, an empty string is returned to signify that no parent is currently assigned.
- Returns:
The name of the parent object, or an empty string if no parent is set.
- Return type:
str
- get_representative_if_exists(
- type: fuzzy_dl_owl2.fuzzydl.util.constants.InequalityType,
- f_name: str,
- f: fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_number.triangular_fuzzy_number.TriangularFuzzyNumber,
Searches the collection of representatives associated with this instance for an entry matching the specified inequality type, feature name, and triangular fuzzy number. If a matching representative is found, the method returns the underlying individual linked to that representative; otherwise, it returns None.
- Parameters:
type (InequalityType) – Specifies the inequality condition (e.g., GREATER_EQUAL or LESS_EQUAL) that defines the representative individual relative to the fuzzy number.
f_name (str) – The name of the feature associated with the representative individual.
f (TriangularFuzzyNumber) – The fuzzy number defining the representative individual to retrieve.
- Returns:
The individual associated with the representative matching the specified inequality type, feature name, and fuzzy number, or None if no such representative exists.
- Return type:
Optional[Self]
- get_role_name() str[source]
Retrieves the string identifier representing the specific function or designation assigned to this individual. This method acts as a simple accessor for the internal role_name attribute, providing read-only access to the entity’s classification without modifying the underlying state. The returned value corresponds directly to the attribute set during the object’s initialization or subsequent modification.
- Returns:
The name of the role.
- Return type:
str
- individual_set_intersection_of(
- set1: sortedcontainers.SortedSet[Self],
- set2: sortedcontainers.SortedSet[Self],
Computes the intersection of two sorted sets containing instances of the class, returning a new set that includes only the elements present in both input collections. This operation does not modify the original sets, ensuring that the input data remains unchanged. If the input sets share no common elements, the method returns an empty set.
- Parameters:
set1 (SortedSet[Self]) – The first sorted set of concept labels to intersect.
set2 (SortedSet[Self]) – The second sorted set of concept labels to intersect with the first set.
- Returns:
A SortedSet containing the elements common to both set1 and set2.
- Return type:
SortedSet[Self]
- is_blockable() bool[source]
Determines whether the individual is eligible for blocking by checking if it is associated with any nominals. The method returns True if the internal list of nominals is empty, signifying that the individual can be blocked, and False if the list contains one or more elements. This predicate is a read-only operation that does not alter the state of the object or its attributes.
- Returns:
True if the nominal list is empty, indicating that the object is blockable; False otherwise.
- Return type:
bool
- is_concrete() bool[source]
Returns a boolean indicating whether the individual is concrete. This method provides access to the internal _is_concrete state, distinguishing between fully realized entities and abstract definitions. It performs no side effects and simply reflects the current status of the instance.
- Returns:
True if the object is concrete, False otherwise.
- Return type:
bool
- mark_indirectly_blocked() None[source]
Performs a breadth-first traversal of the subtree rooted at the current individual, marking all reachable descendants as indirectly blocked. During traversal, the method follows role relations but explicitly skips the parent node to prevent backtracking via inverse roles. Only individuals that satisfy the is_blockable condition are modified; their indirectly_blocked attribute is updated to reflect the blocked state.
- set_concrete_individual() None[source]
Marks the individual as concrete, indicating that it represents a specific, fully realized entity rather than an abstract or placeholder concept. This method updates the internal _is_concrete flag to True, effectively changing the state of the object. The operation is idempotent; calling it multiple times has the same effect as calling it once, and it does not return any value.