Package org.mindswap.pellet.utils

Examples of org.mindswap.pellet.utils.Timer


        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


      return;

    if( log.isLoggable( Level.FINE ) )
      log.fine( "Classifying..." );

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

    builder = getTaxonomyBuilder();

    boolean isClassified = builder.classify();

    timer.stop();

    if( !isClassified )
      return;

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

    boolean timeout = false;

    Reasoner pellet = new Reasoner( OWL.manager );
    KnowledgeBase kb = pellet.getKB();

    Timer timer = kb.timers.createTimer( "classify" );
    timer.setTimeout( 1 );

    OWLOntology ont = loadOntology( base + "food.owl" );
    pellet.loadOntology( ont );

    try {
View Full Code Here

  public void testRealizationTimeout() throws Exception {
    boolean timeout = false;
    Reasoner pellet = new Reasoner( OWL.manager );
    KnowledgeBase kb = pellet.getKB();

    Timer timer = kb.timers.createTimer( "realize" );
    timer.setTimeout( 1 );

    OWLOntology ont = loadOntology( base + "food.owl" );
    pellet.loadOntology( ont );

    try {
View Full Code Here

    // load ontologies again
    load( notImportedOnts );
  }

  public void load(Set<OWLOntology> ontologies) {
    Timer timer = kb.timers.startTimer( "load" );

    int axiomCount = 0;
    Collection<OWLOntology> toBeLoaded = new LinkedHashSet<OWLOntology>();
    for( OWLOntology ontology : ontologies )
      axiomCount += load( ontology, false, toBeLoaded );

    ProgressMonitor monitor = new SilentProgressMonitor();
    monitor.setProgressTitle( "Loading" );
    monitor.setProgressLength( axiomCount );
    monitor.taskStarted();

    visitor.reset();
    visitor.setAddAxiom( true );
    visitor.setMonitor( monitor );

    for( OWLOntology ontology : toBeLoaded )
      ontology.accept( visitor );
   
    visitor.verify();

    monitor.taskFinished();

    timer.stop();
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public void load(Iterable<Graph> graphs) throws UnsupportedFeatureException {
    Timer timer = kb.timers.startTimer( "load" );

    monitor.setProgressTitle( "Loading" );
    monitor.taskStarted();
   
    graph = EMPTY_GRAPH;
    preprocess();

    for (Graph g : graphs) {
      graph = g;
      processTypes();   
        }

    for (Graph g : graphs) {
      graph = g;
      processTriples()
        }
   
    processUntypedResources();

    monitor.taskFinished();

    timer.stop();
  }
View Full Code Here

    verbose( "Start " + task );   
    timers.startTimer( task );   
 
 
  protected void finishTask(String task) {
    Timer timer = timers.getTimer( task );
    timer.stop();
    verbose( "Finished " + task + " in " + timer.format() );
  }
View Full Code Here

      }
    }
  }

  public void applyRete() {
    Timer t;
    if( PelletOptions.ALWAYS_REBUILD_RETE ) {
      t = timers.startTimer( "rule-rebuildRete" );
      interpreter.reset();
      interpreter.rete.compileFacts( abox );
      partialBindings.clear();
      t.stop();
    }

    if( !interpreter.isDirty() )
      return;

    t = timers.startTimer( "rule-reteRun" );
    Set<Fact> inferred = interpreter.run();
    t.stop();

    t = timers.startTimer( "rule-reteFacts" );
    for( Fact fact : inferred ) {
      assert (fact.getDependencySet().getBranch() == abox.getBranch());
      assert (fact.getDependencySet().max() <= abox.getBranch());
      applyFact( fact );
      if( abox.isClosed() ) {
        t.stop();
        return;
      }
      if( fact.getElements().size() > 3
          && fact.getElements().get( Compiler.PRED ).equals(
              ContinuousReteTransformer.VARBINDING ) ) {
        if( !partialBindings.containsKey( fact ) ) {
          partialBindings.put( fact, abox.getBranch() );
        }
      }
    }
    t.stop();
  }
View Full Code Here

    // behavior of Pellet. it is possible that this behavior will
    // change in the future and this test case can be modified
    // accordingly   
   
    KnowledgeBase kb = new KnowledgeBase();
    Timer classifyTimer = kb.timers.createTimer( "classify" );
    Timer realizeTimer = kb.timers.createTimer( "realize" );

    ATermAppl a = term( "a" );
    ATermAppl b = term( "b" );

    ATermAppl C = term( "C" );
    ATermAppl D = term( "D" );
    ATermAppl E = term( "E" );

    ATermAppl p = term( "p" );
    ATermAppl q = term( "q" );

    kb.addClass( C );
    kb.addClass( D );
    kb.addClass( E );

    kb.addSubClass( C, D );
    kb.addEquivalentClass( C, some( p, TOP ) );
    kb.addEquivalentClass( E, some( q, TOP ) );

    kb.addObjectProperty( p );
    kb.addObjectProperty( q );
    kb.addSubProperty( q, p );

    kb.addIndividual( a );
    kb.addIndividual( b );

    kb.addType( a, C );
    kb.addPropertyValue( p, a, b );

    // do the first consistency test
    // ABox: C(a), p(a, b)
    // TBox: C = some(p, TOP), E = some(q, TOP)
    // RBox: q [= p
    assertTrue( kb.isConsistent() );
   
    // no classification or realization yet
    assertEquals( 0, classifyTimer.getCount() );
    assertEquals( 0, realizeTimer.getCount() );   
    assertFalse( kb.isClassified() );
    assertFalse( kb.isRealized() );
   
    // force realization
    kb.realize();

    // make sure counts are ok
    assertEquals( 1, classifyTimer.getCount() );
    assertEquals( 1, realizeTimer.getCount() );

    // make an ABox change
    kb.addType( b, E );

    // check consistency again
    assertTrue( kb.isConsistent() );
   
    // classification results should remain but realization
    // results are invalidated
    assertTrue( kb.isClassified() );
    assertTrue( !kb.isRealized() );
   
    // force classification with a query
    assertEquals( emptySet(), kb.getEquivalentClasses( C ) );
   
    // verify classification occurred
    assertEquals( 1, classifyTimer.getCount() );
   
    // perform instance retrieval
    assertEquals( singleton( b ), kb.getInstances( E ) );
   
    // verify instance retrieval did not trigger realization
    assertEquals( 1, realizeTimer.getCount() );

    // query direct instances to force realization
    assertEquals( singleton( b ), kb.getInstances( E, true ) );
   
    // verify realization occurred
    assertEquals( 2, realizeTimer.getCount() );
   
    // make an ABox change causing p = q and as a result C = E
    kb.addSubProperty( p, q );

    // check consistency again
    assertTrue( kb.isConsistent() );
   
    // both classification and realization results are invalidated
    assertTrue( !kb.isClassified() );
    assertTrue( !kb.isRealized() );

    // verify new equivalent property inference
    assertEquals( singleton( q ), kb.getEquivalentProperties( p ) );
   
    // verify new property assertion inference
    assertEquals( singletonList( b ), kb.getPropertyValues( q, a ) );
   
    // nothing so far should have triggered classification or realization
    assertTrue( !kb.isClassified() );
    assertTrue( !kb.isRealized() );

    // verify new equivalent class inference (trigger classification)
    assertEquals( singleton( E ), kb.getEquivalentClasses( C ) );
   
    // verify classification
    assertEquals( 2, classifyTimer.getCount() );

    // verify new instance relation (trigger realization)
    assertEquals( SetUtils.create( a, b ), kb.getInstances( E, true ) );
   
    // verify realization
    assertEquals( 3, realizeTimer.getCount() );
  }
View Full Code Here

    loader.clear();
    loader.getKB().timers.resetAll();
    kb = loader.createKB( file + ext );   
    kb.setTimeout(TBOX_LIMIT * 1000);
   
    Timer t = kb.timers.startTimer( "test" );
   
    if( log.isLoggable( Level.INFO ) )
      System.out.print("preparing...");
   
    kb.prepare();
   
    if( log.isLoggable( Level.INFO ) )
      System.out.print("classifying...");
   
    kb.classify();
       
    t.stop();
   
    if(PRINT_TREE) kb.printClassTree();
   
    if( log.isLoggable( Level.INFO ) )
      System.out.print("verifying...");

    loader.verifyTBox( file + ".tree", kb );
   
    if( log.isLoggable( Level.INFO ) )
      System.out.print("done");
   
    if( log.isLoggable( Level.INFO ) ) {
      System.out.print( " Prepare " + kb.timers.getTimer("preprocessing").getTotal() );
        System.out.print( " Classify " + kb.timers.getTimer("classify").getTotal() );
   
        System.out.println( " " + t.getTotal() );
    }
   
    if(PRINT_TIME) kb.timers.print();
   
    return true;
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.