fuzzy_dl_owl2.fuzzydl.query.min.min_query
A query implementation that calculates the minimum possible value of a specific expression within a fuzzy description logic knowledge base.
Description
The software extends the generic query framework to support optimization tasks focused on finding the lowest possible value for a given mathematical expression. By accepting an objective expression during instantiation, the logic prepares to evaluate this target against the constraints and data contained within a fuzzy description logic knowledge base. During execution, the process first resolves the assertional box (ABox) to ensure consistency before creating a clone of the knowledge base to perform the actual optimization without altering the original state. Error handling is integrated to manage scenarios where the underlying ontology is inconsistent, returning a specific failure solution instead of crashing, while also tracking the total time required for the resolution and optimization phases.
Classes
This class defines a minimization query used to retrieve the smallest possible value of a specific expression subject to the constraints defined in a knowledge base. It operates by accepting an objective expression during initialization and, upon execution, verifying the consistency of the knowledge base before performing an optimization to find the minimum. Users should instantiate this class with the expression they wish to minimize and pass it to a solver, noting that it handles inconsistent knowledge bases by returning a specific failure solution. |
Module Contents
UML Class Diagram for MinQuery
- class MinQuery(expr: fuzzy_dl_owl2.fuzzydl.milp.expression.Expression)[source]
Bases:
fuzzy_dl_owl2.fuzzydl.query.query.Query
This class defines a minimization query used to retrieve the smallest possible value of a specific expression subject to the constraints defined in a knowledge base. It operates by accepting an objective expression during initialization and, upon execution, verifying the consistency of the knowledge base before performing an optimization to find the minimum. Users should instantiate this class with the expression they wish to minimize and pass it to a solver, noting that it handles inconsistent knowledge bases by returning a specific failure solution.
- Parameters:
obj_expr (Any) – The expression representing the objective function to be minimized.
- __str__() str[source]
Returns a string representation of the minimum query, formatted as a partial expression involving the object’s target expression and a greater-than-or-equal-to operator. The output string combines the stored object expression with a question mark and the comparison symbol, providing a human-readable or serialization-friendly version of the query structure. This method has no side effects and does not alter the internal state of the object.
- Returns:
A string representation of the object, formatted as the object expression followed by a parameter placeholder and the greater-than-or-equal-to operator.
- Return type:
str
- preprocess(kb: fuzzy_dl_owl2.fuzzydl.knowledge_base.KnowledgeBase) None[source]
Prepares the internal state of the query object based on the provided knowledge base. This method is intended to be overridden by subclasses to perform specific initialization logic, such as validating the knowledge base structure, indexing relevant entities, or constructing intermediate data structures required for efficient query execution. Since it modifies the object’s state, it should be invoked prior to executing the main query logic, and subclasses may raise exceptions if the provided knowledge base is incompatible with the specific query requirements.
- Parameters:
kb (KnowledgeBase) – The knowledge base object to be preprocessed.
- solve(kb: fuzzy_dl_owl2.fuzzydl.knowledge_base.KnowledgeBase) None[source]
Executes the minimization query by first resolving the ABox of the provided knowledge base and then optimizing a clone of that base against the query’s objective expression. The method tracks the total execution time required for these operations. If the knowledge base is found to be inconsistent, the method catches the resulting exception and returns a specific Solution object indicating an inconsistent state; otherwise, it returns the Solution obtained from the optimization process.
- Parameters:
kb (KnowledgeBase) – The knowledge base containing the ontology and data to be solved and optimized. The ABox is solved directly on this instance, while optimization is performed on a clone.
- obj_expr