protected Branch(final ABox abox, final CompletionStrategy strategy, final DependencySet ds, final int n) { _abox = abox; _strategy = strategy; _termDepends = ds; _tryCount = n; _combinedClash = DependencySet.EMPTY; _tryNext = 0; _branchIndexInABox = abox.getBranchIndex(); _anonCount = abox.getAnonCount(); _nodeCount = abox.size(); }
protected Branch(final ABox abox, final CompletionStrategy strategy, final DependencySet ds, final int n) { _abox = abox; _strategy = strategy; _termDepends = ds; _tryCount = n; _combinedClash = DependencySet.EMPTY; _tryNext = 0; _branchIndexInABox = abox.getBranchIndex(); _anonCount = abox.getAnonCount(); _nodeCount = abox.size(); }
protected DependencySet forceAddType(final ATermAppl c, final DependencySet ds) { // add to effected list if (OpenlletOptions.TRACK_BRANCH_EFFECTS && _abox.getBranchIndex() >= 0) _abox.getBranchEffectTracker().add(_abox.getBranchIndex(), getName()); // if we are checking entailment using a precompleted ABox, _abox.branch // is set to -1. however, since applyAllValues is done automatically // and the edge used in applyAllValues may depend on a _branch we want // this type to be deleted when that edge goes away, i.e. we backtrack // to a position before the max dependency of this type int b = _abox.getBranchIndex(); final int max = ds.max(); if (b == -1 && max != 0) b = max + 1; final DependencySet out = ds.copy(b); _depends.put(c, out); _abox.setChanged(true); return out; }
protected DependencySet forceAddType(final ATermAppl c, final DependencySet ds) { // add to effected list if (OpenlletOptions.TRACK_BRANCH_EFFECTS && _abox.getBranchIndex() >= 0) _abox.getBranchEffectTracker().add(_abox.getBranchIndex(), getName()); // if we are checking entailment using a precompleted ABox, _abox.branch // is set to -1. however, since applyAllValues is done automatically // and the edge used in applyAllValues may depend on a _branch we want // this type to be deleted when that edge goes away, i.e. we backtrack // to a position before the max dependency of this type int b = _abox.getBranchIndex(); final int max = ds.max(); if (b == -1 && max != 0) b = max + 1; final DependencySet out = ds.copy(b); _depends.put(c, out); _abox.setChanged(true); return out; }
/** * Indicates that _node has been changed in a way that requires us to recheck the concepts of given type. * * @param type type of concepts that need to be rechecked */ public void setChanged(final int type) { //Check if we need to updated the completion _queue //Currently we only updated the changed lists for checkDatatypeCount() final QueueElement newElement = new QueueElement(this); //update the datatype _queue if ((type == Node.ALL || type == Node.MIN) && OpenlletOptions.USE_COMPLETION_QUEUE) _abox.getCompletionQueue().add(newElement, NodeSelector.DATATYPE); // add _node to effected list if (_abox.getBranchIndex() >= 0 && OpenlletOptions.TRACK_BRANCH_EFFECTS) _abox.getBranchEffectTracker().add(_abox.getBranchIndex(), getName()); }
/** * Indicates that _node has been changed in a way that requires us to recheck the concepts of given type. * * @param type type of concepts that need to be rechecked */ public void setChanged(final int type) { //Check if we need to updated the completion _queue //Currently we only updated the changed lists for checkDatatypeCount() final QueueElement newElement = new QueueElement(this); //update the datatype _queue if ((type == Node.ALL || type == Node.MIN) && OpenlletOptions.USE_COMPLETION_QUEUE) _abox.getCompletionQueue().add(newElement, NodeSelector.DATATYPE); // add _node to effected list if (_abox.getBranchIndex() >= 0 && OpenlletOptions.TRACK_BRANCH_EFFECTS) _abox.getBranchEffectTracker().add(_abox.getBranchIndex(), getName()); }
/** * Prune the given _node by removing all links going to nominal _nodes and recurse through all successors. No need to remove incoming edges because either * the _node is the first one being pruned so the merge function already handled it or this is a successor _node and its successor is also being pruned * * @param ds */ @Override public void prune(final DependencySet ds) { // add to effected list if (_abox.getBranchIndex() >= 0 && OpenlletOptions.TRACK_BRANCH_EFFECTS) _abox.getBranchEffectTracker().add(_abox.getBranchIndex(), getName()); _pruned = ds; for (int i = 0; i < _outEdges.size(); i++) { final Edge edge = _outEdges.get(i); final Node succ = edge.getTo(); if (succ.isPruned()) continue; else if (succ.isNominal()) succ.removeInEdge(edge); else succ.prune(ds); } }
_abox.getBranchEffectTracker().add(_abox.getBranchIndex(), _name);
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; }
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; }
/** * Prune the given _node by removing all links going to nominal _nodes and recurse through all successors. No need to remove incoming edges because either * the _node is the first one being pruned so the merge function already handled it or this is a successor _node and its successor is also being pruned * * @param ds */ @Override public void prune(final DependencySet ds) { // add to effected list if (_abox.getBranchIndex() >= 0 && OpenlletOptions.TRACK_BRANCH_EFFECTS) _abox.getBranchEffectTracker().add(_abox.getBranchIndex(), getName()); _pruned = ds; for (int i = 0; i < _outEdges.size(); i++) { final Edge edge = _outEdges.get(i); final Node succ = edge.getTo(); if (succ.isPruned()) continue; else if (succ.isNominal()) succ.removeInEdge(edge); else succ.prune(ds); } }
/** * Restore a branch add dependency * * @param assertion * @param branch */ private void restoreBranchAdd(final ATermAppl assertion, final AddBranchDependency branch) { DependencyIndex._logger.fine(() -> " Removing branch add? " + branch.getBranch()); final DependencySet ds = branch.getBranch().getTermDepends(); // get merge dependency ds.removeExplain(assertion); // remove the dependency if (ds.getExplain().isEmpty()) // undo merge if empty { DependencyIndex._logger.fine(" Actually removing branch!"); final ABox abox = _kb.getABox(); phase1(branch, abox); // TODO rename this function when you find the its semantic. if (OpenlletOptions.TRACK_BRANCH_EFFECTS) abox.getBranchEffectTracker().remove(branch.getBranch().getBranchIndexInABox() + 1); updateBranchesOfABox(branch, abox); // Next update abox branches abox.setBranchIndex(abox.getBranchIndex() - 1); // set the branch counter } }
/** * Restore a branch add dependency * * @param assertion * @param branch */ private void restoreBranchAdd(final ATermAppl assertion, final AddBranchDependency branch) { DependencyIndex._logger.fine(() -> " Removing branch add? " + branch.getBranch()); final DependencySet ds = branch.getBranch().getTermDepends(); // get merge dependency ds.removeExplain(assertion); // remove the dependency if (ds.getExplain().isEmpty()) // undo merge if empty { DependencyIndex._logger.fine(" Actually removing branch!"); final ABox abox = _kb.getABox(); phase1(branch, abox); // TODO rename this function when you find the its semantic. if (OpenlletOptions.TRACK_BRANCH_EFFECTS) abox.getBranchEffectTracker().remove(branch.getBranch().getBranchIndexInABox() + 1); updateBranchesOfABox(branch, abox); // Next update abox branches abox.setBranchIndex(abox.getBranchIndex() - 1); // set the branch counter } }
@Override public void addDifferent(final ATermAppl i1, final ATermAppl i2) { if (null == i1 || null == i2) return; // set addition flag _changes.add(ChangeType.ABOX_ADD); // if we can use incremental consistency checking then add to // pseudomodel if (canUseIncConsistency()) { // TODO: refactor the access to the updatedIndividuals and // newIndividuals - add get method _abox.getIncrementalChangeTracker().addUpdatedIndividual(_abox.getIndividual(i1)); _abox.getIncrementalChangeTracker().addUpdatedIndividual(_abox.getIndividual(i2)); // add to pseudomodel - note _branch must be temporarily set to 0 to // ensure that asssertion // will not be restored during backtracking final int branch = _abox.getBranchIndex(); _abox.setBranchIndex(0); _abox.addDifferent(i1, i2); _abox.setBranchIndex(branch); } _abox.addDifferent(i1, i2); _logger.finer(() -> "diff " + i1 + " " + i2); }
@Override public void addDifferent(final ATermAppl i1, final ATermAppl i2) { if (null == i1 || null == i2) return; // set addition flag _changes.add(ChangeType.ABOX_ADD); // if we can use incremental consistency checking then add to // pseudomodel if (canUseIncConsistency()) { // TODO: refactor the access to the updatedIndividuals and // newIndividuals - add get method _abox.getIncrementalChangeTracker().addUpdatedIndividual(_abox.getIndividual(i1)); _abox.getIncrementalChangeTracker().addUpdatedIndividual(_abox.getIndividual(i2)); // add to pseudomodel - note _branch must be temporarily set to 0 to // ensure that asssertion // will not be restored during backtracking final int branch = _abox.getBranchIndex(); _abox.setBranchIndex(0); _abox.addDifferent(i1, i2); _abox.setBranchIndex(branch); } _abox.addDifferent(i1, i2); _logger.finer(() -> "diff " + i1 + " " + i2); }
final int branch = _abox.getBranchIndex(); _abox.setBranchIndex(0);
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; }
if (_abox.getBranchIndex() >= 0 && OpenlletOptions.TRACK_BRANCH_EFFECTS) _abox.getBranchEffectTracker().add(_abox.getBranchIndex(), z.getName());
if (_abox.getBranchIndex() >= 0 && OpenlletOptions.TRACK_BRANCH_EFFECTS) _abox.getBranchEffectTracker().add(_abox.getBranchIndex(), z.getName());
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; }