public boolean isClassified() { return super.isPrepared() && _kb.isClassified(); }
public boolean isClassified() { return super.isPrepared() && _kb.isClassified(); }
public boolean isClassified() { return super.isPrepared() && _kb.isClassified(); }
public void computKBCosts() { final int classCount = _kb.getClasses().size(); final int indCount = _kb.getClasses().size(); // FIXME the following constants are chosen based on very limited // empirical analysis noSatCost = 1; oneSatCost = 2; // this is a very rough and pretty inaccurate estimate // of classification. the number of sat checks done during // classification varies widely but due to various optimizations // it is a relatively small percentage of the brute-force n^2 classificationCost = _kb.isClassified() ? noSatCost : classCount * classCount * oneSatCost / 10; // the same arguments for classification applies here too realizationCost = _kb.isRealized() ? noSatCost : classificationCost + oneSatCost * classCount * indCount; // instance retrieval performs sat checks on only individuals that // are not ruled out by obvious (non-)instance checks thus it is // again a very small percentage instanceRetrievalCost = _kb.isRealized() ? noSatCost : indCount * oneSatCost / 100; // either KB is realized and this operation is pretty much free or // we perform realization and pay the cost // NOTE: the behavior to realize the KB at every type retrieval query // is subject to change and would require a change here too classRetrievalCost = _kb.isRealized() ? noSatCost : realizationCost; }
public void computKBCosts() { final int classCount = _kb.getClasses().size(); final int indCount = _kb.getClasses().size(); // FIXME the following constants are chosen based on very limited // empirical analysis noSatCost = 1; oneSatCost = 2; // this is a very rough and pretty inaccurate estimate // of classification. the number of sat checks done during // classification varies widely but due to various optimizations // it is a relatively small percentage of the brute-force n^2 classificationCost = _kb.isClassified() ? noSatCost : classCount * classCount * oneSatCost / 10; // the same arguments for classification applies here too realizationCost = _kb.isRealized() ? noSatCost : classificationCost + oneSatCost * classCount * indCount; // instance retrieval performs sat checks on only individuals that // are not ruled out by obvious (non-)instance checks thus it is // again a very small percentage instanceRetrievalCost = _kb.isRealized() ? noSatCost : indCount * oneSatCost / 100; // either KB is realized and this operation is pretty much free or // we perform realization and pay the cost // NOTE: the behavior to realize the KB at every type retrieval query // is subject to change and would require a change here too classRetrievalCost = _kb.isRealized() ? noSatCost : realizationCost; }
private Set<OWLAxiom> getCachedExplanation(final OWLClassExpression unsatClass) { final OpenlletReasoner pellet = getReasoner(); if (!pellet.getKB().isClassified()) return null; final Pair<OWLClass, OWLClass> pair = getSubClassAxiom(unsatClass); if (pair != null) { final Set<Set<ATermAppl>> exps = TaxonomyUtils.getSuperExplanations(pellet.getKB().getTaxonomy(), pellet.term(pair.first), pellet.term(pair.second)); if (exps != null) { final Set<OWLAxiom> result = convertExplanation(exps.iterator().next()); if (_logger.isLoggable(Level.FINE)) _logger.fine("Cached explanation: " + result); return result; } } return null; }
private Set<OWLAxiom> getCachedExplanation(final OWLClassExpression unsatClass) { final OpenlletReasoner pellet = getReasoner(); if (!pellet.getKB().isClassified()) return null; final Pair<OWLClass, OWLClass> pair = getSubClassAxiom(unsatClass); if (pair != null) { final Set<Set<ATermAppl>> exps = TaxonomyUtils.getSuperExplanations(pellet.getKB().getTaxonomy(), pellet.term(pair.first), pellet.term(pair.second)); if (exps != null) { final Set<OWLAxiom> result = convertExplanation(exps.iterator().next()); if (_logger.isLoggable(Level.FINE)) _logger.fine("Cached explanation: " + result); return result; } } return null; }
private Set<OWLAxiom> getCachedExplanation(final OWLClassExpression unsatClass) { final OpenlletReasoner pellet = getReasoner(); if (!pellet.getKB().isClassified()) return null; final Pair<OWLClass, OWLClass> pair = getSubClassAxiom(unsatClass); if (pair != null) { final Set<Set<ATermAppl>> exps = TaxonomyUtils.getSuperExplanations(pellet.getKB().getTaxonomy(), pellet.term(pair.first), pellet.term(pair.second)); if (exps != null) { final Set<OWLAxiom> result = convertExplanation(exps.iterator().next()); if (_logger.isLoggable(Level.FINE)) _logger.fine("Cached explanation: " + result); return result; } } return null; }
@Override public CandidateSet<ATermAppl> getObviousInstances(final ATermAppl cParam, final Collection<ATermAppl> individuals) { ATermAppl c = cParam; c = ATermUtils.normalize(c); final Set<ATermAppl> subs = _kb.isClassified() && _kb.getTaxonomy().contains(c) ? _kb.getTaxonomy().getFlattenedSubs(c, false) : Collections.<ATermAppl> emptySet(); subs.remove(ATermUtils.BOTTOM); final CandidateSet<ATermAppl> cs = new CandidateSet<>(); for (final ATermAppl x : individuals) { final Bool isType = isKnownType(x, c, subs); cs.add(x, isType); } return cs; }
@Override public CandidateSet<ATermAppl> getObviousInstances(final ATermAppl cParam, final Collection<ATermAppl> individuals) { ATermAppl c = cParam; c = ATermUtils.normalize(c); final Set<ATermAppl> subs = _kb.isClassified() && _kb.getTaxonomy().contains(c) ? _kb.getTaxonomy().getFlattenedSubs(c, false) : Collections.<ATermAppl> emptySet(); subs.remove(ATermUtils.BOTTOM); final CandidateSet<ATermAppl> cs = new CandidateSet<>(); for (final ATermAppl x : individuals) { final Bool isType = isKnownType(x, c, subs); cs.add(x, isType); } return cs; }
if (OpenlletOptions.USE_CACHING && !_kb.isClassified()) for (final QueryAtom a : _oldQuery.getAtoms()) for (final ATermAppl arg : a.getArguments())
if (OpenlletOptions.USE_CACHING && !_kb.isClassified()) for (final QueryAtom a : _oldQuery.getAtoms()) for (final ATermAppl arg : a.getArguments())
/** * {@inheritDoc} */ @Override public boolean isPrecomputed(final InferenceType inferenceType) { switch (inferenceType) { case CLASS_HIERARCHY: return _kb.isClassified(); case CLASS_ASSERTIONS: return _kb.isRealized(); case OBJECT_PROPERTY_HIERARCHY: return _kb.getRBox().isObjectTaxonomyPrepared(); case DATA_PROPERTY_HIERARCHY: return _kb.getRBox().isDataTaxonomyPrepared(); default: return false; } }
/** * {@inheritDoc} */ @Override public boolean isPrecomputed(final InferenceType inferenceType) { switch (inferenceType) { case CLASS_HIERARCHY: return _kb.isClassified(); case CLASS_ASSERTIONS: return _kb.isRealized(); case OBJECT_PROPERTY_HIERARCHY: return _kb.getRBox().isObjectTaxonomyPrepared(); case DATA_PROPERTY_HIERARCHY: return _kb.getRBox().isDataTaxonomyPrepared(); default: return false; } }
/** * {@inheritDoc} */ @Override public boolean isPrecomputed(final InferenceType inferenceType) { switch (inferenceType) { case CLASS_HIERARCHY: return _kb.isClassified(); case CLASS_ASSERTIONS: return _kb.isRealized(); case OBJECT_PROPERTY_HIERARCHY: return _kb.getRBox().isObjectTaxonomyPrepared(); case DATA_PROPERTY_HIERARCHY: return _kb.getRBox().isDataTaxonomyPrepared(); default: return false; } }
@Test public void testUnsatClasses1() { classes(_B, _C, _D); _kb.addSubClass(_B, and(_C, _D)); assertTrue(_kb.getUnsatisfiableClasses().isEmpty()); assertEquals(singleton(BOTTOM), _kb.getAllUnsatisfiableClasses()); assertFalse(_kb.isClassified()); assertTrue(_kb.getUnsatisfiableClasses().isEmpty()); assertEquals(singleton(BOTTOM), _kb.getAllUnsatisfiableClasses()); }
@Test public void testUnsatClasses2() { classes(_B, _C, _D); _kb.addDisjointClass(_C, _D); _kb.addSubClass(_B, and(_C, _D)); assertEquals(singleton(_B), _kb.getUnsatisfiableClasses()); assertEquals(SetUtils.create(_B, BOTTOM), _kb.getAllUnsatisfiableClasses()); assertFalse(_kb.isClassified()); assertEquals(singleton(_B), _kb.getUnsatisfiableClasses()); assertEquals(SetUtils.create(_B, BOTTOM), _kb.getAllUnsatisfiableClasses()); }
@Test // This tests ticket 147 // Not having _timeout functionality in classification and realization makes // it harder to interrupt these processes public void testClassificationTimeout() { boolean timeout = false; final OWLOntology ont = loadOntology(OWLManager.createOWLOntologyManager(), _base + "food.owl"); final OpenlletReasoner pellet = OpenlletReasonerFactory.getInstance().createReasoner(ont); final KnowledgeBase kb = pellet.getKB(); final Timer timer = kb.getTimers().createTimer("classify"); timer.setTimeout(1); try { kb.classify(); } catch (final TimeoutException e) { _logger.log(Level.FINER, "", e); timeout = true; } assertTrue(timeout); assertFalse(kb.isClassified()); }
@Test public void testClassificationStatus1EL() { // Same as testClassificationStatus1 but with EL // classifier final KnowledgeBase kb = new KnowledgeBaseImpl(); final ATermAppl C = term("C"); final ATermAppl D = term("D"); final ATermAppl E = term("E"); kb.addClass(C); kb.addClass(D); kb.addClass(E); kb.addSubClass(C, D); assertFalse(kb.isClassified()); assertFalse(kb.isRealized()); kb.getToldTaxonomy(); kb.addIndividual(term("a")); kb.prepare(); assertFalse(kb.isClassified()); assertFalse(kb.isRealized()); }
@Test public void testClassificationStatus1() { // Related to ticket #193 final KnowledgeBase kb = new KnowledgeBaseImpl(); final ATermAppl C = term("C"); final ATermAppl D = term("D"); final ATermAppl E = term("E"); kb.addClass(C); kb.addClass(D); kb.addClass(E); kb.addSubClass(C, D); // force expressivity out of EL kb.addSubClass(E, or(C, D)); assertFalse(kb.isClassified()); assertFalse(kb.isRealized()); kb.getToldTaxonomy(); kb.addIndividual(term("a")); kb.prepare(); assertFalse(kb.isClassified()); assertFalse(kb.isRealized()); }