Package org.mindswap.pellet

Examples of org.mindswap.pellet.Node


                order[getTryNext()] = minIndex;             
            }
      }
    }
   
    Node node = this.node.getSame();

    for(; getTryNext() < getTryCount(); tryNext++) {
      ATermAppl d = disj[getTryNext()];

      if(PelletOptions.USE_SEMANTIC_BRANCHING) {
        for(int m = 0; m < getTryNext(); m++)
          strategy.addType(node, ATermUtils.negate( disj[m] ), prevDS[m]);
      }

      DependencySet ds = null;
      if(getTryNext() == getTryCount() - 1 && !PelletOptions.SATURATE_TABLEAU) {
        ds = getTermDepends();
        for(int m = 0; m < getTryNext(); m++)
          ds = ds.union(prevDS[m], abox.doExplanation());

        //CHW - added for incremental reasoning and rollback through deletions
        if(PelletOptions.USE_INCREMENTAL_DELETION)
          ds.setExplain( getTermDepends().getExplain() );
        else
          ds.remove(getBranch());
      }
      else {
        //CHW - Changed for tracing purposes
        if(PelletOptions.USE_INCREMENTAL_DELETION)
          ds = getTermDepends().union(new DependencySet(getBranch()), abox.doExplanation());
        else{
          ds = new DependencySet(getBranch());
          //added for tracing
          Set<ATermAppl> explain = new HashSet<ATermAppl>();
          explain.addAll(getTermDepends().getExplain());
          ds.setExplain( explain );                     
        }
            }
           
      if( log.isLoggable( Level.FINE ) )
                log.fine( getDebugMsg() );   
     
      ATermAppl notD = ATermUtils.negate(d);
      DependencySet clashDepends = PelletOptions.SATURATE_TABLEAU ? null : node.getDepends(notD);
      if(clashDepends == null) {
          strategy.addType(node, d, ds);
        // we may still find a clash if concept is allValuesFrom
        // and there are some conflicting edges
        if(abox.isClosed())
          clashDepends = abox.getClash().getDepends();
      }
      else {
          clashDepends = clashDepends.union(ds, abox.doExplanation());
      }
     
      // if there is a clash
      if(clashDepends != null) {       
        if( log.isLoggable( Level.FINE ) ) {
          Clash clash = abox.isClosed() ? abox.getClash() : Clash.atomic(node, clashDepends, d);
                    log.fine("CLASH: Branch " + getBranch() + " " + clash + "!" + " " + clashDepends.getExplain());
        }
       
        if( PelletOptions.USE_DISJUNCT_SORTING ) {
            if(stats == null) {
                stats = new int[disj.length];
                for(int i = 0; i < disj.length; i++)
                    stats[i] = 0;
                abox.getDisjBranchStats().put(disjunction, stats);
            }
          stats[order[getTryNext()]]++;
        }
       
        // do not restore if we do not have any more branches to try. after
        // backtrack the correct branch will restore it anyway. more
        // importantly restore clears the clash info causing exceptions
        if(getTryNext() < getTryCount() - 1 && clashDepends.contains(getBranch())) {
            // do not restore if we find the problem without adding the concepts
            if(abox.isClosed()) {
              if( node.isLiteral() ) {
                abox.setClash( null );
               
                node.restore( branch );                             
              }
              else {
              // restoring a single node is not enough here because one of the disjuncts could be an
                // all(r,C) that changed the r-neighbors
                  strategy.restoreLocal((Individual) node, this);
View Full Code Here


    if( negated ) {
      ATermAppl cls = all( p, not( value( o ) ) );
      strategy.addType( node1, cls, ds );
    }
    else {
      Node node2 = abox.getNode( o ).getSame();
      strategy.addEdge( node1, abox.getRole( p ), node2, ds );
    }
  }
View Full Code Here

          ind1.setDifferent( ind2, DependencySet.INDEPENDENT );
        } else {
          // add code for inferring roles, too
          Role r = abox.getRole( pred );
          Individual from = abox.getIndividual( subj );
          Node to;
          if ( r != null && r.isObjectRole()) {
            to = abox.getIndividual( obj );
          } else if ( r != null && r.isDatatypeRole()) {
            to = abox.getLiteral( obj );
            if ( to == null ) {
View Full Code Here

        // add a type assertion for the individual
        ATermAppl type = objTerm;
        addType( subj, type, ds );
      }
      else {
        Node obj = abox.getNode( objTerm );
        if( obj != null && obj.isMerged() ) {
//          ds = ds.union( ds, abox.doExplanation() );
          obj = obj.getSame();
        }

        if( pred.equals( Compiler.SAME_AS ) ) {
          Individual ind2 = (Individual) obj;
          mergeTo( ind2, subj, ds );
View Full Code Here

    mergingAll = true;
    while (!merging && !mergeList.isEmpty() && !abox.isClosed()) {
      NodeMerge merge = mergeList.remove(0);

      Node y = abox.getNode(merge.getSource());
      Node z = abox.getNode(merge.getTarget());
      DependencySet ds = merge.getDepends();

      if (y.isMerged()) {
        ds = ds.union(y.getMergeDependency(true), abox.doExplanation());
        y = y.getSame();
      }

      if (z.isMerged()) {
        ds = ds.union(z.getMergeDependency(true), abox.doExplanation());
        z = z.getSame();
      }

      if (y.isPruned() || z.isPruned()) {
        continue;
      }

      mergeTo(y, z, ds);
    }
View Full Code Here

    // for all edges (y, r, z) where z is a nominal add an edge (x, r, z)
    EdgeList outEdges = y.getOutEdges();
    for (int e = 0; e < outEdges.size(); e++) {
      Edge edge = outEdges.edgeAt(e);
      Node z = edge.getTo();

      if (z.isNominal() && !y.equals(z)) {
        Role r = edge.getRole();
        DependencySet finalDS = ds.union(edge.getDepends(), abox.doExplanation());

        addEdge(x, r, z, finalDS);

        // add to effected list
        if (abox.getBranch() >= 0 && PelletOptions.TRACK_BRANCH_EFFECTS) {
          abox.getBranchEffectTracker().add(abox.getBranch(), z.getName());
        }

        // do not remove edge here because prune will take care of that
      }
    }
View Full Code Here

    boolean restored = ind.restore(branch);
    visited.put(ind, restored);

    if (restored) {
      for (Edge edge : ind.getOutEdges()) {
        Node succ = edge.getTo();
        if (visited.containsKey(succ)) {
          continue;
        }

        if (succ.isLiteral()) {
          visited.put(succ, Boolean.FALSE);
          succ.restore(branch);
        }
        else {
          restoreLocal(((Individual) succ), branch, visited);
        }
      }
View Full Code Here

    int deleteBlock = 0;
    for (int i = 0; i < nodeCount; i++) {
      // get the node name
      ATermAppl a = nodeList.get(i);
      // and the corresponding node
      Node node = abox.getNode(a);

      // node dependency tells us if the node was created after the branch
      // and if that is the case we remove it completely
      // NOTE: for literals, node.getNodeDepends() may be null when a literal value branch is
      // restored, in that case we can remove the literal since there is no other reference
      // left for that literal
      if (node.getNodeDepends() == null || node.getNodeDepends().getBranch() > br.getBranch()) {
        // remove the node from the node map
        abox.removeNode(a);
        // if the node is merged to another one we should remove it from
        // the other node's merged list
        if (node.isMerged()) {
          node.undoSetSame();
        }
        // increment the size of block that will be deleted
        deleteBlock++;
      }
      else {
        // this node will be restored to previous state not removed

        // first if there are any nodes collected earlier delete them
        if (deleteBlock > 0) {
          // create the sub list for nodes to be removed
          List<ATermAppl> subList = nodeList.subList(i - deleteBlock, i);
          if (log.isLoggable(Level.FINE)) {
            log.fine("Remove nodes " + subList);
          }
          // clear the sublist causing all elements to removed from nodeList
          subList.clear();
          // update counters
          nodeCount -= deleteBlock;
          i -= deleteBlock;
          deleteBlock = 0;
        }

        // restore only if not tracking branch effects
        if (!PelletOptions.TRACK_BRANCH_EFFECTS) {
          node.restore(br.getBranch());
        }
      }
    }

    // if there were nodes to be removed at the end of the list do it now
    if (deleteBlock > 0) {
      nodeList.subList(nodeCount - deleteBlock, nodeCount).clear();
    }

    if (PelletOptions.TRACK_BRANCH_EFFECTS) {
      // when tracking branch effects only restore nodes explicitly stored in the effected list
      Set<ATermAppl> effected = abox.getBranchEffectTracker().removeAll(br.getBranch() + 1);
      for (ATermAppl a : effected) {
        Node n = abox.getNode(a);
        if (n != null) {
          n.restore(br.getBranch());
        }
      }
    }

    restoreAllValues();
View Full Code Here

    for(; getTryNext() < getTryCount(); tryNext++) {   
      this.abox.getKB().timers.mainTimer.check();
      if(PelletOptions.USE_SEMANTIC_BRANCHING) {
        for(int m = 0; m < getTryNext(); m++) {
          NodeMerge nm = mergePairs.get(m);     
          Node y = abox.getNode(nm.getSource()).getSame();
          Node z = abox.getNode(nm.getTarget()).getSame();
          y.setDifferent( z, prevDS[m]);
          //strategy.addType( y, ATermUtils.makeNot( ATermUtils.makeValue( z.getName() ) ), prevDS[m] );
        }
      }
     
      NodeMerge nm = mergePairs.get(getTryNext());     
      Node y = abox.getNode(nm.getSource()).getSame();
      Node z = abox.getNode(nm.getTarget()).getSame();
           
      if( log.isLoggable( Level.FINE ) )
                log.fine(
            "MAX : (" + (getTryNext()+1) + "/" + mergePairs.size() +
            ") at branch (" + getBranch() + ") to  " + ind +
            " for prop " + r + " qualification " + qualification +
            " merge " + y + " -> " + z + " " + ds);           
     
      ds = ds.union(new DependencySet(getBranch()), abox.doExplanation());
     
      // max cardinality merge also depends on all the edges
      // between the individual that has the cardinality and
      // nodes that are going to be merged
      EdgeList rNeighbors = ind.getRNeighborEdges(r);
      boolean yEdge = false, zEdge = false;
      for( Edge edge : rNeighbors ) {
        Node neighbor = edge.getNeighbor( ind );
       
        if( neighbor.equals( y ) ) {
          ds = ds.union( edge.getDepends(), abox.doExplanation() );
          yEdge = true;
        }
        else if( neighbor.equals( z ) ) {
          ds = ds.union( edge.getDepends(), abox.doExplanation() );
          zEdge = true;
        }
      }
     
View Full Code Here

    findNext();
  }   
   
  protected void findNext() {
    for(; index < stop; index++) {
        Node node = abox.getNode( nodeList.get( index ) ) ;
      if( !node.isPruned() && node.isIndividual() )
        break;
    }
  }
View Full Code Here

TOP

Related Classes of org.mindswap.pellet.Node

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.