From 8241a535a55508b6c504f4f0b426612fe95d15a5 Mon Sep 17 00:00:00 2001 From: RncLsn Date: Wed, 8 Jul 2015 18:53:00 +0100 Subject: Internalisation: added condition for existential variables (classes HermitChecker and QueryGraph). Answer dependencies: found bug, trying to solve; excluding dependency analysis solve the problem. --- .../ac/ox/cs/pagoda/endomorph/DependencyGraph.java | 12 ++++----- src/uk/ac/ox/cs/pagoda/endomorph/Endomorph.java | 29 +++++++++++++++++---- .../ac/ox/cs/pagoda/query/rollup/QueryGraph.java | 3 +-- .../ox/cs/pagoda/reasoner/full/HermitChecker.java | 30 ++++++++++++---------- 4 files changed, 48 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/uk/ac/ox/cs/pagoda/endomorph/DependencyGraph.java b/src/uk/ac/ox/cs/pagoda/endomorph/DependencyGraph.java index e7f1c96..8514808 100644 --- a/src/uk/ac/ox/cs/pagoda/endomorph/DependencyGraph.java +++ b/src/uk/ac/ox/cs/pagoda/endomorph/DependencyGraph.java @@ -114,23 +114,23 @@ public class DependencyGraph { // print(); - topolocialOrder = null; + topologicalOrder = null; Utility.logDebug("link: " + link); } - LinkedList topolocialOrder = null; + LinkedList topologicalOrder = null; public LinkedList getTopologicalOrder() { - if (topolocialOrder != null) return topolocialOrder; + if (topologicalOrder != null) return topologicalOrder; - topolocialOrder = new LinkedList(); + topologicalOrder = new LinkedList(); Queue toVisit = new LinkedList(entrances); Map toVisitedInComingDegree = new HashMap(); int count; while (!toVisit.isEmpty()) { Clique cu = toVisit.remove(); - topolocialOrder.add(cu); + topologicalOrder.add(cu); if (outGoingEdges.containsKey(cu)) for (Clique cv: outGoingEdges.get(cu)) { if (toVisitedInComingDegree.containsKey(cv)) { @@ -144,7 +144,7 @@ public class DependencyGraph { } } - return topolocialOrder; + return topologicalOrder; } private void addNodeTuple(NodeTuple u) { diff --git a/src/uk/ac/ox/cs/pagoda/endomorph/Endomorph.java b/src/uk/ac/ox/cs/pagoda/endomorph/Endomorph.java index 1c853d7..9ca73a1 100644 --- a/src/uk/ac/ox/cs/pagoda/endomorph/Endomorph.java +++ b/src/uk/ac/ox/cs/pagoda/endomorph/Endomorph.java @@ -34,7 +34,11 @@ public class Endomorph extends Checker { graph = new Graph(record.getRelevantOntology()); dGraph = new DependencyGraph(graph); } - + + /* + * FIXME + * The result is unsound. The output is not deterministic. + * */ @Override public int check(AnswerTuples answerTuples) { if(isDisposed()) throw new DisposedException(); @@ -57,11 +61,26 @@ public class Endomorph extends Checker { Utility.logInfo("The number of individuals to be checked by Homomorphism checker: " + counter); // CheckPlan plan = new PlainPlan(this.checker, dGraph.cliques); // CheckPlan plan = new OpenEndMultiThreadPlan(this.checker, dGraph); - CheckPlan plan = new OpenEndPlan(fullReasoner, dGraph, m_record); - int answerCounter = plan.check(); - + + CheckPlan plan = new OpenEndPlan(fullReasoner, dGraph, m_record); + int answerCounter = plan.check(); + + +// // BEGIN: debugging code +// Set validatedAnswers = new HashSet<>(); +// for (answerTuples.reset(); answerTuples.isValid(); answerTuples.moveNext()) { +// if(fullReasoner.check(answerTuples.getTuple())) { +// validatedAnswers.add(answerTuples.getTuple()); +// } +// } +// m_record.addLowerBoundAnswers(validatedAnswers); +// +// Utility.logDebug("The number of correct answers: " + validatedAnswers.size()); +// return validatedAnswers.size(); +//// END: debugging code + Utility.logDebug("The number of correct answers: " + answerCounter); - return answerCounter; + return answerCounter; } public OWLOntology getOntology() { diff --git a/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java b/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java index 116e724..02697b8 100644 --- a/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java +++ b/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java @@ -109,8 +109,7 @@ public class QueryGraph { Set axioms = new HashSet<>(); for(Map.Entry> entry : concepts.map.entrySet()) { if(existVars.contains(entry.getKey())) { - OWLClassExpression conjunction = - factory.getOWLObjectIntersectionOf(factory.getOWLThing()); + OWLClassExpression conjunction = factory.getOWLThing(); for(OWLClassExpression owlClassExpression : entry.getValue()) { conjunction = factory.getOWLObjectIntersectionOf(conjunction, owlClassExpression.accept(visitor)); } diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java b/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java index 9574845..0362fc2 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java @@ -106,19 +106,23 @@ public class HermitChecker extends Checker { Map sub = answerTuple.getAssignment(answerVariable[1]); Set toCheckAxioms = qGraph.getAssertions(sub); -// // TODO complete -// Set toCheckExistentialAxioms = qGraph.getExistentialAxioms(sub); -// -// // TODO possibly inefficient -// for(OWLAxiom subclassAxiom : toCheckExistentialAxioms) { -// Utility.logInfo("Checking consistency of ontology union " + subclassAxiom); -// ontology.getOWLOntologyManager().addAxiom(ontology, subclassAxiom); -// if(hermit.isConsistent()) { -// Utility.logDebug("@TIME to check one tuple: " + t.duration()); -// return false; -// } -// ontology.getOWLOntologyManager().removeAxiom(ontology, subclassAxiom); -// } + // TODO complete + Set toCheckExistentialAxioms = qGraph.getExistentialAxioms(sub); + + // TODO possibly inefficient + for(OWLAxiom subclassAxiom : toCheckExistentialAxioms) { + Utility.logDebug("Checking consistency of ontology union " + subclassAxiom); + ontology.getOWLOntologyManager().addAxiom(ontology, subclassAxiom); + hermit.flush(); + if(hermit.isConsistent()) { + ontology.getOWLOntologyManager().removeAxiom(ontology, subclassAxiom); + hermit.flush(); + Utility.logDebug("@TIME to check one tuple: " + t.duration()); + return false; + } + ontology.getOWLOntologyManager().removeAxiom(ontology, subclassAxiom); + hermit.flush(); + } // for (OWLAxiom axiom: toCheckAxioms) System.out.println(axiom.toString()); -- cgit v1.2.3