Fuzzy DL OWL 2

Contents:

  • Fuzzy DL OWL 2
  • Funding
  • Installation and Configuration
  • Fuzzy Description Logic Grammatics
  • Fuzzy Concepts
  • Fuzzy OWL 2 XML Annotations
  • Usage
  • API Reference
    • Description
    • Sub-packages
      • fuzzy_dl_owl2
        • Submodules
Fuzzy DL OWL 2
  • API Reference
  • fuzzy_dl_owl2
  • fuzzy_dl_owl2.fuzzydl
  • fuzzy_dl_owl2.fuzzydl.query
  • fuzzy_dl_owl2.fuzzydl.query.max
  • fuzzy_dl_owl2.fuzzydl.query.max.max_related_query
  • View page source

fuzzy_dl_owl2.fuzzydl.query.max.max_related_query

A query mechanism that calculates the maximum degree of truth for a specific relationship between two individuals within a fuzzy knowledge base.

Description

This component extends the functionality of relationship queries by focusing on optimization rather than simple verification, specifically seeking the highest possible truth value for a role assertion between two defined entities. By leveraging Mixed-Integer Linear Programming (MILP), the logic translates the fuzzy description logic constraints into mathematical expressions that can be solved numerically. During execution, the system isolates the problem by cloning the knowledge base to prevent side effects on the original data, then formulates an objective function that targets the specific variable representing the relationship degree. Error handling is integrated directly into the workflow to manage cases where the underlying ontology is inconsistent, ensuring that the process fails gracefully without corrupting the system state.

Classes

MaxRelatedQuery

This class models a query designed to determine the maximum degree of truth for a specific relationship between two individuals within a fuzzy knowledge base. It operates by formulating an optimization problem where the goal is to maximize the membership degree of the assertion that the first individual is related to the second individual via a specified role. To use this class, instantiate it with the two individuals involved and the name of the role, then invoke the solve method with a knowledge base instance to retrieve the optimal solution. The implementation handles potential ontology inconsistencies gracefully by returning a specific solution state.

Module Contents

UML Class Diagram for MaxRelatedQuery

UML Class Diagram for MaxRelatedQuery

class MaxRelatedQuery(
a: fuzzy_dl_owl2.fuzzydl.individual.individual.Individual,
b: fuzzy_dl_owl2.fuzzydl.individual.individual.Individual,
role_name: str,
)[source]

Bases: fuzzy_dl_owl2.fuzzydl.query.related_query.RelatedQuery

Inheritance diagram of fuzzy_dl_owl2.fuzzydl.query.max.max_related_query.MaxRelatedQuery

This class models a query designed to determine the maximum degree of truth for a specific relationship between two individuals within a fuzzy knowledge base. It operates by formulating an optimization problem where the goal is to maximize the membership degree of the assertion that the first individual is related to the second individual via a specified role. To use this class, instantiate it with the two individuals involved and the name of the role, then invoke the solve method with a knowledge base instance to retrieve the optimal solution. The implementation handles potential ontology inconsistencies gracefully by returning a specific solution state.

Parameters:
  • ind1 (Individual) – The first individual in the role assertion, representing the subject of the relationship.

  • ind2 (Individual) – The second individual in the role assertion, representing the target of the relationship.

  • role (str) – The name of the role through which the two individuals are related.

__str__() → str[source]

Returns a human-readable string representation of the query object, formatted as a question regarding the relationship between two individuals. The method constructs the string by interpolating the first individual, the second individual, and the relationship role into a template that asks if the first is related to the second through the specified role. The output string concludes with a prompt indicator (‘<= ‘) and relies on the standard string conversion of the object’s attributes, ensuring that the method does not modify the object’s state.

Returns:

A string representation of the relationship query, formatted as a question asking if the first individual is related to the second through the specified role.

Return type:

str

preprocess(kb: fuzzy_dl_owl2.fuzzydl.knowledge_base.KnowledgeBase) → None[source]

Prepares the query for execution by translating a specific relationship constraint into a Mixed-Integer Linear Programming (MILP) formulation within the provided Knowledge Base. It constructs a HasValueConcept representing the restriction that an individual must have a specific value for a given role, retrieves the corresponding MILP variable, and asserts this relationship with a degree derived from that variable. As a side effect, this method increments the knowledge base’s counter for legacy variables, initializes the instance’s objective expression to optimize the relationship’s degree, and triggers the solving of all current assertions to update the system state.

Parameters:

kb (KnowledgeBase) – The knowledge base context used to access the MILP model, add assertions, update variable counters, and trigger the solver.

solve(kb: fuzzy_dl_owl2.fuzzydl.knowledge_base.KnowledgeBase) → fuzzy_dl_owl2.fuzzydl.milp.solution.Solution[source]

Executes the optimization query by first resolving the ABox of the provided Knowledge Base to ensure consistency. Upon successful resolution, the method clones the Knowledge Base to preserve the original state, applies necessary preprocessing, and runs an optimization routine using the defined objective expression. The process includes tracking the total execution time. If the Knowledge Base is determined to be inconsistent during the initial resolution step, the method intercepts the exception and returns a Solution object specifically marked as inconsistent.

Parameters:

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

Returns:

The Solution object resulting from the optimization process, or a specific solution state indicating the knowledge base is inconsistent.

Return type:

Solution

ind1: fuzzy_dl_owl2.fuzzydl.individual.individual.Individual
ind2: fuzzy_dl_owl2.fuzzydl.individual.individual.Individual
role: str
Previous Next

© Copyright 2025, Giuseppe Filippone.

Built with Sphinx using a theme provided by Read the Docs.