Package org.mindswap.pellet.tableau.branch

Examples of org.mindswap.pellet.tableau.branch.Branch


      // decrease branch id for each branch after the branch we're
      // removing
      // also need to change the dependency set for each label
      for( int i = branch.getBranch().getBranch(); i < branches.size(); i++ ) {
        // cast for ease
        Branch br = branches.get( i );
       
        DependencySet tDS = br.getTermDepends();
       
        // update the term depends in the branch
        if( tDS.getBranch() > branch.getBranch().getBranch() )
          tDS = tDS.copy( tDS.getBranch() - 1 );
 
        for( int j = branch.getBranch().getBranch(); j < kb.getABox().getBranches().size(); j++ ) {
          if( tDS.contains( j ) ) {
            tDS.remove( j );
            tDS.add( j - 1 );
          }
        }
 
        // also need to decrement the branch number
        br.setBranch( br.getBranch() - 1 );
        br.setTermDepends( tDS );
      }
 
      // remove the actual branch
      branches.remove( branch.getBranch() );
 
View Full Code Here


        else
          abox.setComplete( true );
      }
      else {
        if( PelletOptions.SATURATE_TABLEAU ) {
          Branch unexploredBranch = null;
          for( int i = abox.getBranches().size() - 1; i >= 0; i-- ) {
            unexploredBranch = abox.getBranches().get( i );
            unexploredBranch.setTryNext( unexploredBranch.getTryNext() + 1 );
            if( unexploredBranch.getTryNext() < unexploredBranch.getTryCount() ) {
              restore( unexploredBranch );
              System.out.println( "restoring branch " + unexploredBranch.getBranch()
                  + " tryNext = " + unexploredBranch.getTryNext()
                  + " tryCount = " + unexploredBranch.getTryCount() );
              unexploredBranch.tryNext();
              break;
            }
            else {
              System.out.println( "removing branch " + unexploredBranch.getBranch() );
              abox.getBranches().remove( i );
              unexploredBranch = null;
            }
          }
          if( unexploredBranch == null ) {
View Full Code Here

        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 );
      }
View Full Code Here

            abox.getCompletionQueue().flushQueue();
        }
      }
      else {
        if( PelletOptions.SATURATE_TABLEAU ) {
          Branch unexploredBranch = null;
          for( int i = abox.getBranches().size() - 1; i >= 0; i-- ) {
            unexploredBranch = abox.getBranches().get( i );
            unexploredBranch.setTryNext( unexploredBranch.getTryNext() + 1 );
            if( unexploredBranch.getTryNext() < unexploredBranch.getTryCount() ) {
              restore( unexploredBranch );
              System.out.println( "restoring branch " + unexploredBranch.getBranch()
                  + " tryNext = " + unexploredBranch.getTryNext()
                  + " tryCount = " + unexploredBranch.getTryCount() );
              unexploredBranch.tryNext();
              break;
            }
            else {
              System.out.println( "removing branch " + unexploredBranch.getBranch() );
              abox.getBranches().remove( i );
              unexploredBranch = null;
            }
          }
          if( unexploredBranch == null ) {
View Full Code Here

      if( lastBranch <= 0 )
        return false;

      List<Branch> branches = abox.getBranches();
      abox.stats.backjumps += (branches.size() - lastBranch);
      Branch newBranch = null;
      if( lastBranch <= branches.size() ) {
        branches.subList( lastBranch, branches.size() ).clear();
        newBranch = branches.get( lastBranch - 1 );

        if( log.isLoggable( Level.FINE ) )
          log.fine( "JUMP: " + lastBranch );
        if( newBranch == null || lastBranch != newBranch.getBranch() )
          throw new RuntimeException(
              "Internal error in reasoner: Trying to backtrack branch " + lastBranch
                  + " but got " + newBranch );

        if( newBranch.getTryNext() < newBranch.getTryCount() )
          newBranch.setLastClash( abox.getClash().getDepends() );

        newBranch.setTryNext( newBranch.getTryNext() + 1 );

        if( newBranch.getTryNext() < newBranch.getTryCount() ) {
          restore( newBranch );

          branchFound = newBranch.tryNext();
        }
      }

      if( !branchFound ) {
        abox.getClash().getDepends().remove( lastBranch );
        if( log.isLoggable( Level.FINE ) )
          log.fine( "FAIL: " + lastBranch );
      }
      else {
        // create another copy of the mnx list here because we may backtrack to the same
        // branch multiple times and we want the same copy to be available every time
        mayNeedExpanding = new LinkedList<Individual>( mnx.get( newBranch.getBranch() ) );
        mnx.subList( newBranch.getBranch() + 1, mnx.size() ).clear();
        if( log.isLoggable( Level.FINE ) )
          log.fine( "MNX : " + mayNeedExpanding );
      }

    }
View Full Code Here

      // need to update the branch node count as this is node has been
      // added otherwise during back jumping this node can be removed
      for( int j = 0; j < abox.getBranches().size(); j++ ) {
        // get next branch
        Branch branch = abox.getBranches().get( j );
        branch.setNodeCount( branch.getNodeCount() + 1 );
      }

      // track updated and new individuals; this is needed for the
      // incremental completion strategy
      abox.getIncrementalChangeTracker().addUpdatedIndividual( abox.getIndividual( i ) );
View Full Code Here

   
    if( extraIndividual == null || copyIndividuals ) {
      setBranch( abox.branch );
      branches = new ArrayList<Branch>( abox.branches.size() );
      for( int i = 0, n = abox.branches.size(); i < n; i++ ) {
        Branch branch = abox.branches.get( i );
        Branch copy;

        if( sourceABox == null ) {
          copy = branch.copyTo( this );
          copy.setNodeCount( branch.getNodeCount() + extra );
        }
        else {
          copy = branch;
        }
        branches.add( copy );
View Full Code Here

    }
   
   

    for( int i = 0, n = branches.size(); i < n; i++ ) {
      Branch branch = branches.get( i );
      Branch copy = branch.copyTo( this );
      branches.set( i, copy );

      if( i >= sourceABox.getBranches().size() ) {
              copy.setNodeCount( copy.getNodeCount() + nodeCount );
            }
            else {
              copy.setNodeCount( copy.getNodeCount() + 1 );
            }
    }

    t.stop();
View Full Code Here

        else
          abox.setComplete( true );
      }
      else {
        if( PelletOptions.SATURATE_TABLEAU ) {
          Branch unexploredBranch = null;
          for( int i = abox.getBranches().size() - 1; i >= 0; i-- ) {
            unexploredBranch = abox.getBranches().get( i );
            unexploredBranch.setTryNext( unexploredBranch.getTryNext() + 1 );
            if( unexploredBranch.getTryNext() < unexploredBranch.getTryCount() ) {
              restore( unexploredBranch );
              System.out.println( "restoring branch " + unexploredBranch.getBranch()
                  + " tryNext = " + unexploredBranch.getTryNext() + " tryCount = "
                  + unexploredBranch.getTryCount() );
              unexploredBranch.tryNext();
              break;
            }
            else {
              System.out.println( "removing branch " + unexploredBranch.getBranch() );
              abox.getBranches().remove( i );
              unexploredBranch = null;
            }
          }
          if( unexploredBranch == null ) {
View Full Code Here

        else
          abox.setComplete( true );
      }
      else {
        if( PelletOptions.SATURATE_TABLEAU ) {
          Branch unexploredBranch = null;
          for( int i = abox.getBranches().size() - 1; i >= 0; i-- ) {
            unexploredBranch = abox.getBranches().get( i );
            unexploredBranch.setTryNext( unexploredBranch.getTryNext() + 1 );
            if( unexploredBranch.getTryNext() < unexploredBranch.getTryCount() ) {
              restore( unexploredBranch );
              System.out.println( "restoring branch " + unexploredBranch.getBranch()
                  + " tryNext = " + unexploredBranch.getTryNext()
                  + " tryCount = " + unexploredBranch.getTryCount() );
              unexploredBranch.tryNext();
              break;
            }
            else {
              System.out.println( "removing branch " + unexploredBranch.getBranch() );
              abox.getBranches().remove( i );
              unexploredBranch = null;
            }
          }
          if( unexploredBranch == null ) {
View Full Code Here

TOP

Related Classes of org.mindswap.pellet.tableau.branch.Branch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.