Package org.mindswap.pellet

Examples of org.mindswap.pellet.EdgeList$EdgeIterator


      }
    }
  }

  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


      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

    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

      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

    return result;
  }

  private Bool checkNominalEdges(KnowledgeBase kb, CachedNode pNode, CachedNode cNode,
      boolean checkInverses) {
    EdgeList edges = checkInverses
      ? cNode.getInEdges()
      : cNode.getOutEdges();
    for( Edge edge : edges ) {
      Role role = checkInverses
        ? edge.getRole().getInverse()
View Full Code Here

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

  public void addEdge(Individual subj, Role pred, Node obj, DependencySet ds) {
    super.addEdge( subj, pred, obj, ds );

    if( !merging && !abox.isClosed() && subj.isRootNominal() && obj.isRootNominal() ) {
      if( interpreter != null ) {
        EdgeList edges = subj.getRNeighborEdges( pred, obj );
        for( Edge edge : edges ) {
          if( edge.getFrom().isRootNominal() && edge.getTo().isRootNominal() )
            runRules |= interpreter.rete.addFact( edge );
        }
View Full Code Here

      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

    return result;
  }

  private Bool checkNominalEdges(KnowledgeBase kb, CachedNode pNode, CachedNode cNode,
      boolean checkInverses) {
    EdgeList edges = checkInverses
      ? cNode.getInEdges()
      : cNode.getOutEdges();
    for( Edge edge : edges ) {
      Role role = checkInverses
        ? edge.getRole().getInverse()
View Full Code Here

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

TOP

Related Classes of org.mindswap.pellet.EdgeList$EdgeIterator

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.