throw new InternalReasonerException( "Backtrack: Trying to backtrack to branch "
+ lastBranch + " but has only " + abox.getBranches().size()
+ " branches. Clash found: " + abox.getClash() );
else if( PelletOptions.USE_INCREMENTAL_DELETION ) {
// get the last branch
Branch br = abox.getBranches().get( lastBranch - 1 );
// if this is the last disjunction, merge pair, etc. for the
// branch (i.e, br.tryNext == br.tryCount-1) and there are no
// other branches to test (ie.
// abox.getClash().depends.size()==2),
// then update depedency index and return false
if( (br.getTryNext() == br.getTryCount() - 1)
&& abox.getClash().getDepends().size() == 2 ) {
abox.getKB().getDependencyIndex().addCloseBranchDependency( br,
abox.getClash().getDepends() );
return false;
}
}
List<Branch> branches = abox.getBranches();
abox.stats.backjumps += (branches.size() - lastBranch);
// CHW - added for incremental deletion support
if( PelletOptions.USE_TRACING && PelletOptions.USE_INCREMENTAL_CONSISTENCY ) {
// we must clean up the KB dependecny index
List<Branch> brList = branches.subList( lastBranch, branches.size() );
for( Iterator<Branch> it = brList.iterator(); it.hasNext(); ) {
// remove from the dependency index
abox.getKB().getDependencyIndex().removeBranchDependencies( it.next() );
}
brList.clear();
}
else {
// old approach
branches.subList( lastBranch, branches.size() ).clear();
}
// get the branch to try
Branch newBranch = branches.get( lastBranch - 1 );
if( log.isLoggable( Level.FINE ) )
log.fine( "JUMP: Branch " + lastBranch );
if( lastBranch != newBranch.getBranch() )
throw new InternalReasonerException( "Backtrack: Trying to backtrack to branch "
+ lastBranch + " but got " + newBranch.getBranch() );
// set the last clash before restore
if( newBranch.getTryNext() < newBranch.getTryCount() ) {
newBranch.setLastClash( abox.getClash().getDepends() );
}
// increment the counter
newBranch.setTryNext( newBranch.getTryNext() + 1 );
// no need to restore this branch if we exhausted possibilities
if( newBranch.getTryNext() < newBranch.getTryCount() ) {
// undo the changes done after this branch
restore( newBranch );
}
// try the next possibility
branchFound = newBranch.tryNext();
if( !branchFound ) {
if( log.isLoggable( Level.FINE ) )
log.fine( "FAIL: Branch " + lastBranch );
}