Package org.mindswap.pellet

Examples of org.mindswap.pellet.Node


    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

   *
   * @param type
   */
  protected void findNext(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() && allowLiterals() ) || (node.isIndividual() && !allowLiterals())) && !node.isPruned())
        break;     
    }
  }
View Full Code Here

   * @return
   */
  public Node nextLiteral() {
    //get the next index
    findNext(-1);
    Node node = abox.getNode(queue.get(current));   
    node = node.getSame();   
    current++;
    return node;
  }
View Full Code Here

   *
   * @param type
   */
  protected void findNext(int type) {
    for( ; current[type] < cutOff[type]; current[type]++ ) {
      Node node = abox.getNode( queue[type].get( current[type] ) );

      //because we do not maitain the queue during restore this node could be non-existent
      if(node == null)
        continue;
     
      node = node.getSame();
     
      if( ( ( node instanceof Literal && allowLiterals() ) || (node instanceof Individual && !allowLiterals())) && !node.isPruned())
        break;     
    }
  }
View Full Code Here

   * @return
   */
  public Node nextLiteral() {
    //get the next index
    findNext(currentType);
    Node node = abox.getNode(queue[currentType].get(current[currentType]));   
    node = node.getSame();   
    current[currentType]++;
    return node;
  }
View Full Code Here

        ? new CachedOutEdge( edge )
        : new CachedInEdge( edge );
      cachedEdges.addEdge( cachedEdge );
     
      if( PelletOptions.CHECK_NOMINAL_EDGES ) {
        Node neighbor = edge.getNeighbor( node );
        Map<Node,DependencySet> mergedNodes = neighbor.getAllMerged();
          DependencySet edgeDepends = edge.getDepends();
          for( Entry<Node,DependencySet> entry : mergedNodes.entrySet() ) {
            Node mergedNode = entry.getKey();
            if( mergedNode.isRootNominal() && !mergedNode.equals( neighbor ) ) {
              Role r = edge.getRole();
              ATermAppl n = mergedNode.getName();
              DependencySet ds = edgeDepends.union( entry.getValue(), false ).cache();
              Edge e = out
                ? new CachedOutEdge( r, n, ds )
                : new CachedInEdge( r, n, ds );
              cachedEdges.addEdge( e );
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();
          strategy.setDifferent(y, 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

      return true;
    }
   
    Individual blocker = cxt.blocker;
    for( Edge e : blocker.getOutEdges() ) {
      Node child = e.getTo();

      if( cxt.moveBlockerDown( child ) ) {
        if( isDirectlyBlockedByDescendant( cxt ) ) {     
          return true;
        }
View Full Code Here

        return "DISJ: Branch (" + getBranch() + ") try (" + (getTryNext() + 1) + "/" + getTryCount()
            + ") " + node + " " +  ATermUtils.toString( disj[getTryNext()] ) + " " + ATermUtils.toString(disjunction);
    }
 
  public DisjunctionBranch copyTo(ABox abox) {
      Node n = abox.getNode(node.getName());
      DisjunctionBranch b = new DisjunctionBranch(abox, null, n, disjunction, getTermDepends(), disj);
      b.setAnonCount( anonCount );
      b.setNodeCount( nodeCount );
      b.setBranch( branch );
      b.setStrategy( strategy );
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.