Examples of EdgeList


Examples of org.mindswap.pellet.EdgeList

   * @param removedTypes
   * @param edge
   * @return
   */
  protected EdgeList findAllValues( Node node, Individual neighbor, Set<ATermAppl> removedTypes, Edge edge){
    EdgeList edges = new EdgeList();
   
    boolean applicable = false;   
    List<ATermAppl> avTypes = neighbor.getTypes( Node.ALL );
    List<ATermAppl> applicableRoles = new ArrayList<ATermAppl>();
   
    //inspect all values for a recently deleted type
    for( int i = 0; i < avTypes.size(); i++ ){
      ATermAppl avType = avTypes.get( i );
      ATermAppl role = (ATermAppl) avType.getArgument( 0 );
      ATermAppl type = (ATermAppl) avType.getArgument( 1 );
     
      //if we cannot use this edge then continue
      if( edge != null && !edge.getRole().isSubRoleOf( abox.getRole( role ) ) )
        continue;
     
      if( containsType( type, removedTypes ) ){
        applicable = true;       
        applicableRoles.add( type );
      }
    }
   
    //only proceed if necessary
    if( !applicable )
      return edges;
   
    //two cases depending on input
    if(edge == null){
      //get all edges to this node
      for( int i = 0; i < applicableRoles.size(); i++ ){
        ATerm p = applicableRoles.get( i );
        Role role = abox.getRole( p );

        edges.addEdgeList( neighbor.getRNeighborEdges( role, node ) );
      }     
    }else{
      edges.addEdge( edge );
    }
   
    return edges;
  }
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

    } while( x.canApply( Node.ATOM ) || x.canApply( Node.OR ) || x.canApply( Node.SOME )
        || x.canApply( Node.MIN ) );

    mayNeedExpanding.remove( 0 );

    EdgeList sortedSuccessors = x.getOutEdges().sort();
    if( PelletOptions.SEARCH_TYPE == PelletOptions.DEPTH_FIRST ) {
      for( Edge edge : sortedSuccessors ) {
        Node succ = edge.getTo();
        if( !succ.isLiteral() && !succ.equals( x ) ) {
          mayNeedExpanding.add( (Individual) succ );
        }
      }
    }
    else {
      for( int i = sortedSuccessors.size() - 1; i >= 0; i-- ) {
        Edge edge = sortedSuccessors.edgeAt( i );
        Node succ = edge.getTo();
        if( !succ.isLiteral() && !succ.equals( x ) ) {
          mayNeedExpanding.add( (Individual) succ );
        }
      }
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

   *
   * @param edgeList
   * @return
   */
  private EdgeList copyEdgeList( Individual node, boolean out) {
    EdgeList edgeList = out
      ? node.getOutEdges()
      : node.getInEdges();
    EdgeList cachedEdges = new EdgeList( edgeList.size() );
    for( Edge edge : edgeList ) {
      Edge cachedEdge = out
        ? 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

Examples of org.mindswap.pellet.EdgeList

          continue;
        }
        selfRule.apply(n);

        // CHW-added for inc. queue must see if this is bad
        EdgeList allEdges = n.getOutEdges();
        for (int e = 0; e < allEdges.size(); e++) {
          Edge edge = allEdges.edgeAt(e);
          if (edge.getTo().isPruned()) {
            continue;
          }

          applyPropertyRestrictions(edge);
          if (n.isMerged()) {
            break;
          }
        }

      }

      return;
    }

    if (log.isLoggable(Level.FINE)) {
      log.fine("Initialize started");
    }

    abox.setBranch(0);

    mergeList.addAll(abox.getToBeMerged());

    if (!mergeList.isEmpty()) {
      mergeAll();
    }

    Role topRole = abox.getRole(TOP_OBJECT_PROPERTY);
    Iterator<Individual> i = getInitializeIterator();
    while (i.hasNext()) {
      Individual n = i.next();

      if (n.isMerged()) {
        continue;
      }

      applyUniversalRestrictions(n);
      if (n.isMerged()) {
        continue;
      }

      selfRule.apply(n);
      if (n.isMerged()) {
        continue;
      }

      EdgeList allEdges = n.getOutEdges();
      for (int e = 0; e < allEdges.size(); e++) {
        Edge edge = allEdges.edgeAt(e);

        if (edge.getTo().isPruned()) {
          continue;
        }
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

    // TODO improve this check
    Set<Role> disjoints = pred.getDisjointRoles();
    if (disjoints.isEmpty()) {
      return;
    }
    EdgeList edges = subj.getEdgesTo(obj);
    for (int i = 0, n = edges.size(); i < n; i++) {
      Edge otherEdge = edges.edgeAt(i);

      if (disjoints.contains(otherEdge.getRole())) {
        ds = ds.union(otherEdge.getDepends(), abox.doExplanation());
        ds = ds.union(pred.getExplainDisjointRole(otherEdge.getRole()), abox.doExplanation());
        abox.setClash(Clash.disjointProps(subj, ds, pred.getName(), otherEdge.getRole().getName()));
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

  }

  void checkReflexivitySymmetry(Individual subj, Role pred, Individual obj, DependencySet ds) {
    if (pred.isAsymmetric() && obj.hasRSuccessor(pred, subj)) {
      EdgeList edges = obj.getEdgesTo(subj, pred);
      ds = ds.union(edges.edgeAt(0).getDepends(), abox.doExplanation());
      if (PelletOptions.USE_TRACING) {
        ds = ds.union(pred.getExplainAsymmetric(), abox.doExplanation());
      }
      abox.setClash(Clash.unexplained(subj, ds, "Antisymmetric property " + pred));
    }
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

      }
    }
  }

  protected void applyFunctionalMaxRule(Literal x, Role r, DependencySet ds) {
    EdgeList edges = x.getInEdges().getEdges(r);

    // if there is not more than one edge then func max rule won't be triggered
    if (edges.size() <= 1) {
      return;// continue;
    }

    // find all distinct R-neighbors of x
    Set<Node> neighbors = edges.getNeighbors(x);

    // if there is not more than one neighbor then func max rule won't be triggered
    if (neighbors.size() <= 1) {
      return;// continue;
    }

    Individual head = null;
    DependencySet headDS = null;
    // find a nominal node to use as the head
    for (int edgeIndex = 0; edgeIndex < edges.size(); edgeIndex++) {
      Edge edge = edges.edgeAt(edgeIndex);
      Individual ind = edge.getFrom();

      if (ind.isNominal() && (head == null || ind.getNominalLevel() < head.getNominalLevel())) {
        head = ind;
        headDS = edge.getDepends();
      }
    }

    // if there is no nominal in the merge list we need to create one
    if (head == null) {
      head = abox.addFreshIndividual(null, ds);
    }
    else {
      ds = ds.union(headDS, abox.doExplanation());
    }

    for (int i = 0; i < edges.size(); i++) {
      Edge edge = edges.edgeAt(i);
      Individual next = edge.getFrom();

      if (next.isPruned()) {
        continue;
      }
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

      DependencySet finalDS = ds.union(entry.getValue(), abox.doExplanation());
      addType(x, yType, finalDS);
    }

    // for all edges (z, r, y) add an edge (z, r, x)
    EdgeList inEdges = y.getInEdges();
    for (int e = 0; e < inEdges.size(); e++) {
      Edge edge = inEdges.edgeAt(e);

      Individual z = edge.getFrom();
      Role r = edge.getRole();
      DependencySet finalDS = ds.union(edge.getDepends(), abox.doExplanation());

      // if y has a self edge then x should have the same self edge
      if (y.equals(z)) {
        addEdge(x, r, x, finalDS);
      }
      // if z is already a successor of x add the reverse edge
      else if (x.hasSuccessor(z)) {
        // FIXME what if there were no inverses in this expressitivity
        addEdge(x, r.getInverse(), z, finalDS);
      }
      else {
        addEdge(z, r, x, finalDS);
      }

      // only remove the edge from z and keep a copy in y for a
      // possible restore operation in the future
      z.removeEdge(edge);

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

    }

    // for all z such that y != z set x != z
    x.inheritDifferents(y, ds);

    // we want to prune y early due to an implementation issue about literals
    // if y has an outgoing edge to a literal with concrete value
    y.prune(ds);

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

Examples of org.mindswap.pellet.EdgeList

    y.setSame(x, ds);

    x.addAllTypes(y.getDepends(), ds);

    // for all edges (z, r, y) add an edge (z, r, x)
    EdgeList inEdges = y.getInEdges();
    for (int e = 0; e < inEdges.size(); e++) {
      Edge edge = inEdges.edgeAt(e);

      Individual z = edge.getFrom();
      Role r = edge.getRole();
      DependencySet finalDS = ds.union(edge.getDepends(), abox.doExplanation());
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

      Set<Role> functionalSupers = role.getFunctionalSupers();
      for( Iterator<Role> j = functionalSupers.iterator(); j.hasNext(); ) {
        Role supRole = j.next();

        EdgeList otherEdges = otherRoot.getRNeighborEdges( supRole );
        for( Edge otherEdge : otherEdges ) {
          DependencySet ds = edge.getTo().getDifferenceDependency( otherEdge.getNeighbor( otherRoot ) );
          if( log.isLoggable( Level.FINE ) )
            log.fine( root + " and " + otherRoot + " has " + supRole + " " + edge + " " + otherEdge );
          if( ds != null && ds.isIndependent() )
            return Bool.FALSE;
          result = Bool.UNKNOWN;
        }
      }
    }

    for( Edge edge : root.getInEdges() ) {
      Role role = edge.getRole().getInverse();

      if( role == null || !role.isFunctional() )
        continue;

      Set<Role> functionalSupers = role.getFunctionalSupers();
      for( Iterator<Role> j = functionalSupers.iterator(); j.hasNext(); ) {
        Role supRole = j.next();

        EdgeList otherEdges = otherRoot.getRNeighborEdges( supRole );
        for( Edge otherEdge : otherEdges ) {
          DependencySet ds = edge.getTo().getDifferenceDependency( otherEdge.getNeighbor( otherRoot ) );
          if( log.isLoggable( Level.FINE ) )
            log.fine( root + " and " + otherRoot + " has " + supRole + " " + edge + " " + otherEdge );
          if( ds != null && ds.isIndependent() )
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.