![JAR search and dependency download from the Maven repository](/logo.png)
org.semanticweb.HermiT.tableau.DescriptionGraphManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.semanticweb.hermit Show documentation
Show all versions of org.semanticweb.hermit Show documentation
HermiT is reasoner for ontologies written using the Web
Ontology Language (OWL). Given an OWL file, HermiT can determine whether or
not the ontology is consistent, identify subsumption relationships between
classes, and much more.
This is the maven build of HermiT and is designed for people who wish to use
HermiT from within the OWL API. It is now versioned in the main HermiT
version repository, although not officially supported by the HermiT
developers.
The version number of this package is a composite of the HermiT version and
an value representing releases of this packaged version. So, 1.3.7.1 is the
first release of the mavenized version of HermiT based on the 1.3.7 release
of HermiT.
This package includes the Jautomata library
(http://jautomata.sourceforge.net/), and builds with it directly. This
library appears to be no longer under active development, and so a "fork"
seems appropriate. No development is intended or anticipated on this code
base.
/* Copyright 2008, 2009, 2010 by the Oxford University Computing Laboratory
This file is part of HermiT.
HermiT is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
HermiT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with HermiT. If not, see .
*/
package org.semanticweb.HermiT.tableau;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.semanticweb.HermiT.model.DescriptionGraph;
import org.semanticweb.HermiT.model.ExistsDescriptionGraph;
import org.semanticweb.HermiT.monitor.TableauMonitor;
public final class DescriptionGraphManager implements Serializable {
private static final long serialVersionUID=4536271856850424712L;
protected final Tableau m_tableau;
protected final InterruptFlag m_interruptFlag;
protected final TableauMonitor m_tableauMonitor;
protected final ExtensionManager m_extensionManager;
protected final MergingManager m_mergingManager;
protected final OccurrenceManager m_occurrenceManager;
protected final Map m_descriptionGraphIndices;
protected final DescriptionGraph[] m_descriptionGraphsByIndex;
protected final ExtensionTable[] m_extensionTablesByIndex;
protected final Object[][] m_auxiliaryTuples1;
protected final Object[][] m_auxiliaryTuples2;
protected final List m_newNodes;
protected final UnionDependencySet m_binaryUnionDependencySet;
protected final ExtensionTable.Retrieval[] m_deltaOldRetrievals;
public DescriptionGraphManager(Tableau tableau) {
m_tableau=tableau;
m_interruptFlag=m_tableau.m_interruptFlag;
m_tableauMonitor=m_tableau.m_tableauMonitor;
m_extensionManager=m_tableau.m_extensionManager;
m_mergingManager=m_tableau.m_mergingManager;
m_occurrenceManager=new OccurrenceManager();
m_descriptionGraphIndices=new HashMap();
Set extensionTables=new HashSet();
List descriptionGraphsByIndex=new ArrayList();
List extensionTablesByIndex=new ArrayList();
for (DescriptionGraph descriptionGraph : m_tableau.m_permanentDLOntology.getAllDescriptionGraphs()) {
m_descriptionGraphIndices.put(descriptionGraph,Integer.valueOf(descriptionGraphsByIndex.size()));
descriptionGraphsByIndex.add(descriptionGraph);
ExtensionTable extensionTable=m_extensionManager.getExtensionTable(descriptionGraph.getNumberOfVertices()+1);
extensionTablesByIndex.add(extensionTable);
extensionTables.add(extensionTable);
}
m_descriptionGraphsByIndex=new DescriptionGraph[descriptionGraphsByIndex.size()];
descriptionGraphsByIndex.toArray(m_descriptionGraphsByIndex);
m_extensionTablesByIndex=new ExtensionTable[extensionTablesByIndex.size()];
extensionTablesByIndex.toArray(m_extensionTablesByIndex);
m_auxiliaryTuples1=new Object[m_descriptionGraphsByIndex.length][];
m_auxiliaryTuples2=new Object[m_descriptionGraphsByIndex.length][];
for (int index=0;index();
m_binaryUnionDependencySet=new UnionDependencySet(2);
m_deltaOldRetrievals=new ExtensionTable.Retrieval[extensionTables.size()];
int index=0;
for (ExtensionTable extensionTable : extensionTables)
m_deltaOldRetrievals[index++]=extensionTable.createRetrieval(new boolean[extensionTable.getArity()],ExtensionTable.View.DELTA_OLD);
}
public void clear() {
for (int index=0;index=1;--mergePosition) {
Node nodeFirst=(Node)extensionTable.getTupleObject(thisTupleIndex,mergePosition);
Node nodeSecond=(Node)extensionTable.getTupleObject(tupleIndex,mergePosition);
if (nodeFirst!=nodeSecond) {
m_mergingManager.mergeNodes(nodeFirst,nodeSecond,m_binaryUnionDependencySet);
hasChange=true;
}
m_interruptFlag.checkInterrupt();
}
}
else {
m_extensionManager.setClash(m_binaryUnionDependencySet);
hasChange=true;
}
if (m_tableauMonitor!=null)
m_tableauMonitor.descriptionGraphCheckingFinished(thisGraphIndex,thisTupleIndex,thisPositionInTuple,graphIndex,tupleIndex,positionInTuple);
}
listNode=m_occurrenceManager.getListNodeComponent(listNode,OccurrenceManager.NEXT_NODE);
m_interruptFlag.checkInterrupt();
}
}
}
retrieval.next();
}
m_interruptFlag.checkInterrupt();
}
return hasChange;
}
public boolean isSatisfied(ExistsDescriptionGraph existsDescriptionGraph,Node node) {
int graphIndex=m_descriptionGraphIndices.get(existsDescriptionGraph.getDescriptionGraph()).intValue();
int positionInTuple=existsDescriptionGraph.getVertex()+1;
int listNode=node.m_firstGraphOccurrenceNode;
while (listNode!=-1) {
if (graphIndex==m_occurrenceManager.getListNodeComponent(listNode,OccurrenceManager.GRAPH_INDEX) && positionInTuple==m_occurrenceManager.getListNodeComponent(listNode,OccurrenceManager.POSITION_IN_TUPLE))
return true;
listNode=m_occurrenceManager.getListNodeComponent(listNode,OccurrenceManager.NEXT_NODE);
}
return false;
}
public void mergeGraphs(Node mergeFrom,Node mergeInto,UnionDependencySet binaryUnionDependencySet) {
int listNode=mergeFrom.m_firstGraphOccurrenceNode;
while (listNode!=-1) {
int graphIndex=m_occurrenceManager.getListNodeComponent(listNode,OccurrenceManager.GRAPH_INDEX);
int tupleIndex=m_occurrenceManager.getListNodeComponent(listNode,OccurrenceManager.TUPLE_INDEX);
int positionInTuple=m_occurrenceManager.getListNodeComponent(listNode,OccurrenceManager.POSITION_IN_TUPLE);
ExtensionTable extensionTable=m_extensionTablesByIndex[graphIndex];
Object[] auxiliaryTuple=m_auxiliaryTuples1[graphIndex];
extensionTable.retrieveTuple(auxiliaryTuple,tupleIndex);
if (extensionTable.isTupleActive(auxiliaryTuple)) {
m_binaryUnionDependencySet.m_dependencySets[0]=extensionTable.getDependencySet(tupleIndex);
boolean isCore=extensionTable.isCore(tupleIndex);
if (m_tableauMonitor!=null) {
Object[] sourceTuple=m_auxiliaryTuples2[graphIndex];
System.arraycopy(auxiliaryTuple,0,sourceTuple,0,auxiliaryTuple.length);
auxiliaryTuple[positionInTuple]=mergeInto;
m_tableauMonitor.mergeFactStarted(mergeFrom,mergeInto,sourceTuple,auxiliaryTuple);
m_extensionManager.addTuple(auxiliaryTuple,m_binaryUnionDependencySet,isCore);
m_tableauMonitor.mergeFactFinished(mergeFrom,mergeInto,sourceTuple,auxiliaryTuple);
}
else {
auxiliaryTuple[positionInTuple]=mergeInto;
m_extensionManager.addTuple(auxiliaryTuple,m_binaryUnionDependencySet,isCore);
}
}
listNode=m_occurrenceManager.getListNodeComponent(listNode,OccurrenceManager.NEXT_NODE);
}
}
public void descriptionGraphTupleAdded(int tupleIndex,Object[] tuple) {
int graphIndex=m_descriptionGraphIndices.get(tuple[0]).intValue();
for (int positionInTuple=tuple.length-1;positionInTuple>=1;--positionInTuple) {
Node node=(Node)tuple[positionInTuple];
int listNode=m_occurrenceManager.newListNode();
m_occurrenceManager.initializeListNode(listNode,graphIndex,tupleIndex,positionInTuple,node.m_firstGraphOccurrenceNode);
node.m_firstGraphOccurrenceNode=listNode;
}
}
public void descriptionGraphTupleRemoved(int tupleIndex,Object[] tuple) {
for (int positionInTuple=tuple.length-1;positionInTuple>=1;--positionInTuple) {
Node node=(Node)tuple[positionInTuple];
int listNode=node.m_firstGraphOccurrenceNode;
assert m_occurrenceManager.getListNodeComponent(listNode,OccurrenceManager.GRAPH_INDEX)==m_descriptionGraphIndices.get(tuple[0]).intValue();
assert m_occurrenceManager.getListNodeComponent(listNode,OccurrenceManager.TUPLE_INDEX)==tupleIndex;
assert m_occurrenceManager.getListNodeComponent(listNode,OccurrenceManager.POSITION_IN_TUPLE)==positionInTuple;
node.m_firstGraphOccurrenceNode=m_occurrenceManager.getListNodeComponent(listNode,OccurrenceManager.NEXT_NODE);
m_occurrenceManager.deleteListNode(listNode);
}
}
public void expand(ExistsDescriptionGraph existsDescriptionGraph,Node forNode) {
if (m_tableau.m_tableauMonitor!=null)
m_tableau.m_tableauMonitor.existentialExpansionStarted(existsDescriptionGraph,forNode);
m_newNodes.clear();
DescriptionGraph descriptionGraph=existsDescriptionGraph.getDescriptionGraph();
DependencySet dependencySet=m_extensionManager.getConceptAssertionDependencySet(existsDescriptionGraph,forNode);
Object[] auxiliaryTuple=m_auxiliaryTuples1[m_descriptionGraphIndices.get(descriptionGraph).intValue()];
auxiliaryTuple[0]=descriptionGraph;
for (int vertex=0;vertex=m_numberOfPages) {
if (pageIndex>=m_nodePages.length) {
int[][] newNodePages=new int[m_nodePages.length*3/2][];
System.arraycopy(m_nodePages,0,newNodePages,0,m_nodePages.length);
m_nodePages=newNodePages;
}
m_nodePages[pageIndex]=new int[LIST_NODE_PAGE_SIZE];
m_numberOfPages++;
}
setListNodeComponent(m_firstFreeListNode,NEXT_NODE,-1);
}
return newListNode;
}
public void deleteListNode(int listNode) {
setListNodeComponent(listNode,NEXT_NODE,m_firstFreeListNode);
m_firstFreeListNode=listNode;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy