Package org.mindswap.pellet.utils

Examples of org.mindswap.pellet.utils.Timer


   
    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


      log.fine( "Classes: " + classCount + " Individuals: "
          + kb.getIndividuals().size() );
    }

    if( !prepared ) {
      Timer t = kb.timers.startTimer( "taxBuilder.prepare" );
      prepare();
      t.stop();
    }

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

    conceptFlags = CollectionUtils.makeIdentityMap();
  }

  private void computeToldInformation() {
    Timer t = kb.timers.startTimer( "computeToldInformation" );

    toldTaxonomy = new Taxonomy<ATermAppl>( classes, ATermUtils.TOP, ATermUtils.BOTTOM );

    // compute told subsumers for each concept
    TBox tbox = kb.getTBox();
    Collection<ATermAppl> axioms = tbox.getAxioms();
    for( ATermAppl axiom : axioms ) {
      ATermAppl c1 = (ATermAppl) axiom.getArgument( 0 );
      ATermAppl c2 = (ATermAppl) axiom.getArgument( 1 );

      boolean equivalent = axiom.getAFun().equals( ATermUtils.EQCLASSFUN );
      Set<ATermAppl> explanation = tbox.getAxiomExplanation( axiom );

      boolean reverseArgs = !ATermUtils.isPrimitive( c1 ) && ATermUtils.isPrimitive( c2 );
      if( equivalent && reverseArgs ) {
              addToldRelation( c2, c1, equivalent, explanation );
            }
            else {
              addToldRelation( c1, c2, equivalent, explanation );
            }
    }

    // additional step for union classes. for example, if we have
    // C = or(A, B)
    // and both A and B subclass of D then we can conclude C is also
    // subclass of D
    for( ATermAppl c : unionClasses.keySet() ) {

      List<ATermAppl> list = new ArrayList<ATermAppl>();
      for( ATermList disj = unionClasses.get( c ); !disj.isEmpty(); disj = disj.getNext() ) {
        list.add( (ATermAppl) disj.getFirst() );
      }
      List<ATermAppl> lca = toldTaxonomy.computeLCA( list );

      for( ATermAppl d : lca ) {
        if( log.isLoggable( Level.FINER ) ) {
                  log.finer( "Union subsumption " + format( c ) + " " + format( d ) );
                }

        addToldSubsumer( c, d );
      }
    }

    // we don't need this any more so set it null and let GC claim it
    unionClasses = null;

    toldTaxonomy.assertValid();

    t.stop();
  }
View Full Code Here

  private TaxonomyNode<ATermAppl> checkSatisfiability(ATermAppl c) {
    if( log.isLoggable( Level.FINER ) ) {
          log.finer( "Satisfiable " );
        }

    Timer t = kb.timers.startTimer( "classifySat" );
    boolean isSatisfiable = kb.getABox().isSatisfiable( c, true );
    t.stop();

    if( log.isLoggable( Level.FINER ) ) {
          log.finer( (isSatisfiable
        ? "true"
        : "*****FALSE*****") + " (" + t.getLast() + "ms)" );
        }

    if( !isSatisfiable ) {
          taxonomy.addEquivalentNode( c, taxonomy.getBottom() );
        }

    if( PelletOptions.USE_CACHING ) {
      if( log.isLoggable( Level.FINER ) ) {
              log.finer( "...negation " );
            }

      t = kb.timers.startTimer( "classifySatNot" );
      ATermAppl notC = ATermUtils.makeNot( c );
      isSatisfiable = kb.getABox().isSatisfiable( notC, true );
      t.stop();

      if( !isSatisfiable ) {
              taxonomy.addEquivalentNode( c, taxonomy.getTop() );
            }

      if( log.isLoggable( Level.FINER ) ) {
              log.finer( isSatisfiable + " (" + t.getLast() + "ms)" );
            }
    }

    return taxonomy.getNode( c );
  }
View Full Code Here

         * if i has only one super class j and j is a subclass of i then
         * it means i = j. There is no need to classify i since we
         * already know everything about j
         */
        ATermAppl sup = supNode.getName();
        Timer t = kb.timers.startTimer( "eqCheck" );
        boolean isEq = subsumes( c, sup );
        t.stop();
        if( isEq ) {
          if( log.isLoggable( Level.FINER ) ) {
                      log.finer( format( c ) + " = " + format( sup ) );
                    }

View Full Code Here

  }

  private Collection<TaxonomyNode<ATermAppl>> search(boolean topSearch, ATermAppl c,
      TaxonomyNode<ATermAppl> x, Set<TaxonomyNode<ATermAppl>> visited,
      List<TaxonomyNode<ATermAppl>> result) {
    Timer t = kb.timers.startTimer( "search" + (topSearch ? "Top" : "Bottom") );
   
    List<TaxonomyNode<ATermAppl>> posSucc = new ArrayList<TaxonomyNode<ATermAppl>>();
    visited.add( x );

    Collection<TaxonomyNode<ATermAppl>> list = topSearch
      ? x.getSubs()
      : x.getSupers();

    for( TaxonomyNode<ATermAppl> next : list ) {

      if( topSearch ) {
        if( subsumes( next, c ) ) {
                  posSucc.add( next );
                }
      }
      else {
        if( subsumed( next, c ) ) {
                  posSucc.add( next );
                }
      }
    }

    if( posSucc.isEmpty() ) {
      result.add( x );
    }
    else {
      for( TaxonomyNode<ATermAppl> y : posSucc ) {
        if( !visited.contains( y ) ) {
                  search( topSearch, c, y, visited, result );
                }
      }
    }

    t.stop();
   
    return result;
  }
View Full Code Here

        time = System.currentTimeMillis();
        count = kb.getABox().stats.consistencyCount;
        log.finer( "Type checking for [" + format( n ) + ", " + format( c ) + "]..." );
      }

      Timer t = kb.timers.startTimer( "classifyType" );
      isType = kb.isType( n, c );
      t.stop();
      marked.put( c, isType
        ? Boolean.TRUE
        : Boolean.FALSE );

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

    return instances;
  }

  public void printStats() {
    Timer t1 = kb.timers.getTimer( "satisfiability" );
    Timer t2 = kb.timers.getTimer( "subClassSat" );
    StringBuilder sb = new StringBuilder( kb.getABox().getCache().toString() );
    sb.append( "sat: " );
    if( t1 != null ) {
      sb.append( t1.getCount() ).append( " " ).append( t1.getTotal() );
    }
    else {
      sb.append( "0" );
    }

    sb.append( " sub: " );
    if( t2 != null ) {
      sb.append( t2.getCount() ).append( " " ).append( t2.getTotal() );
    }
    else {
      sb.append( "0" );
    }
View Full Code Here

        }
  }

  public ABox(KnowledgeBase kb, ABox abox, ATermAppl extraIndividual, boolean copyIndividuals) {
    this.kb = kb;
    Timer timer = kb.timers.startTimer( "cloneABox" );


    this.rulesNotApplied = true;
    initialized = abox.initialized;
    setChanged( abox.isChanged() );
    setAnonCount( abox.getAnonCount() );
    cache = abox.cache;
    clash = abox.clash;   
    dtReasoner = abox.dtReasoner;
    doExplanation = abox.doExplanation;
    setDisjBranchStats( abox.getDisjBranchStats() );

    int extra = (extraIndividual == null)
      ? 0
      : 1;
    int nodeCount = extra + (copyIndividuals
      ? abox.nodes.size()
      : 0);

    nodes = new HashMap<ATermAppl, Node>( nodeCount );
    nodeList = new ArrayList<ATermAppl>( nodeCount );

    if( PelletOptions.TRACK_BRANCH_EFFECTS ) {
      if( copyIndividuals ) {
              branchEffects = abox.branchEffects.copy();
            }
            else {
              branchEffects = new SimpleBranchEffectTracker();
            }
    }
        else {
          branchEffects = null;
        }
   
    // copy the queue - this must be done early so that the effects of
    // adding the extra individual do not get removed
    if( PelletOptions.USE_COMPLETION_QUEUE ) {
      if( copyIndividuals ) {
        completionQueue = abox.completionQueue.copy();
        completionQueue.setABox( this );
      }
      else if( PelletOptions.USE_OPTIMIZED_BASIC_COMPLETION_QUEUE ) {
              completionQueue = new OptimizedBasicCompletionQueue( this );
            }
            else {
              completionQueue = new BasicCompletionQueue( this );
            }
    }
        else {
          completionQueue = null;
        }

    if( extraIndividual != null ) {
      Individual n = new Individual( extraIndividual, this, null );
      n.setNominalLevel( Node.BLOCKABLE );
      n.setConceptRoot( true );
      n.addType( ATermUtils.TOP, DependencySet.INDEPENDENT );
      nodes.put( extraIndividual, n );
      nodeList.add( extraIndividual );

      if( PelletOptions.COPY_ON_WRITE ) {
              sourceABox = abox;
            }
    }

    if( copyIndividuals ) {
      toBeMerged = abox.getToBeMerged();
      if( sourceABox == null ) {
        for( int i = 0; i < nodeCount - extra; i++ ) {
          ATermAppl x = abox.nodeList.get( i );
          Node node = abox.getNode( x );
          Node copy = node.copyTo( this );

          nodes.put( x, copy );
          nodeList.add( x );
        }

        for( Node node : nodes.values() ) {
          node.updateNodeReferences();
        }
      }
    }
    else {
      toBeMerged = Collections.emptyList();
      sourceABox = null;
      initialized = false;
    }

    // Copy of the incChangeTracker looks up nodes in the new ABox, so this
    // copy must follow node copying
    if( PelletOptions.USE_INCREMENTAL_CONSISTENCY ) {
      if( copyIndividuals ) {
              incChangeTracker = abox.incChangeTracker.copy( this );
            }
            else {
              incChangeTracker = new SimpleIncrementalChangeTracker();
            }
    }
        else {
          incChangeTracker = null;
        }

    assertedClashes = new HashSet<Clash>();
    for( Clash clash : abox.assertedClashes ) {
      assertedClashes.add( clash.copyTo( this ) );
    }
   
    if( extraIndividual == null || copyIndividuals ) {
      setBranch( abox.branch );
      branches = new ArrayList<Branch>( abox.branches.size() );
      for( int i = 0, n = abox.branches.size(); i < n; i++ ) {
        Branch branch = abox.branches.get( i );
        Branch copy;

        if( sourceABox == null ) {
          copy = branch.copyTo( this );
          copy.setNodeCount( branch.getNodeCount() + extra );
        }
        else {
          copy = branch;
        }
        branches.add( copy );
      }
    }
    else {
      setBranch( DependencySet.NO_BRANCH );
      branches = new ArrayList<Branch>();
    }

    timer.stop();

  }
View Full Code Here

  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

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.