fuzzy_dl_owl2.fuzzydl.query.min.min_instance_query
Calculates the greatest lower bound of membership for a specific individual relative to a given concept using Mixed-Integer Linear Programming optimization.
Description
The software 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. Execution involves cloning the current knowledge base to prevent side effects, applying necessary constraints, and performing 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.
Classes
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
- 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
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[source]
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[source]
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[source]
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: