fuzzy_dl_owl2.fuzzydl.query.min.min_instance_query

A query mechanism that computes the minimum membership degree of an individual for a given concept by formulating and solving a mixed-integer linear programming problem.

Description

The implementation extends the standard instance query logic to specifically target the greatest lower bound of truth values within a fuzzy description logic framework. To achieve this, the system introduces a semi-continuous variable into the optimization model and establishes a linear constraint that links the negation of the target concept to this variable, effectively minimizing the objective to find the lower bound. The resolution process ensures data integrity by cloning the knowledge base before applying transformations, handles dynamic blocking for existential restrictions, and gracefully manages inconsistent ontology states by returning a specific solution type rather than propagating exceptions.

Classes

MinInstanceQuery

This class models a query designed to retrieve the greatest lower bound of the degree of membership for a specific individual relative to a given concept. It functions by transforming the logical query into an optimization problem, specifically utilizing a semi-continuous variable to represent the degree of membership. To execute the query, the user must provide a target concept and an individual; the solve method then clones the current knowledge base to prevent side effects, applies necessary constraints, and performs an optimization to calculate the result. The implementation includes specific handling for existential restrictions and manages inconsistent ontology states by returning a designated solution type.

Module Contents

UML Class Diagram for MinInstanceQuery

UML Class Diagram for MinInstanceQuery

class MinInstanceQuery(
concept: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
individual: fuzzy_dl_owl2.fuzzydl.individual.individual.Individual,
)

Bases: fuzzy_dl_owl2.fuzzydl.query.instance_query.InstanceQuery

Inheritance diagram of fuzzy_dl_owl2.fuzzydl.query.min.min_instance_query.MinInstanceQuery

This class models a query designed to retrieve the greatest lower bound of the degree of membership for a specific individual relative to a given concept. It functions by transforming the logical query into an optimization problem, specifically utilizing a semi-continuous variable to represent the degree of membership. To execute the query, the user must provide a target concept and an individual; the solve method then clones the current knowledge base to prevent side effects, applies necessary constraints, and performs an optimization to calculate the result. The implementation includes specific handling for existential restrictions and manages inconsistent ontology states by returning a designated solution type.

__str__() str

Returns a human-readable string representation of the query object, formatted to ask whether the individual stored in self.ind is an instance of the concept stored in self.conc, followed by a threshold comparison indicator. This method is primarily used for debugging or logging purposes to visualize the specific parameters of the query in a structured format.

Returns:

A human-readable string representation of the object, formatted as a query regarding whether ind is an instance of conc.

Return type:

str

preprocess(kb: fuzzy_dl_owl2.fuzzydl.knowledge_base.KnowledgeBase) None

Prepares the minimum instance query for solving by introducing a new semi-continuous variable into the Knowledge Base’s MILP solver and setting it as the objective to be minimized. The method inspects the query’s conclusion for existential quantifiers, triggering dynamic blocking on the Knowledge Base if specific patterns are detected. It then encodes the logical structure of the query by adding an assertion that links the negation of the conclusion to the new variable via a linear constraint, specifically enforcing that the negated conclusion is greater than or equal to one minus the variable. This process modifies the Knowledge Base state and immediately triggers a solving step for the accumulated assertions.

Parameters:

kb (KnowledgeBase) – The knowledge base instance used to manage variables, assertions, and solver state.

solve(kb: fuzzy_dl_owl2.fuzzydl.knowledge_base.KnowledgeBase) fuzzy_dl_owl2.fuzzydl.milp.solution.Solution

Orchestrates the resolution of the query by performing ABox reasoning, preprocessing, and optimization on the provided Knowledge Base. The method initiates timing, solves the ABox of the input KB, and then operates on a cloned version to apply preprocessing steps and optimize against the objective expression. It returns the resulting solution after calculating the total execution time. In the event that the ontology is inconsistent, the method catches the exception and returns a Solution object marked as inconsistent rather than propagating the error.

Parameters:

kb (KnowledgeBase) – The knowledge base containing the ontology and data to be solved and optimized.

Returns:

A Solution object representing the result of optimizing the preprocessed knowledge base. If the knowledge base is inconsistent, returns a Solution indicating an inconsistent state.

Return type:

Solution