Package org.mindswap.pellet.utils

Examples of org.mindswap.pellet.utils.Timer


      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

   * Extract modules from scratch
   *
   * @return
   */
  public MultiValueMap<OWLEntity, OWLEntity> extractModules() {
    Timer timer = timers.startTimer( "extractModules" );

    // cache the axiom signatures
    processAdditions();
    additions.clear();

    // no need to consider deletions for initial module extraction
    deletions.clear();
    changes.clear();
   
    nonLocalAxioms = false;

    modules = new MultiValueMap<OWLEntity, OWLEntity>();

    extractModuleSignatures( allClasses );

    timer.stop();

    return modules;
  }
View Full Code Here

   *             if modules cannot be updated as reported by
   *             {@link #canUpdate()} function
   */
  public Set<OWLEntity> updateModules(Taxonomy<OWLClass> taxonomy, boolean add)
      throws UnsupportedOperationException {
    Timer timer = timers.startTimer( "updateModules" );

    if( !canUpdate() )
      throw new UnsupportedOperationException( "Modules cannot be updated!" );

    Set<OWLEntity> effects = null;
    if( add ) {
      // cash the signatures for axioms as they are used in the next step
      processAdditions();
      // compute effects
      effects = updateEffectedModules( additions, taxonomy, add );
      // clear processed axioms
      additions.clear();
     
      // update the pending change types -- remove the changes
      // that are additions
      changes.remove(ChangeType.ABOX_ADD);
      changes.remove(ChangeType.RBOX_ADD);
      changes.remove(ChangeType.TBOX_ADD);
    }
    else {
      // compute effects
      effects = updateEffectedModules( deletions, taxonomy, add );
      // remove signatures for deleted axioms now that they are not needed
      processDeletions();
      // clear processed axioms
      deletions.clear();
     
      // update the pending change types -- remove the changes
      // that are additions
      changes.remove(ChangeType.ABOX_DEL);
      changes.remove(ChangeType.RBOX_DEL);
      changes.remove(ChangeType.TBOX_DEL);

    }

    timer.stop();

    return effects;
  }
View Full Code Here

  public QueryResult exec(Query query) {
    if( log.isLoggable( Level.FINE ) ) {
      log.fine( "Executing query " + query );
    }

    Timer timer = new Timer( "CombinedQueryEngine" );
    timer.start();
    prepare( query );
    branches = 0;
    exec( new ResultBindingImpl() );
    timer.stop();

    if( log.isLoggable( Level.FINE ) ) {
      log.log( Level.FINE, "#B=" + branches + ", time=" + timer.getLast() + " ms." );
    }

    return 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

        String msg = UsableRuleFilter.explainNotUsable( rule );       
        log.warning( "Ignoring rule " + rule + ": " + msg );
      }
    }

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

    boolean doExplanation = abox.doExplanation();
   
    if( PelletOptions.USE_TRACING && !explainOnlyInconsistency )
      abox.setDoExplanation( true );
     
    // perform the consistency check
    consistent = canUseIncConsistency
      ? abox.isIncConsistent()
      : abox.isConsistent();

    // final clean up
    if( PelletOptions.USE_INCREMENTAL_CONSISTENCY )
      abox.getIncrementalChangeTracker().clear();

    if( PelletOptions.USE_INCREMENTAL_DELETION )
      getDeletedAssertions().clear();

    if( !consistent ) {
      // the behavior of Pellet 1.5.1 (and prior versions) was to generate
      // explanations for inconsistent ontologies even if the
      // doExplanation
      // was not set. this was causing an overhead for repeated
      // consistency
      // tests that mostly turn out to be consistent. the new strategy is
      // to repeat the consistency test for inconsistent ontologies by
      // manually setting the doExplanation flag. this will generate more
      // overhead for inconsistent ontologies but inconsistent ontologies
      // are much less frequent so this trade-off is preferred

      // create explanation by default for the ABox consistency check
      // but only if we can generate it (i.e. tracing is turned on) and
      // we haven't already done so (i.e. doExplanation flag was false at
      // the beginning)
      if( PelletOptions.USE_TRACING && explainOnlyInconsistency && !abox.doExplanation() ) {
        abox.setDoExplanation( true );

        abox.reset();
        abox.isConsistent();

        abox.setDoExplanation( false );
      }

      if ( log.isLoggable( Level.FINE )) {
        log.fine( "Inconsistent ontology. Reason: " + getExplanation() );
      }

      if( PelletOptions.USE_TRACING && log.isLoggable( Level.FINE )) {
        log.fine( renderExplanationSet() );
      }
    }
   
    abox.setDoExplanation( doExplanation );
   
    state.add( ReasoningState.CONSISTENCY );
   
    timer.stop();
   
    if ( log.isLoggable( Level.FINE ) ) {
      log.fine( "Consistent: " + consistent + " (" + timer.getLast() + "ms)" );
    }

    assert isConsistencyDone() : "Consistency flag not set";
  }
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.