fuzzy_dl_owl2.fuzzydl.query.max.max_instance_query
A reasoning query that computes the maximum degree of membership for a specific individual within a given concept using mixed-integer linear programming.
Description
It operates within a fuzzy description logic framework to determine the highest possible truth value for an individual belonging to a specific concept. The logic relies on constructing a mixed-integer linear programming problem where the objective is to maximize the variable representing the individual’s membership degree. To ensure the original knowledge base remains unaltered during the optimization process, the implementation operates on a cloned version of the data structure. Special handling is included for complex logical constructs, such as universal restrictions, by enabling dynamic blocking strategies to manage the constraints effectively. The workflow involves solving the ABox, preprocessing the constraints, and finally optimizing the objective expression to return a solution that reflects the maximum supported degree or signals an inconsistent ontology.
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[source]
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[source]
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[source]
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: