/** * Find the next _individual in a given queue * * @param type */ @Override protected void findNext(final int type) { for (; _current < _cutOff; _current++) { Node node = _abox.getNode(_queue.get(_current)); //because we do not maitain the _queue during restore this _node could be non-existent if (node == null) continue; node = node.getSame(); if ((node.isLiteral() && isAllowLiterals() || node.isIndividual() && !isAllowLiterals()) && !node.isPruned()) break; } }
@Override public boolean hasNext() { while (_next == null && _iterator.hasNext()) { final Node node = _iterator.next(); if (node.isLiteral() && node.isRootNominal()) _next = (Literal) node; } return _next != null; }
/** * Sets the _blocker to the specified child of the _current _blocker and returns if the new _blocker candidate is allowed to block. The child is not allowed * to block if it is a literal, or a root, or pruned/merged, or is _blocked itself. * * @param child child of the _current _blocker * @return <code>true</code> if the new _blocker candidate is allowed to block */ public boolean moveBlockerDown(final Node child) { if (child.isLiteral() || child.isRoot() || child.isPruned() || child.isMerged() || ((Individual) child).isBlocked() || child.equals(_blocker)) return false; _blocker = (Individual) child; _rolesToBlocked = null; return true; }
final DependencySet ds = _kb.getABox().getNode(merge.getInd()).getMergeDependency(false); // get merge dependency final Node mergedToInd = _kb.getABox().getNode(merge.getmergedIntoInd()); if (!ind.isSame(mergedToInd)) // check that they are actually the same - else throw error throw new InternalReasonerException(" Restore merge error: " + ind + " not same as " + mergedToInd); if (!ind.isPruned()) throw new InternalReasonerException(" Restore merge error: " + ind + " not pruned"); ind.unprune(ind.getPruned().getBranch()); // unprune to prune _branch ind.undoSetSame(); // undo set same
return; node.addType(c, ds); if (node.isLiteral()) _abox.getKB().getDependencyIndex().addTypeDependency(node.getName(), c, ds); node = node.getSame(); final Role role = _abox.getRole(pred); if (_logger.isLoggable(Level.FINE) && !((Individual) node).hasRSuccessor(role, node)) _logger.fine("SELF: " + node + " " + role + " " + node.getDepends(c)); addEdge((Individual) node, role, node, ds);
public boolean setDifferent(final Node node, final DependencySet dsParam) { DependencySet ds = dsParam; // add to effected list if (_abox.getBranchIndex() >= 0 && OpenlletOptions.TRACK_BRANCH_EFFECTS) _abox.getBranchEffectTracker().add(_abox.getBranchIndex(), node.getName()); if (isDifferent(node)) return false; if (isSame(node)) { ds = ds.union(getMergeDependency(true), _abox.doExplanation()); ds = ds.union(node.getMergeDependency(true), _abox.doExplanation()); _abox.setClash(Clash.nominal(this, ds, node.getName())); if (!ds.isIndependent()) return false; } ds = ds.copy(_abox.getBranchIndex()); _differents.put(node, ds); node.setDifferent(this, ds); _abox.setChanged(true); return true; }
Node obj = getNode(o); if (subj.isMerged() && obj.isMerged()) return null; if (obj.isMerged()) obj.addInEdge(new DefaultEdge(role, subj, obj, ds)); ds = ds.union(obj.getMergeDependency(true), true); ds = ds.copy(ds.max() + 1); obj = obj.getSame(); obj.addInEdge(edge); obj.addInEdge(edge); else if (!existingEdge.getDepends().isIndependent()) obj.removeInEdge(existingEdge); obj.addInEdge(edge);
public boolean setSame(final Node node, final DependencySet ds) { if (isSame(node)) return false; if (isDifferent(node)) { //CHW - added for incremental reasoning support - this is needed as we will need to backjump if possible if (OpenlletOptions.USE_INCREMENTAL_CONSISTENCY) _abox.setClash(Clash.nominal(this, ds.union(_mergeDepends, _abox.doExplanation()).union(node._mergeDepends, _abox.doExplanation()), node.getName())); else _abox.setClash(Clash.nominal(this, ds, node.getName())); return false; } _mergedTo = node; _mergeDepends = ds.copy(_abox.getBranchIndex()); node.addMerged(this); return true; }
_abox.getBranchEffectTracker().add(_abox.getBranchIndex(), y.getName()); _abox.getBranchEffectTracker().add(_abox.getBranchIndex(), z.getName()); _abox.getKB().getDependencyIndex().addMergeDependency(y.getName(), z.getName(), ds); if (y.isDifferent(z)) _abox.setClash(Clash.nominal(y, y.getDifferenceDependency(z).union(ds, _abox.doExplanation()))); return; if (!y.isSame(z))
/** * Apply all values restriction for the Top object role * * @param allTopC * @param c * @param ds */ public void applyAllValuesTop(final ATermAppl allTopC, final ATermAppl c, final DependencySet ds) { for (final Node node : _strategy.getABox().getNodes().values()) if (node.isIndividual() && !node.isPruned() && !node.hasType(c)) { node.addType(c, ds); node.addType(allTopC, ds); if (_strategy.getABox().isClosed()) break; } } }
for (final Iterator<ATermAppl> i = getTypes().iterator(); i.hasNext();) final DependencySet d = getDepends(c); removeType(c); restored = true; for (final ATermAppl c : conjunctions) final DependencySet d = getDepends(c); for (ATermList cs = (ATermList) c.getArgument(0); !cs.isEmpty(); cs = cs.getNext()) addType(conj, d);
protected void applyAllValues(final Individual subj, final Role pred, final Node obj, final ATermAppl c, final DependencySet ds) { if (!obj.hasType(c)) { _logger.fine(() -> "ALL : " + subj + " -> " + pred + " -> " + obj + " : " + ATermUtils.toString(c) + " - " + ds); // because we do not maintain the _queue it could be the case that this _node is pruned, so return if (obj.isPruned()) return; _strategy.addType(obj, c, ds); } }
protected Node getNode(final NodeProvider provider, final Token token) { Node node = provider.getNode(null, token); if (node.isMerged()) { final boolean doExplanation = _strategy.getABox().doExplanation(); _ds = _ds.union(node.getMergeDependency(true), doExplanation); node = node.getSame(); } return node; }
/** * @param node * @param type * @return true if a type should be readded to a node */ private static boolean requiredAddType(final Node node, final ATermAppl type) { return !(type == null || node.hasType(type) && !ATermUtils.isAnd(type)); }
public Node getSame() { if (_mergedTo == this) return this; return _mergedTo.getSame(); }