fuzzy_dl_owl2.fuzzydl.query.defuzzify.mom_defuzzify_query
Implements the Mean of Maxima defuzzification strategy to derive a crisp numerical value for a specific feature of an individual within a fuzzy ontology.
Description
The logic centers on determining the maximum degree of membership an individual has to a given concept by first solving the ABox and executing a max-satisfiability query. Once this peak membership degree is established, the system creates a modified version of the knowledge base where the individual is asserted to possess the concept at that specific degree. Within this constrained environment, the process identifies the Mixed-Integer Linear Programming variable corresponding to the target feature and performs optimization to locate both the minimum and maximum values that satisfy the constraints. The final crisp output is calculated as the arithmetic mean of these two boundary values, effectively representing the center of the plateau where the membership function is maximized. Error handling ensures that inconsistencies or missing role relations result in appropriate warnings or inconsistent solution states rather than unhandled failures.
Classes
This class implements a defuzzification strategy that calculates the crisp value of a specific feature for an individual based on the "middle of maxima" principle within a fuzzy ontology framework. To determine the result, it first establishes the maximum degree of membership the individual has to a given concept. It then performs optimization to find the smallest and largest feature values that satisfy this maximum membership degree, effectively identifying the boundaries of the membership plateau. The final output is the arithmetic mean of these two boundary values. Users should instantiate this class with a target concept, an individual, and a feature name, then invoke the solve method with a knowledge base to retrieve the calculated solution. |
Module Contents
UML Class Diagram for MomDefuzzifyQuery
- class MomDefuzzifyQuery(
- c: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
- ind: fuzzy_dl_owl2.fuzzydl.individual.individual.Individual,
- feature_name: str,
Bases:
fuzzy_dl_owl2.fuzzydl.query.defuzzify.defuzzify_query.DefuzzifyQuery
This class implements a defuzzification strategy that calculates the crisp value of a specific feature for an individual based on the “middle of maxima” principle within a fuzzy ontology framework. To determine the result, it first establishes the maximum degree of membership the individual has to a given concept. It then performs optimization to find the smallest and largest feature values that satisfy this maximum membership degree, effectively identifying the boundaries of the membership plateau. The final output is the arithmetic mean of these two boundary values. Users should instantiate this class with a target concept, an individual, and a feature name, then invoke the solve method with a knowledge base to retrieve the calculated solution.
- __str__() str
Provides a human-readable string representation of the Middle of Maxima (MoM) defuzzification query object. The returned string formats a description that includes the specific feature name and instance identifier associated with the query, ending with an equals sign to facilitate the display of the resulting value. This method relies on the existence of the f_name and a attributes; accessing this string representation will raise an AttributeError if these attributes are not defined on the instance.
- Returns:
Returns a string describing the middle of the maxima defuzzification calculation for the specific feature and instance.
- Return type:
str
- get_obj_expression(variable: fuzzy_dl_owl2.fuzzydl.milp.variable.Variable) fuzzy_dl_owl2.fuzzydl.milp.expression.Expression
Returns a placeholder objective expression for the provided variable. This method is currently not utilized within the defuzzification logic and serves as a stub implementation. It constructs and returns an Expression object containing a single Term with a coefficient of -1.0, regardless of the input variable’s state.
- Parameters:
variable (Variable) – The variable object to be used in constructing the expression.
- Returns:
An Expression object representing the negative of the provided variable.
- Return type:
- preprocess(kb: fuzzy_dl_owl2.fuzzydl.knowledge_base.KnowledgeBase) None
Prepares the internal state of the query object for the Mean of Maxima (MoM) defuzzification process by interacting with the provided KnowledgeBase. This method retrieves and validates the configuration of the target output variable, ensuring that the necessary fuzzy sets and universe of discourse are available for calculation. As a side effect, it updates the instance attributes to store intermediate results or references required for the subsequent defuzzification step, potentially raising an error if the specified variable cannot be found in the KnowledgeBase or is improperly configured.
- Parameters:
kb (KnowledgeBase) – The knowledge base object to be preprocessed.
- solve(kb: fuzzy_dl_owl2.fuzzydl.knowledge_base.KnowledgeBase) fuzzy_dl_owl2.fuzzydl.milp.solution.Solution
Executes a Mean of Maxima (MOM) defuzzification strategy to derive a crisp numerical value from a fuzzy knowledge base. The method begins by solving the ABox of the input knowledge base and determining the maximum degree of membership for the target concept and individual via a max-satisfiability query. It then creates a modified clone of the knowledge base where the individual is asserted to possess the concept at this maximum degree, subsequently identifying the MILP variable associated with the specified role relation. The solution is calculated by optimizing this variable to find both the minimum and maximum values within the feasible region and returning their average. Edge cases include returning an inconsistent solution if the ontology cannot be solved or if optimization fails, and returning None with a warning if the required role relations or variables are absent. The method has side effects of solving the ABox of the input knowledge base and printing warnings or stack traces to standard output upon encountering errors.
- Parameters:
kb (KnowledgeBase) – The input knowledge base containing the ontology, individuals, and assertions used to perform the reasoning and optimization tasks.
- Returns:
A Solution object containing the calculated numeric value (Mean of Maximums) derived from fuzzy logic optimization, or None if defuzzification fails. The Solution may also indicate an inconsistent knowledge base.
- Return type: