fuzzy_dl_owl2.fuzzydl.query.max.max_instance_query
A reasoning query that calculates the maximum degree of membership for a specific individual within a given concept by formulating and solving a mixed-integer linear programming optimization problem.
Description
The logic centers on determining the highest possible truth value supported by the knowledge base for a specific entity belonging to a particular category. To achieve this, the implementation constructs an optimization objective that maximizes the variable representing the individual’s membership degree. Before optimization, the system clones the knowledge base to ensure the original state remains unaltered, then applies preprocessing steps that include adding necessary assertions and enabling dynamic blocking strategies for complex logical constructs like universal quantification. The execution workflow involves solving the ABox constraints first, followed by the optimization step, which yields a solution containing the calculated maximum degree or signals an inconsistency if the constraints cannot be satisfied.
Classes
This class implements a reasoning query designed to calculate the maximum degree of membership for a specific individual within a given concept. It functions by constructing an optimization problem that maximizes the variable associated with the individual's membership, effectively retrieving the highest truth value supported by the knowledge base. To ensure the integrity of the original state, the query operates on a cloned version of the knowledge base, where it preprocesses the problem by adding necessary assertions and enabling dynamic blocking strategies for complex logical constructs like universal quantification. The execution involves solving the ABox and optimizing the objective expression, returning a solution that reflects the maximum membership degree or indicates an inconsistent ontology if the constraints cannot be satisfied. |
Module Contents
UML Class Diagram for MaxInstanceQuery
- class MaxInstanceQuery(
- 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 implements a reasoning query designed to calculate the maximum degree of membership for a specific individual within a given concept. It functions by constructing an optimization problem that maximizes the variable associated with the individual’s membership, effectively retrieving the highest truth value supported by the knowledge base. To ensure the integrity of the original state, the query operates on a cloned version of the knowledge base, where it preprocesses the problem by adding necessary assertions and enabling dynamic blocking strategies for complex logical constructs like universal quantification. The execution involves solving the ABox and optimizing the objective expression, returning a solution that reflects the maximum membership degree or indicates an inconsistent ontology if the constraints cannot be satisfied.
- __str__() str
Returns a formatted string representation of the query, posing the question of whether the individual self.ind is an instance of the concept self.conc. The string is constructed using an f-string and concludes with the suffix “? <=”, adhering to a specific syntax likely used for display or serialization within the module. This operation is read-only and does not alter the state of the object.
- Returns:
Returns a string representation of the object, formatted as a question asking if self.ind is an instance of self.conc.
- Return type:
str
- preprocess(kb: fuzzy_dl_owl2.fuzzydl.knowledge_base.KnowledgeBase) None
Prepares the knowledge base for a maximum instance query by initializing the necessary MILP variables and constraints. It retrieves the variable associated with the specific individual and concept, increments the counter for legacy binary variables, and constructs an objective expression to maximize the retrieved variable. If the concept expression involves universal restrictions or negated existential restrictions, the method enables dynamic blocking on the knowledge base to handle these specific logic constructs. Finally, it adds an assertion linking the individual, concept, and variable degree to the knowledge base and triggers the solver to process these assertions.
- Parameters:
kb (KnowledgeBase) – The KnowledgeBase instance managing the MILP context, variable storage, and assertion solving. It is updated with new constraints and internal counters during the preprocessing step.
- solve(kb: fuzzy_dl_owl2.fuzzydl.knowledge_base.KnowledgeBase) fuzzy_dl_owl2.fuzzydl.milp.solution.Solution
Executes the solving workflow for the maximum instance query, starting a timer and invoking the ABox solver on the provided KnowledgeBase, potentially modifying it in place. The method then creates a clone of the KnowledgeBase to perform preprocessing and optimization based on the instance’s objective expression, ensuring the optimization logic does not further alter the original input. After calculating the total execution time, the resulting Solution is returned. If the ontology is determined to be inconsistent during the ABox solving phase, the method handles the exception by returning a Solution indicating an inconsistent KnowledgeBase.
- Parameters:
kb (KnowledgeBase) – The knowledge base containing the ontology and constraints to be solved and optimized.
- Returns:
The Solution object resulting from the optimization of the preprocessed knowledge base, or a solution indicating an inconsistent ontology.
- Return type: