/** * Expands the axiom set by adding the referencing axioms for the * specified entity. */ private int expandWithReferencingAxioms(OWLEntity obj, int limit) throws OWLException { Set<OWLAxiom> expansionAxioms = new HashSet<OWLAxiom>(); // First expand by getting the defining axioms - if this doesn't // return any axioms, then get the axioms that reference the entity for (OWLOntology ont : owlOntologyManager.getImportsClosure(getOWLOntology())) { expansionAxioms.addAll(ont.getReferencingAxioms(obj)); } expansionAxioms.removeAll(debuggingAxioms); return addMax(expansionAxioms, debuggingAxioms, limit); }
resetSatisfiabilityTestCounter(); expandWithDefiningAxioms((OWLClass) getCurrentClass(), expansionLimit); LOGGER.info("Initial axiom count: {}", Integer.valueOf(debuggingAxioms.size())); int totalAdded = 0; int expansionCount = 0; while (isSatisfiable()) { LOGGER.info("Expanding axioms (expansion {})", Integer.valueOf(expansionCount)); expansionCount++; int numberAdded = expandAxioms(); totalAdded += numberAdded; LOGGER.info(" ... expanded by {}", Integer.valueOf(numberAdded)); resetSatisfiabilityTestCounter(); LOGGER.info("Fast pruning..."); fastPruningWindowSize = DEFAULT_FAST_PRUNING_WINDOW_SIZE; performFastPruning(); LOGGER.info("... end of fast pruning. Axioms remaining: {}", Integer.valueOf(debuggingAxioms.size())); Integer.valueOf(satTestCount)); int totalSatTests = satTestCount; resetSatisfiabilityTestCounter(); LOGGER.info("Slow pruning..."); performSlowPruning(); LOGGER.info("... end of slow pruning"); LOGGER.info("Performed {} satisfiability tests during slow pruning",
@Override public Set<OWLAxiom> getSOSForInconsistentClass(OWLClassExpression cls) { reset(); currentClass = setupDebuggingClass(cls); generateSOSAxioms(); getOWLOntology().remove(temporaryAxioms); debuggingAxioms.removeAll(temporaryAxioms); return new HashSet<>(debuggingAxioms); }
/** * Setup debugging class. * * @param cls the cls * @return the oWL class */ private OWLClass setupDebuggingClass(OWLClassExpression cls) { if (!cls.isAnonymous()) { return (OWLClass) cls; } else { // The class is anonymous, so we need to assign it a name OWLClass curCls = df.getOWLClass(createIRI()); temporaryAxioms.add(df.getOWLEquivalentClassesAxiom(createSet(curCls, cls))); temporaryAxioms.forEach(ax -> man.addAxiom(getOWLOntology(), ax)); return curCls; } }
int added = expandWithDefiningAxioms(curObj, remainingSpace); axiomsAdded += added; remainingSpace -= added; int added = expandWithReferencingAxioms(curObj, expansionLimit); axiomsAdded += added; remainingSpace -= added;
/** * Tests the satisfiability of the test class. The ontology is recreated * before the test is performed. * * @return true, if is satisfiable */ private boolean isSatisfiable() { createDebuggingOntology(); OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(getDebuggingOntology()); satTestCount++; boolean sat = reasoner.isSatisfiable(verifyNotNull(currentClass)); reasoner.dispose(); return sat; }
private void createDebuggingOntology() { if (debuggingOntology != null) { man.removeOntology(verifyNotNull(debuggingOntology)); } IRI iri = createIRI(); SimpleIRIMapper mapper = new SimpleIRIMapper(iri, iri); man.getIRIMappers().add(mapper); try { debuggingOntology = man.createOntology(iri); } catch (OWLOntologyCreationException e) { throw new OWLRuntimeException(e); } man.getIRIMappers().remove(mapper); List<AddAxiom> changes = new ArrayList<>(); debuggingAxioms.forEach(ax -> changes.add(new AddAxiom(getDebuggingOntology(), ax))); temporaryAxioms.forEach(ax -> changes.add(new AddAxiom(getDebuggingOntology(), ax))); // Ensure the ontology contains the signature of the class which is // being debugged OWLAxiom ax = df.getOWLSubClassOfAxiom(verifyNotNull(currentClass), df.getOWLThing()); changes.add(new AddAxiom(getDebuggingOntology(), ax)); man.applyChanges(changes); }
protected void removeAndTest(OWLAxiom ax) { debuggingAxioms.remove(ax); if (isSatisfiable()) { // Affects satisfiability, so add back in debuggingAxioms.add(ax); } }
/** * Tests the satisfiability of the test class. The ontology * is recreated before the test is performed. */ private boolean isSatisfiable() throws OWLException { createDebuggingOntology(); // RDFXMLRenderer ren = new RDFXMLRenderer(); // ren.setOWLOntologyManager(owlOntologyManager); // ren.render(debuggingOntology, IRI.create("file:/Users/matthewhorridge/Desktop/DebuggingOntology" + ontologyCounter + ".owlapi")); ontologyCounter++; OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(debuggingOntology); satTestCount++; boolean sat = reasoner.isSatisfiable(currentClass); reasoner.dispose(); return sat; }
private void createDebuggingOntology() throws OWLException { //System.out.println("Debugging ontology: " + ontologyCounter); if (debuggingOntology != null) { owlOntologyManager.removeOntology(debuggingOntology); } IRI iri = createIRI(); SimpleIRIMapper mapper = new SimpleIRIMapper(iri, iri); owlOntologyManager.addIRIMapper(mapper); debuggingOntology = owlOntologyManager.createOntology(iri); owlOntologyManager.removeIRIMapper(mapper); List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(); for (OWLAxiom ax : debuggingAxioms) { changes.add(new AddAxiom(debuggingOntology, ax)); } for (OWLAxiom ax : temporaryAxioms) { changes.add(new AddAxiom(debuggingOntology, ax)); } // Ensure the ontology contains the signature of the class which is being debugged OWLDataFactory factory = owlOntologyManager.getOWLDataFactory(); OWLAxiom ax = factory.getOWLSubClassOfAxiom(currentClass, factory.getOWLThing()); changes.add(new AddAxiom(debuggingOntology, ax)); owlOntologyManager.applyChanges(changes); }
/** * Setup debugging class. * * @param cls the cls * @return the oWL class */ private OWLClass setupDebuggingClass(OWLClassExpression cls) { if (!cls.isAnonymous()) { return (OWLClass) cls; } else { // The class is anonymous, so we need to assign it a name OWLClass curCls = df.getOWLClass(createIRI()); temporaryAxioms.add(df.getOWLEquivalentClassesAxiom(createSet(curCls, cls))); temporaryAxioms.forEach(ax -> man.addAxiom(getOWLOntology(), ax)); return curCls; } }
int added = expandWithDefiningAxioms(curObj, remainingSpace); axiomsAdded += added; remainingSpace -= added; int added = expandWithReferencingAxioms(curObj, expansionLimit); axiomsAdded += added; remainingSpace -= added;
/** * Tests the satisfiability of the test class. The ontology is recreated * before the test is performed. * * @return true, if is satisfiable */ private boolean isSatisfiable() { createDebuggingOntology(); OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(getDebuggingOntology()); satTestCount++; boolean sat = reasoner.isSatisfiable(verifyNotNull(currentClass)); reasoner.dispose(); return sat; }
private void createDebuggingOntology() { if (debuggingOntology != null) { man.removeOntology(verifyNotNull(debuggingOntology)); } IRI iri = createIRI(); SimpleIRIMapper mapper = new SimpleIRIMapper(iri, iri); man.getIRIMappers().add(mapper); try { debuggingOntology = man.createOntology(iri); } catch (OWLOntologyCreationException e) { throw new OWLRuntimeException(e); } man.getIRIMappers().remove(mapper); List<AddAxiom> changes = new ArrayList<>(); debuggingAxioms.forEach(ax -> changes.add(new AddAxiom(getDebuggingOntology(), ax))); temporaryAxioms.forEach(ax -> changes.add(new AddAxiom(getDebuggingOntology(), ax))); // Ensure the ontology contains the signature of the class which is // being debugged OWLAxiom ax = df.getOWLSubClassOfAxiom(verifyNotNull(currentClass), df.getOWLThing()); changes.add(new AddAxiom(getDebuggingOntology(), ax)); man.applyChanges(changes); }
protected void removeAndTest(OWLAxiom ax) { debuggingAxioms.remove(ax); if (isSatisfiable()) { // Affects satisfiability, so add back in debuggingAxioms.add(ax); } }
resetSatisfiabilityTestCounter(); expandWithDefiningAxioms((OWLClass) getCurrentClass(), expansionLimit); LOGGER.info("Initial axiom count: {}", Integer.valueOf(debuggingAxioms.size())); int totalAdded = 0; int expansionCount = 0; while (isSatisfiable()) { LOGGER.info("Expanding axioms (expansion {})", Integer.valueOf(expansionCount)); expansionCount++; int numberAdded = expandAxioms(); totalAdded += numberAdded; LOGGER.info(" ... expanded by {}", Integer.valueOf(numberAdded)); resetSatisfiabilityTestCounter(); LOGGER.info("Fast pruning..."); fastPruningWindowSize = DEFAULT_FAST_PRUNING_WINDOW_SIZE; performFastPruning(); LOGGER.info("... end of fast pruning. Axioms remaining: {}", Integer.valueOf(debuggingAxioms.size())); Integer.valueOf(satTestCount)); int totalSatTests = satTestCount; resetSatisfiabilityTestCounter(); LOGGER.info("Slow pruning..."); performSlowPruning(); LOGGER.info("... end of slow pruning"); LOGGER.info("Performed {} satisfiability tests during slow pruning",
@Override public Set<OWLAxiom> getSOSForInconsistentClass(OWLClassExpression cls) { reset(); currentClass = setupDebuggingClass(cls); generateSOSAxioms(); getOWLOntology().remove(temporaryAxioms); debuggingAxioms.removeAll(temporaryAxioms); return new HashSet<>(debuggingAxioms); }
/** * Expands the axiom set by adding the referencing axioms for the specified * entity. * * @param obj the obj * @param limit the limit * @return the int */ private int expandWithReferencingAxioms(OWLEntity obj, int limit) { // First expand by getting the defining axioms - if this doesn't // return any axioms, then get the axioms that reference the entity Set<OWLAxiom> expansionAxioms = asUnorderedSet( getOWLOntology().referencingAxioms(obj, INCLUDED)); expansionAxioms.removeAll(debuggingAxioms); return addMax(expansionAxioms, debuggingAxioms, limit); }
/** * Setup debugging class. * * @param cls the cls * @return the oWL class */ private OWLClass setupDebuggingClass(OWLClassExpression cls) { if (!cls.isAnonymous()) { return (OWLClass) cls; } else { // The class is anonymous, so we need to assign it a name OWLClass curCls = df.getOWLClass(createIRI()); temporaryAxioms.add(df.getOWLEquivalentClassesAxiom(createSet(curCls, cls))); temporaryAxioms.forEach(ax -> man.addAxiom(getOWLOntology(), ax)); return curCls; } }
int added = expandWithDefiningAxioms(curObj, remainingSpace); axiomsAdded += added; remainingSpace -= added; int added = expandWithReferencingAxioms(curObj, expansionLimit); axiomsAdded += added; remainingSpace -= added;