org.semanticweb.elk.reasoner
Class Reasoner

java.lang.Object
  extended by org.semanticweb.elk.reasoner.stages.AbstractReasonerState
      extended by org.semanticweb.elk.reasoner.Reasoner

public class Reasoner
extends AbstractReasonerState

The class for querying the results of the reasoning tasks for a given ontology. The input ontology is represented internally by the OntologyIndex object, which is updated by adding or removing ElkAxioms (methods addAxiom() and removeAxiom()). When querying the results of the reasoning tasks, the reasoner will ensure that all necessary reasoning stages, such as consistency checking, are performed. Reasoners are created (and pre-configured) by the ReasonerFactory.


Field Summary
protected  boolean allowFreshEntities
          Should fresh entities in reasoner queries be accepted (configuration setting).
protected  ProgressMonitor progressMonitor
          The progress monitor that is used for reporting progress.
protected  ReasonerStageExecutor stageExecutor
          The executor for various stages of the reasoner
 
Constructor Summary
protected Reasoner(AxiomLoader axiomLoader, ReasonerStageExecutor stageExecutor, ExecutorService executor)
          Constructor.
 
Method Summary
 boolean getAllowFreshEntities()
          Get whether fresh entities are allowed.
 TaxonomyNode<ElkClass> getClassNode(ElkClassExpression classExpression)
          Return the TaxonomyNode for the given ElkClassExpression.
 Node<ElkClass> getEquivalentClasses(ElkClassExpression classExpression)
          Return the Node containing equivalent classes of the given ElkClassExpression.
protected  InstanceNode<ElkClass,ElkNamedIndividual> getInstanceNode(ElkNamedIndividual elkNamedIndividual)
          Helper method to get an InstanceNode from the taxonomy.
 Set<? extends Node<ElkNamedIndividual>> getInstances(ElkClassExpression classExpression, boolean direct)
          Return the (direct or indirect) instances of the given ElkClassExpression as specified by the parameter.
protected  int getNumberOfWorkers()
           
protected  ComputationExecutor getProcessExecutor()
           
protected  ProgressMonitor getProgressMonitor()
           
protected  ReasonerStageExecutor getStageExecutor()
           
 Set<? extends Node<ElkClass>> getSubClasses(ElkClassExpression classExpression, boolean direct)
          Return the (direct or indirect) subclasses of the given ElkClassExpression as specified by the parameter.
 Set<? extends Node<ElkClass>> getSuperClasses(ElkClassExpression classExpression, boolean direct)
          Return the (direct or indirect) superclasses of the given ElkClassExpression as specified by the parameter.
protected  TaxonomyNode<ElkClass> getTaxonomyNode(ElkClass elkClass)
          Helper method to get a TaxonomyNode from the taxonomy.
protected  TypeNode<ElkClass,ElkNamedIndividual> getTypeNode(ElkClass elkClass)
          Helper method to get a TypeNode from the taxonomy.
 Set<? extends Node<ElkClass>> getTypes(ElkNamedIndividual elkNamedIndividual, boolean direct)
          Return the (direct or indirect) types of the given ElkNamedIndividual.
 boolean isSatisfiable(ElkClassExpression classExpression)
          Check if the given ElkClassExpression is satisfiable, that is, if it can possibly have instances.
 void setAllowFreshEntities(boolean allow)
          Set if fresh entities should be allowed.
 void setConfigurationOptions(ReasonerConfiguration config)
          This supposed to be the central place where the reasoner gets its configuration options
 void setNumberOfWorkers(int workerNo)
          Sets the number of working threads.
 void setProgressMonitor(ProgressMonitor progressMonitor)
          Set the progress monitor that will be used for reporting progress on all potentially long-running operations.
 boolean shutdown()
          Tries to shut down the reasoner within 1 minute
 boolean shutdown(long timeout, TimeUnit unit)
          Tries to shut down the reasoner within the specified time
 
Methods inherited from class org.semanticweb.elk.reasoner.stages.AbstractReasonerState
clearInterrupt, doneConsistencyCheck, doneInstanceTaxonomy, doneTaxonomy, forceLoading, getAllClasses, getAllNamedIndividuals, getContextMap, getIndexedClassExpressions, getInstanceTaxonomy, getInstanceTaxonomyQuietly, getOntologyIndex, getPropertySaturationMap, getTaxonomy, getTaxonomyQuietly, initClassTaxonomy, initInstanceTaxonomy, interrupt, isAllowIncrementalMode, isInconsistent, isIncrementalMode, isInterrupted, registerAxiomLoader, resetAxiomLoading, setAllowIncrementalMode, setAllowIncrementalTaxonomy, useIncrementalTaxonomy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

progressMonitor

protected ProgressMonitor progressMonitor
The progress monitor that is used for reporting progress.


stageExecutor

protected final ReasonerStageExecutor stageExecutor
The executor for various stages of the reasoner


allowFreshEntities

protected boolean allowFreshEntities
Should fresh entities in reasoner queries be accepted (configuration setting). If false, a ElkFreshEntitiesException will be thrown when encountering entities that did not occur in the ontology.

Constructor Detail

Reasoner

protected Reasoner(AxiomLoader axiomLoader,
                   ReasonerStageExecutor stageExecutor,
                   ExecutorService executor)
Constructor. In most cases, Reasoners should be created by the ReasonerFactory.

Method Detail

setProgressMonitor

public void setProgressMonitor(ProgressMonitor progressMonitor)
Set the progress monitor that will be used for reporting progress on all potentially long-running operations.

Parameters:
progressMonitor -

setAllowFreshEntities

public void setAllowFreshEntities(boolean allow)
Set if fresh entities should be allowed. Fresh entities are entities that occur as parameters of reasoner queries without occurring in the loaded ontology. If false, a ElkFreshEntitiesException will be thrown in such cases. If true, the reasoner will answer as if the entity had been declared (but not used in any axiom).

Parameters:
allow -

getAllowFreshEntities

public boolean getAllowFreshEntities()
Get whether fresh entities are allowed. See setAllowFreshEntities(boolean) for details.

Returns:
true if fresh entities are allowed

getNumberOfWorkers

protected int getNumberOfWorkers()
Specified by:
getNumberOfWorkers in class AbstractReasonerState
Returns:
the maximal number of workers that can be used for running concurrent reasoning tasks

setNumberOfWorkers

public void setNumberOfWorkers(int workerNo)
Sets the number of working threads. Shouldn't be used during reasoning.

Parameters:
workerNo -

setConfigurationOptions

public void setConfigurationOptions(ReasonerConfiguration config)
This supposed to be the central place where the reasoner gets its configuration options

Parameters:
config -

getProcessExecutor

protected ComputationExecutor getProcessExecutor()
Specified by:
getProcessExecutor in class AbstractReasonerState
Returns:
the ComputationExecutor that is used for execution of reasoning processes

getStageExecutor

protected ReasonerStageExecutor getStageExecutor()
Specified by:
getStageExecutor in class AbstractReasonerState
Returns:
the ReasonerStageExecutor that is used for executing the stages of the reasoner.

getProgressMonitor

protected ProgressMonitor getProgressMonitor()
Specified by:
getProgressMonitor in class AbstractReasonerState
Returns:
the ProgressMonitor that is used for reporting progress on all potentially long-running operations.

shutdown

public boolean shutdown(long timeout,
                        TimeUnit unit)
                 throws InterruptedException
Tries to shut down the reasoner within the specified time

Parameters:
timeout - the maximum time to wait
unit - the time unit of the timeout argument
Returns:
true if the operation was successful
Throws:
InterruptedException - if the current thread was interrupted

shutdown

public boolean shutdown()
                 throws InterruptedException
Tries to shut down the reasoner within 1 minute

Returns:
true if the operation was successful
Throws:
InterruptedException - if the current thread was interrupted

getTaxonomyNode

protected TaxonomyNode<ElkClass> getTaxonomyNode(ElkClass elkClass)
                                          throws ElkException
Helper method to get a TaxonomyNode from the taxonomy.

Parameters:
elkClass - an ElkClass for which to find a TaxonomyNode
Returns:
the TaxonomyNode for the given ElkClass
Throws:
ElkException

getInstanceNode

protected InstanceNode<ElkClass,ElkNamedIndividual> getInstanceNode(ElkNamedIndividual elkNamedIndividual)
                                                             throws ElkException
Helper method to get an InstanceNode from the taxonomy.

Parameters:
elkNamedIndividual -
Returns:
the InstanceNode for the given ElkNamedIndividual
Throws:
ElkException - if the result cannot be computed

getTypeNode

protected TypeNode<ElkClass,ElkNamedIndividual> getTypeNode(ElkClass elkClass)
                                                     throws ElkException
Helper method to get a TypeNode from the taxonomy.

Parameters:
elkClass -
Returns:
the TypeNode for the given ElkClass
Throws:
ElkException - if the result cannot be computed

getClassNode

public TaxonomyNode<ElkClass> getClassNode(ElkClassExpression classExpression)
                                    throws ElkException
Return the TaxonomyNode for the given ElkClassExpression. Calling of this method may trigger the computation of the taxonomy, if it has not been done yet. If the input is an ElkClass that does not occur in the ontology and fresh entities are not allowed, a ElkFreshEntitiesException will be thrown.

Parameters:
classExpression - the ElkClassExpression for which to return the Node
Returns:
the TaxonomyNode for the given ElkClassExpression
Throws:
ElkException - if the result cannot be computed

getEquivalentClasses

public Node<ElkClass> getEquivalentClasses(ElkClassExpression classExpression)
                                    throws ElkException
Return the Node containing equivalent classes of the given ElkClassExpression. Calling of this method may trigger the computation of the taxonomy, if it has not been done yet.

Parameters:
classExpression - the ElkClassExpression for which to return the Node
Returns:
the set of Node whose members are ElkClasses equivalent to the given ElkClassExpression
Throws:
ElkException - if the result cannot be computed

getSubClasses

public Set<? extends Node<ElkClass>> getSubClasses(ElkClassExpression classExpression,
                                                   boolean direct)
                                            throws ElkException
Return the (direct or indirect) subclasses of the given ElkClassExpression as specified by the parameter. The method returns a set of Nodes, each of which representing an equivalent class of subclasses. Calling of this method may trigger the computation of the taxonomy, if it has not been done yet.

Parameters:
classExpression - the ElkClassExpression for which to return the subclass Nodes
direct - if true, only direct subclasses should be returned
Returns:
the set of Nodes for direct or indirect subclasses of the given ElkClassExpression according to the specified parameter
Throws:
ElkException - if the result cannot be computed

getSuperClasses

public Set<? extends Node<ElkClass>> getSuperClasses(ElkClassExpression classExpression,
                                                     boolean direct)
                                              throws ElkException
Return the (direct or indirect) superclasses of the given ElkClassExpression as specified by the parameter. The method returns a set of Nodes, each of which representing an equivalent class of superclasses. Calling of this method may trigger the computation of the taxonomy, if it has not been done yet.

Parameters:
classExpression - the ElkClassExpression for which to return the superclass Nodes
direct - if true, only direct superclasses are returned
Returns:
the set of Nodes for direct or indirect superclasses of the given ElkClassExpression according to the specified parameter
Throws:
ElkException - if the result cannot be computed

getInstances

public Set<? extends Node<ElkNamedIndividual>> getInstances(ElkClassExpression classExpression,
                                                            boolean direct)
                                                     throws ElkException
Return the (direct or indirect) instances of the given ElkClassExpression as specified by the parameter. The method returns a set of Nodes, each of which representing an equivalent class of instances. Calling of this method may trigger the computation of the realization, if it has not been done yet.

Parameters:
classExpression - the ElkClassExpression for which to return the instances Nodes
direct - if true, only direct instances are returned
Returns:
the set of Nodes for direct or indirect instances of the given ElkClassExpression according to the specified parameter
Throws:
ElkException - if the result cannot be computed

getTypes

public Set<? extends Node<ElkClass>> getTypes(ElkNamedIndividual elkNamedIndividual,
                                              boolean direct)
                                       throws ElkException
Return the (direct or indirect) types of the given ElkNamedIndividual. The method returns a set of Nodes, each of which representing an equivalent class of types. Calling of this method may trigger the computation of the realization, if it has not been done yet.

Parameters:
elkNamedIndividual - the ElkNamedIndividual for which to return the types Nodes
direct - if true, only direct types are returned
Returns:
the set of Nodes for the direct or indirect types of the given ElkNamedIndividual according to the specified parameter
Throws:
ElkException - if the result cannot be computed

isSatisfiable

public boolean isSatisfiable(ElkClassExpression classExpression)
                      throws ElkException
Check if the given ElkClassExpression is satisfiable, that is, if it can possibly have instances. ElkClassExpressions are not satisfiable if they are equivalent to owl:Nothing. A satisfiable ElkClassExpression is also called consistent or coherent. Calling of this method may trigger the computation of the taxonomy, if it has not been done yet.

Parameters:
classExpression - the ElkClassExpression for which to check satisfiability
Returns:
true if the given input is satisfiable
Throws:
ElkException - if the result cannot be computed


Copyright © 2011-2013 Department of Computer Science, University of Oxford. All Rights Reserved.