Package org.mindswap.pellet.utils

Examples of org.mindswap.pellet.utils.Timer


      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


    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

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

    PelletReasoner pellet = PelletReasonerFactory.getInstance().createReasoner( ont );
    KnowledgeBase kb = pellet.getKB();

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


    try {
      kb.classify();
    } catch( TimeoutException e ) {
View Full Code Here

    OWLOntology ont = loadOntology( "file:" + PelletTestSuite.base + "modularity/SWEET.owl" );

    PelletReasoner pellet = PelletReasonerFactory.getInstance().createReasoner( ont );
    KnowledgeBase kb = pellet.getKB();

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

    try {
      kb.classify();
    } catch( TimeoutException e ) {
      timeout = true;
View Full Code Here

  private void incrementalClassify() {
    if( log.isLoggable( Level.FINE ) ) {
          log.fine( "Incremental classification starting" );
        }

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

    incClassifyAllModStrategy();
   
    timer.stop();

    if( log.isLoggable( Level.FINE ) ) {
          log.fine( "Incremental classification done" );
        }
  }
View Full Code Here

    Thread classification = new Thread( "classification" ) {
      @Override
            public void run() {
        // classify ontology
        Timer timer = timers.startTimer( "reasonerClassify" );
        reasoner.flush();
        reasoner.getKB().classify();
        timer.stop();

        if( log.isLoggable( Level.FINE ) ) {
          log.fine( "Regular taxonomy:" );

          new TreeTaxonomyPrinter<ATermAppl>().print( reasoner.getKB().getTaxonomy(), new PrintWriter( System.err ) );
        }

        timer = timers.startTimer( "buildClassHierarchy" );
        taxonomy = buildClassHierarchy( reasoner );
        timer.stop();

        if( log.isLoggable( Level.FINE ) ) {
          log.fine( "Copied taxonomy:" );

          new TreeTaxonomyPrinter<OWLClass>().print( taxonomy, new PrintWriter( System.err ) );
        }
      }
    };

    Thread partitioning = new Thread( "partitioning" ) {
      @Override
            public void run() {
        // get modules for each concept
        modules = extractor.extractModules();
      }
    };

    try {
      Timer timer = timers.startTimer( "regularClassify" );

     
      if( multiThreaded ) {
        classification.start();
        partitioning.start();
       
        classification.join();     
        partitioning.join();
      }
      else {
        classification.run();
        partitioning.run();       
      }

      timer.stop();
    } catch( InterruptedException e ) {
      throw new RuntimeException( e );
    }   

    if( log.isLoggable( Level.FINE ) ) {
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

   
    kb = loader.createKB( file + ext );
    kb.timers.resetAll();
    kb.setTimeout(ABOX_LIMIT * 1000);

    Timer t = kb.timers.startTimer( "test" );
   
    System.out.print("preparing...");
   
    kb.prepare();
   
        if( !FAST ) {
        System.out.print("classifying...");       
          kb.realize();
        }
       
    t.stop();
           
   
    System.out.print("verifying...");
    loader.verifyABox( file + ".query", kb );
   
    System.out.print("done");
   
    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.