Package org.mindswap.pellet.utils

Examples of org.mindswap.pellet.utils.Timer


  public void copyOnWrite() {
    if( sourceABox == null ) {
          return;
        }

    Timer t = kb.timers.startTimer( "copyOnWrite" );

    List<ATermAppl> currentNodeList = new ArrayList<ATermAppl>( nodeList );
    int currentSize = currentNodeList.size();
    int nodeCount = sourceABox.nodes.size();

    nodeList = new ArrayList<ATermAppl>( nodeCount + 1 );
    nodeList.add( currentNodeList.get( 0 ) );

    for( int i = 0; i < nodeCount; i++ ) {
      ATermAppl x = sourceABox.nodeList.get( i );
      Node node = sourceABox.getNode( x );
      Node copyNode = node.copyTo( this );
      nodes.put( x, copyNode );
      nodeList.add( x );
    }

    if( currentSize > 1 ) {
          nodeList.addAll( currentNodeList.subList( 1, currentSize ) );
        }

    for( Iterator<Node> i = nodes.values().iterator(); i.hasNext(); ) {
      Node node = i.next();

      if( sourceABox.nodes.containsKey( node.getName() ) ) {
              node.updateNodeReferences();
            }
    }
   
   

    for( int i = 0, n = branches.size(); i < n; i++ ) {
      Branch branch = branches.get( i );
      Branch copy = branch.copyTo( this );
      branches.set( i, copy );

      if( i >= sourceABox.getBranches().size() ) {
              copy.setNodeCount( copy.getNodeCount() + nodeCount );
            }
            else {
              copy.setNodeCount( copy.getNodeCount() + 1 );
            }
    }

    t.stop();

    sourceABox = null;
  }
View Full Code Here


      return false;
    }
  }

  private QueryResult runSingleTest(final Query query) {
    final Timer t = new Timer( "Single query execution" );

    t.start();
    final QueryResult bindings = QueryEngine.exec( query );
    log.info( "Execution time=" + t.getElapsed() );
    t.stop();
    log.info( "Result size = " + bindings.size() );

    return bindings;
  }
View Full Code Here

      log.fine( count + ") Checking subclass [" + ATermUtils.toString( c1 ) + " " + ATermUtils.toString( c2 ) + "]" );
    }

    ATermAppl notC2 = ATermUtils.negate( c2 );
    ATermAppl c = ATermUtils.makeAnd( c1, notC2 );
    Timer t = kb.timers.startTimer( "subClassSat" );
    boolean sub = !isSatisfiable( c, false );
    t.stop();

    if( log.isLoggable( Level.FINE ) ) {
          log.fine( " Result: " + sub + " (" + t.getLast() + "ms)" );
        }

    return sub;
  }
View Full Code Here

      }
    }

    stats.satisfiabilityCount++;

    Timer t = kb.timers.startTimer( "satisfiability" );
    boolean isSat = isConsistent( SetUtils.<ATermAppl>emptySet(), c, cacheModel );
    t.stop();

    return isSat;
  }
View Full Code Here

          log.fine( "Checking type " + ATermUtils.toString( c ) + " for individual " + ATermUtils.toString( x ) );
        }

    ATermAppl notC = ATermUtils.negate( c );

    Timer t = kb.timers.startTimer( "isType" );
    boolean isType = !isConsistent( SetUtils.singleton( x ), notC, false );
    t.stop();

    if( log.isLoggable( Level.FINE ) ) {
          log.fine( "Type " + isType + " " + ATermUtils.toString( c ) + " for individual " + ATermUtils.toString( x ) );
        }
View Full Code Here

   * @param individuals
   * @param c
   * @return
   */
  private boolean isConsistent(Collection<ATermAppl> individuals, ATermAppl c, boolean cacheModel) {
    Timer t = kb.timers.startTimer( "isConsistent" );

    if( log.isLoggable( Level.FINE ) ) {
      if( c == null ) {
              log.fine( "ABox consistency for " + individuals.size() + " individuals" );
            }
            else {
        StringBuilder sb = new StringBuilder();
        sb.append("[");       
        Iterator<ATermAppl> it = individuals.iterator();
        for( int i = 0; i < 100 && it.hasNext(); i++ ) {
          if( i > 0 ) {
                      sb.append( ", " );
                    }
          sb.append( ATermUtils.toString( it.next() ) );
        }
        if( it.hasNext() ) {
                  sb.append( ", ..." );
                }
        sb.append("]");
        log.fine( "Consistency " + ATermUtils.toString( c ) + " for " + individuals.size() + " individuals "
            + sb );
      }
    }

    Expressivity expr = kb.getExpressivityChecker().getExpressivityWith( c );

    // if c is null we are checking the consistency of this ABox as
    // it is and we will not add anything extra
    boolean initialConsistencyCheck = (c == null);

    boolean emptyConsistencyCheck = initialConsistencyCheck && isEmpty();

    // if individuals is empty and we are not building the pseudo
    // model then this is concept satisfiability
    boolean conceptSatisfiability = individuals.isEmpty()
        && (!initialConsistencyCheck || emptyConsistencyCheck);

    // Check if there are any nominals in the KB or nominal
    // reasoning is disabled
    boolean hasNominal = expr.hasNominal() && !PelletOptions.USE_PSEUDO_NOMINALS;

    // Use empty model only if this is concept satisfiability for a KB
    // where there are no nominals
    boolean canUseEmptyABox = conceptSatisfiability && !hasNominal;

    ATermAppl x = null;
    if( conceptSatisfiability ) {
      x = ATermUtils.CONCEPT_SAT_IND;
      individuals = SetUtils.singleton( x );
    }

    if( emptyConsistencyCheck ) {
          c = ATermUtils.TOP;
        }

    ABox abox = canUseEmptyABox
      ? this.copy( x, false )
      : initialConsistencyCheck
        ? this
        : this.copy( x, true );

    for( ATermAppl ind : individuals ) {
      abox.setSyntacticUpdate( true );
      abox.addType( ind, c );
      abox.setSyntacticUpdate( false );
    }

    if( log.isLoggable( Level.FINE ) ) {
          log.fine( "Consistency check starts" );
        }

    CompletionStrategy strategy = kb.chooseStrategy( abox, expr );

    if( log.isLoggable( Level.FINE ) ) {
          log.fine( "Strategy: " + strategy.getClass().getName() );
        }

    Timer completionTimer = kb.timers.getTimer( "complete" );
    completionTimer.start();
    try {
      strategy.complete( expr );
    }
    finally {
      completionTimer.stop();
    }

    boolean consistent = !abox.isClosed();

    if( x != null && c != null && cacheModel ) {
View Full Code Here

   * checking approach
   */
  boolean isIncConsistent() {
    assert isComplete() : "Initial consistency check has not been performed!";

    Timer incT = kb.timers.startTimer( "isIncConsistent" );
    Timer t = kb.timers.startTimer( "isConsistent" );

    // throw away old information to let gc do its work
    lastCompletion = null;
   
    if( log.isLoggable( Level.FINE ) ) {
          log.fine( "Consistency check starts" );
        }
   
    // currently there is only one incremental consistency strategy
    CompletionStrategy incStrategy = new SROIQIncStrategy( this );

    if( log.isLoggable( Level.FINE ) ) {
          log.fine( "Strategy: " + incStrategy.getClass().getName() );
        }

    // set abox to not being complete
    setComplete( false );
    Timer completionTimer = kb.timers.getTimer( "complete" );
    completionTimer.start();
    try {
      incStrategy.complete(kb.getExpressivityChecker().getExpressivity());
    }
    finally {
      completionTimer.stop();
    }
   
    boolean consistent = !isClosed();

    if( log.isLoggable( Level.FINE ) ) {
View Full Code Here

    classify();

    if( !isClassified() )
      return;

    Timer timer = timers.startTimer( "realize" );

    // This is false if the progress monitor is canceled
    boolean isRealized = builder.realize();

    timer.stop();

    if( !isRealized )
      return;

    state.add( ReasoningState.REALIZE );
View Full Code Here

  public Set<ATermAppl> retrieve(ATermAppl d, Collection<ATermAppl> individuals) {
    ensureConsistency();

    ATermAppl c = ATermUtils.normalize( d );

    Timer timer = timers.startTimer( "retrieve" );

    ATermAppl notC = ATermUtils.negate( c );
    List<ATermAppl> knowns = new ArrayList<ATermAppl>();

    // this is mostly to ensure that a model for notC is cached
    if( !abox.isSatisfiable( notC ) ) {
      // if negation is unsat c itself is TOP
      knowns.addAll( getIndividuals() );
    }
    else if( abox.isSatisfiable( c ) ) {
      Set<ATermAppl> subs = Collections.emptySet();
      if( isClassified() ) {
        if( builder == null )
          throw new NullPointerException( "Builder is null" );

        Taxonomy<ATermAppl> taxonomy = builder.getTaxonomy();

        if( taxonomy == null )
          throw new NullPointerException( "Taxonomy" );

        if( taxonomy.contains( c ) )
          subs = taxonomy.getFlattenedSubs( c, false );
      }

      List<ATermAppl> unknowns = new ArrayList<ATermAppl>();
      for( ATermAppl x : individuals ) {
        Bool isType = abox.isKnownType( x, c, subs );
        if( isType.isTrue() )
          knowns.add( x );
        else if( isType.isUnknown() )
          unknowns.add( x );
      }

      if( !unknowns.isEmpty() ) {
        if( PelletOptions.INSTANCE_RETRIEVAL == InstanceRetrievalMethod.TRACING_BASED
            && PelletOptions.USE_TRACING ) {
          tracingBasedInstanceRetrieval( c, unknowns, knowns );
        }
        else if( abox.isType( unknowns, c ) ) {
          if( PelletOptions.INSTANCE_RETRIEVAL == InstanceRetrievalMethod.BINARY )
            binaryInstanceRetrieval( c, unknowns, knowns );
          else
            linearInstanceRetrieval( c, unknowns, knowns );
        }
      }

    }

    timer.stop();

    Set<ATermAppl> result = Collections.unmodifiableSet( new HashSet<ATermAppl>( knowns ) );

    if( PelletOptions.CACHE_RETRIEVAL )
      instances.put( c, result );
View Full Code Here

      return;

    boolean explain = abox.doExplanation();
    abox.setDoExplanation( true );

    Timer timer = timers.startTimer( "preprocessing" );
    Timer t;

    // consistency need to be repeated after modifications
    state.remove( ReasoningState.CONSISTENCY );
    // realization need to be repeated after modifications
    state.remove( ReasoningState.REALIZE );
   
    // classification may notbve repeated if ...
    boolean reuseTaxonomy =
        // classification has been previously done
        state.contains( ReasoningState.CLASSIFY )
        // TBox did not change since classification
        && !isTBoxChanged()
        // RBox did not change since classification
        && !isRBoxChanged()
        // there are no nominals
        && (!expChecker.getExpressivity().hasNominal() || PelletOptions.USE_PSEUDO_NOMINALS);

    if( isRBoxChanged() ) {
      if( log.isLoggable( Level.FINER ) )
        log.finer( "Role hierarchy..." );
      t = timers.startTimer( "rbox" );
      rbox.prepare();
      t.stop();
    }

    if( isTBoxChanged() ) {
      if( log.isLoggable( Level.FINER ) )
        log.finer( "Prepare TBox..." );
      t = timers.startTimer( "normalize" );
      tbox.prepare();
      t.stop();
    }

    if( isRBoxChanged() ) {
      rbox.propagateDomainRange();
    }
View Full Code Here

TOP

Related Classes of org.mindswap.pellet.utils.Timer

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.