Package org.mindswap.pellet

Examples of org.mindswap.pellet.Individual


   
    for( Iterator<Node> i = tracker.unprunedNodes(); i.hasNext(); ) {
      Node node = i.next();
     
      if( node instanceof Individual ){
        Individual ind = (Individual)node;
        //reset type pointers
        for( int j = 0; j < Node.TYPES; j++ )
          ind.applyNext[j] = 0;
       
        //add to all queues
        abox.getCompletionQueue().add( new QueueElement( ind ) );
       
        allValuesRule.apply( ind );
       
        //get out edges
        for( int j = 0; j < ind.getOutEdges().size(); j++ ){
          Edge e = ind.getOutEdges().edgeAt( j );
         
          Node obj = e.getTo();
          if( obj instanceof Individual ){
            Individual objInd = (Individual)obj;
            objInd.applyNext[Node.ALL] = 0;
            allValuesRule.apply( objInd );
          }
        }
      }
           
      //get out edges
      for( int j = 0; j < node.getInEdges().size(); j++ ){
        Edge e = node.getInEdges().edgeAt( j );
        Individual subj= e.getFrom();
        subj.applyNext[Node.ALL] = 0;
        allValuesRule.apply( subj );
      }
    }   
  }
View Full Code Here


      edges.addEdgeList( findAllValues( node, e.getFrom(), removedTypes, e ) );
    }
   
   
    if( node instanceof Individual ){
      Individual ind = (Individual)node;     
     
      //handle in edges
      for(int i = 0; i < ind.getOutEdges().size(); i++){
        Edge e = ind.getOutEdges().edgeAt( i );
        Node to = e.getTo();
       
        Role inv = e.getRole().getInverse();
       
        if(inv != null && to instanceof Individual)
View Full Code Here

    assert abox.size() == 1 : "This strategy can only be used with originally empty ABoxes";
   
    blocking = BlockingFactory.createBlocking( expressivity );
   
    Individual root = abox.getIndIterator().next();
    applyUniversalRestrictions( root );
    selfRule.apply( root );
   
    mayNeedExpanding = new LinkedList<Individual>();
    mayNeedExpanding.add( root );
View Full Code Here

      : CacheSafetyFactory.createCacheSafety( expr );
   
    initialize( expr );

    while( !abox.isComplete() && !abox.isClosed() ) {
      Individual x = getNextIndividual();

      if( x == null ) {
        abox.setComplete( true );
        break;
      }

      if( log.isLoggable( Level.FINE ) ) {
        log.fine( "Starting with node " + x );
        abox.printTree();

        abox.validate();
      }

      expand( x );

      if( abox.isClosed() ) {
        if( log.isLoggable( Level.FINE ) )
          log.fine( "Clash at Branch (" + abox.getBranch() + ") " + abox.getClash() );

        if( backtrack() )
          abox.setClash( null );
        else
          abox.setComplete( true );
      }
      else if( expr.hasInverse() && parentNeedsExpanding( x ) ) {
        mayNeedExpanding.removeAll( getDescendants(x.getParent()) );
        mayNeedExpanding.addFirst( x.getParent() );
        continue;
      }
    }

    if( log.isLoggable( Level.FINE ) )
      abox.printTree();

    if( PelletOptions.USE_ADVANCED_CACHING ) {
      // if completion tree is clash free cache all sat concepts
      if( !abox.isClosed() ) {
        for( Iterator<Individual> i = new IndividualIterator( abox ); i.hasNext(); ) {
          Individual ind = i.next();
          ATermAppl c = cachedNodes.get( ind );
          if( c == null )
            continue;

          addCacheSat( c );
View Full Code Here

 

    private boolean parentNeedsExpanding(Individual x) {
        if(x.isRoot()) return false;

        Individual parent = x.getParent();

        return parent.canApply(Node.ATOM) || parent.canApply(Node.OR)
            || parent.canApply(Node.SOME) || parent.canApply(Node.MIN)
            || parent.canApply(Node.MAX);
    }
View Full Code Here

      }
    }
    nodeList.subList( br.getNodeCount(), nodeList.size() ).clear();

    for( Iterator<Individual> i = abox.getIndIterator(); i.hasNext(); ) {
      Individual ind = i.next();
      allValuesRule.apply( ind );
    }

    if( log.isLoggable( Level.FINE ) )
      abox.printTree();
View Full Code Here

    allValuesRule.applyAllValues(subj, pred, obj, ds);
    if (subj.isPruned() || obj.isPruned()) {
      return;
    }
    if (pred.isObjectRole()) {
      Individual o = (Individual) obj;
      allValuesRule.applyAllValues(o, pred.getInverse(), subj, ds);
      checkReflexivitySymmetry(subj, pred, o, ds);
      checkReflexivitySymmetry(o, pred.getInverse(), subj, ds);
      applyDisjointness(o, pred.getInverse(), subj, ds);
    }
View Full Code Here

    if (pred.isDatatypeRole() && pred.isInverseFunctional()) {
      applyFunctionalMaxRule((Literal) obj, pred, DependencySet.INDEPENDENT);
    }
    else if (pred.isObjectRole()) {
      Individual val = (Individual) obj;
      Role invR = pred.getInverse();

      maxCardDS = invR.isFunctional() ? invR.getExplainFunctional() : val.hasMax1(invR);

      if (maxCardDS != null) {
        maxRule.applyFunctionalMaxRule(val, invR, ATermUtils.TOP, maxCardDS);
      }
    }
View Full Code Here

    // 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;
      }

      // it is possible that there are multiple edges to the same
      // node, e.g. property p and its super property, so check if
      // we already merged this one
      if (head.isSame(next)) {
        continue;
      }

      ds = ds.union(edge.getDepends(), abox.doExplanation());

      if (next.isDifferent(head)) {
        ds = ds.union(next.getDifferenceDependency(head), abox.doExplanation());
        if (r.isFunctional()) {
          abox.setClash(Clash.functionalCardinality(x, ds, r.getName()));
        }
        else {
          abox.setClash(Clash.maxCardinality(x, ds, r.getName(), 1));
View Full Code Here

    // 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());

        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

TOP

Related Classes of org.mindswap.pellet.Individual

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.