Package org.mindswap.pellet.utils

Examples of org.mindswap.pellet.utils.Timer


  public boolean classify() {
    reset();
   
    kb.prepare();
   
    Timer t = timers.startTimer( "createConcepts" );
    logger.info( "Creating structures" );
    createConcepts();
    logger.info( "Created structures" );
    t.stop();
   
    monitor.setProgressTitle( "Classifiying" );
    monitor.setProgressLength( queue.size() );
    monitor.taskStarted();

    printStructures();

    logger.info( "Processing queue" );
    t = timers.startTimer( "processQueue" );
    processQueue();
    t.stop();
    logger.info( "Processed queue" );

    if( logger.isLoggable( Level.FINE ) )
      print();

    logger.info( "Building hierarchy" );
    t = timers.startTimer( "buildHierarchy" );
   
    taxonomy = new ELTaxonomyBuilder().build( concepts );
//    buildTaxonomyWithPO();
   
    t.stop();
    logger.info( "Builded hierarchy" );

    monitor.taskFinished();
   
    return true;
View Full Code Here


     
      return false;
  }

  public Collection<PartialBinding> applyRete() {
    Timer t;
    if( PelletOptions.ALWAYS_REBUILD_RETE ) {
      t = timers.startTimer( "rule-rebuildRete" );

      partialBindings.clear();
      partialBindings.addAll(unsafeRules);
      interpreter.reset();
      t.stop();
    }

    t = timers.startTimer( "rule-reteRun" );
    interpreter.run();
    t.stop();
   
    return interpreter.getBindings();
  }
View Full Code Here

    }
  }

  public void complete(Expressivity expr) {
    Timer t;

    Expressivity expressivity = abox.getKB().getExpressivity();

    initialize( expressivity );

    merging = false;
    t = timers.startTimer( "rule-buildReteRules" );
    Compiler compiler = new Compiler(this);
    for (Entry<Rule, Rule> e : abox.getKB().getNormalizedRules().entrySet()) {
      Rule rule = e.getKey();
      Rule normalizedRule = e.getValue();

      if (normalizedRule == null)
        continue;

      Set<ATermAppl> explain = abox.doExplanation() ? rule.getExplanation(atermTranslator) : Collections
                      .<ATermAppl> emptySet();

      try {
              compiler.compile(normalizedRule, explain);
            }
            catch (UnsupportedOperationException uoe) {
              throw new RuntimeException("Unsupported rule " + normalizedRule, uoe);
            }
    }
    t.stop();
   
    AlphaNetwork alphaNet = compiler.getAlphaNet();
    if (abox.doExplanation()) {
      alphaNet.setDoExplanation(true);
    }
View Full Code Here

    monitor.taskStarted();
    monitor.setProgress( 0 );
   
    logger.info( "Creating structures" );
   
    Timer t = timers.startTimer( "createConcepts" );
    processAxioms();
    t.stop();
   
    logger.info( "Running rules" );
   
    MultiValueMap<ATermAppl, ATermAppl> subsumers = run( kb.getAllClasses() );
   
    monitor.setProgress( classes.size() );
   
    logger.info( "Building hierarchy" );
   
    t = timers.startTimer( "buildHierarchy" );
    buildTaxonomy( subsumers );
    t.stop();
   
    monitor.setProgress( classes.size() );
    monitor.taskFinished();
   
    return true;
View Full Code Here

  @Override
    public boolean classify() {
    logger.fine( "Reset" );
    reset();
   
    Timer t = timers.startTimer( "createConcepts" );
    logger.fine( "Creating structures" );
    createConcepts();
    logger.fine( "Created structures" );
    t.stop();
   
    int queueSize =  primaryQueue.size();
    monitor.setProgressTitle( "Classifiying" );
    monitor.setProgressLength( queueSize );
    monitor.taskStarted();
   
    logger.fine( "Processing queue" );
    t = timers.startTimer( "processQueue" );
    processQueue();
    t.stop();
    logger.fine( "Processed queue" );

    if( logger.isLoggable( Level.FINER ) ) {
      print();
    }   
   
    monitor.setProgress( queueSize );

    logger.fine( "Building hierarchy" );
    t = timers.startTimer( "buildHierarchy" );
   
    taxonomy = new ELTaxonomyBuilder().build( concepts );
   
    t.stop();
    logger.fine( "Builded hierarchy" );

    monitor.taskFinished();
   
    return true;
View Full Code Here

   * additions and deletions in order to guarantee completeness. These are
   * done here.
   */
  public void initialize(Expressivity expr) {
   
    Timer t = abox.getKB().timers.startTimer("initialize");

    if(log.isLoggable( Level.FINE ))
      log.fine("Initialize Started");
   
    mergeList = new ArrayList<NodeMerge>();
   
        blocking = BlockingFactory.createBlocking( expr );

        configureTableauRules( expr );
       
    for (Branch branch : abox.getBranches()) {
      branch.setStrategy(this);
    }

    // if this is an incremental addition we may need to merge nodes and
    // handle newly added individuals

    // merge nodes - note branch must be temporarily set to 0 to
    // ensure that assertion
    // will not be restored during backtracking
    // int branch = abox.getBranch();
    abox.setBranch(0);
       
    mergeList.addAll(abox.getToBeMerged());
    if (!mergeList.isEmpty())
      mergeAll();

     //Apply necessary initialization to any new individual added
     //Currently, this is a replication of the code
     for( Iterator<Individual> newIt = getNewIterator(); newIt.hasNext(); ) {
      Individual n = newIt.next();

      if (n.isMerged())
        continue;

      applyUniversalRestrictions(n);
     
      unfoldingRule.apply( n );
     
      selfRule.apply(n);       
    }
    
    //handle nodes affected by the update
    for (Iterator<Individual> it = getInitializeIterator(); it.hasNext();) {
   
      Individual n = it.next();

      nominalRule.apply(n);
     
      if (n.isMerged()){
        n = n.getSame();
      }

      allValuesRule.apply( n );
    }
   
    //process new edges
    for(Iterator<Edge> it = getNewEdgeIterator(); it.hasNext();){
      Edge edge = it.next();
     
      Individual subj = edge.getFrom();
      Node obj = edge.getTo();
      if(subj.isMerged())
        subj.getSame();
      if(subj.isPruned())
        continue;

      if(obj.isMerged())
        obj.getSame();
      if(obj.isPruned())
        continue;

      Role pred = edge.getRole();       
      DependencySet ds = edge.getDepends();

      applyDomainRange(subj, pred, obj, ds);
      if (subj.isPruned() || obj.isPruned()) {
        return;
      }
      applyFunctionality(subj, pred, obj);
      if (subj.isPruned() || obj.isPruned()) {
        return;
      }

      if (pred.isObjectRole()) {
        Individual o = (Individual) obj;
        checkReflexivitySymmetry(subj, pred, o, ds);
        checkReflexivitySymmetry(o, pred.getInverse(), subj, ds);
      }
     
      //if the KB has cardinality restrictions, then we need to apply the guessing rule
          if(abox.getKB().getExpressivity().hasCardinality()){
            //update the queue so the max rule will be fired
              updateQueueAddEdge(subj, pred, obj);
          }
    }
   
    
    //merge again if necessary
    if (!mergeList.isEmpty())
      mergeAll();
   
    //set appropriate branch
    abox.setBranch(abox.getBranches().size() + 1);

    // we will also need to add stuff to the queue in the event of a
    // deletion   
     
    //Handle removed edges
    Iterator<Edge> i = getRemovedEdgeIterator();
    while( i.hasNext() ){       
      Edge e = i.next();
      Individual subj = e.getFrom();
      Node obj = e.getTo();
     
      subj = subj.getSame();
     
      subj.applyNext[Node.SOME] = 0;
      subj.applyNext[Node.MIN] = 0;
      QueueElement qe = new QueueElement( subj );
      abox.getCompletionQueue().add( qe, NodeSelector.EXISTENTIAL );
      abox.getCompletionQueue().add( qe, NodeSelector.MIN_NUMBER );
     
     
      obj = obj.getSame();
      if(obj instanceof Individual){
        Individual objInd = (Individual)obj;
        objInd.applyNext[Node.SOME] = 0;
        objInd.applyNext[Node.MIN] = 0;
        qe = new QueueElement( objInd );
        abox.getCompletionQueue().add( qe, NodeSelector.EXISTENTIAL );
        abox.getCompletionQueue().add( qe, NodeSelector.MIN_NUMBER );
      }               
    }

   
   
   
    //Handle removed types
    Iterator<Map.Entry<Node,Set<ATermAppl>>> it = getRemovedTypeIterator();
    while( it.hasNext() ){
      Node node = it.next().getKey();
     
      if( node.isIndividual() ){
        Individual ind = (Individual)node;

        //readd the conjunctions
        readdConjunctions( ind );
       
        //it could be the case that the type can be added from unfolding, a forAll application on a self loop, or the disjunction rule
        ind.applyNext[Node.ATOM] = 0;
        ind.applyNext[Node.ALL] = 0;
        ind.applyNext[Node.OR] = 0;

        QueueElement qe = new QueueElement( ind );
        abox.getCompletionQueue().add( qe, NodeSelector.ATOM );
        abox.getCompletionQueue().add( qe, NodeSelector.DISJUNCTION );

        //fire the all rule as the is no explicit call to it
        allValuesRule.apply( ind );
       
        //get out edges and check domains, some values and min values
        for( int j = 0; j < ind.getOutEdges().size(); j++ ){
          Edge e = ind.getOutEdges().edgeAt( j );
                       
          if( e.getFrom().isPruned() || e.getTo().isPruned() )
            continue;
                       
              Role pred = e.getRole();
              Node obj = e.getTo();
              DependencySet ds = e.getDepends();
         
              for( ATermAppl domain : pred.getDomains() ) {             
                if( requiredAddType( ind, domain ) ) {
              if( !PelletOptions.USE_TRACING )
                addType( ind, domain, ds.union( DependencySet.EMPTY, abox.doExplanation() ) );
              else        
                addType( ind, domain, ds.union( pred.getExplainDomain( domain ), abox.doExplanation() ) );
                }
              }

              //it could be the case that this label prevented the firing of the all values, some, or min rules of the neighbor
          if( obj instanceof Individual ){
            Individual objInd = (Individual)obj;
            objInd.applyNext[Node.ALL] = 0;
            objInd.applyNext[Node.SOME] = 0;
            objInd.applyNext[Node.MIN] = 0;
            QueueElement qeObj = new QueueElement( objInd );
            abox.getCompletionQueue().add( qeObj, NodeSelector.EXISTENTIAL );
            abox.getCompletionQueue().add( qeObj, NodeSelector.MIN_NUMBER );
           
            //apply the all values rule
            allValuesRule.apply( ind );
          }
        }
      }
       
     
      //get out edges
      for( int j = 0; j < node.getInEdges().size(); j++ ){
        Edge e = node.getInEdges().edgeAt( j );
                     
        if( e.getFrom().isPruned() || e.getTo().isPruned() )
          continue;
       
        Individual subj = e.getFrom();
              Role pred = e.getRole();              
              DependencySet ds = e.getDepends();
       
            for( ATermAppl range : pred.getRanges() ) {
              if( requiredAddType( node, range ) ) {
            if( !PelletOptions.USE_TRACING )
              addType( node, range, ds.union( DependencySet.EMPTY, abox.doExplanation() ) );
            else        
              addType( node, range, ds.union( pred.getExplainRange( range ), abox.doExplanation() ) );
              }
            }

            //it could be the case that this label prevented the firing of the all values, some, or min rules of the neighbor
        subj.applyNext[Node.ALL] = 0;
        subj.applyNext[Node.SOME] = 0;
        subj.applyNext[Node.MIN] = 0;
        QueueElement qe = new QueueElement( subj );
        abox.getCompletionQueue().add( qe, NodeSelector.EXISTENTIAL );
        abox.getCompletionQueue().add( qe, NodeSelector.MIN_NUMBER );

        allValuesRule.apply( subj );
      }
    }
   
   
    //due to unmerging nodes, edges can actually be added
    i = getNewEdgeIterator();
    while( i.hasNext() ){       
      applyPropertyRestrictions( i.next() );       
    }
   
   
    //due to unmerging any node that was pruned could need rules applied to it. This is because these rules
    //would have been originally applied to the node that the pruned node was merged into. 
    for(Iterator<Node> nodeIt = getUnPrunedIterator(); nodeIt.hasNext(); ) {
      Node n = nodeIt.next();
     
      if( n.isIndividual() ) {
        Individual ind = (Individual) n;
       
        //reset type pointers
        for( int j = 0; j < Node.TYPES; j++ )
          ind.applyNext[j] = 0;
       
        //add to all queues
        abox.getCompletionQueue().add( new QueueElement( ind ) );
       
        allValuesRule.apply( ind );
       
        //get out edges
        for( int j = 0; j < ind.getOutEdges().size(); j++ ){
          Edge e = ind.getOutEdges().edgeAt( j );
                       
          if( !e.getFrom().isPruned() && !e.getTo().isPruned() )
            applyPropertyRestrictions( e );
         
          Node obj = e.getTo();
          if( obj instanceof Individual ){
            Individual objInd = (Individual)obj;
            objInd.applyNext[Node.ALL] = 0;
            allValuesRule.apply( objInd );
          }
        }
         
       
        //get out edges
        for( int j = 0; j < ind.getInEdges().size(); j++ ){
          Edge e = ind.getInEdges().edgeAt( j );
                       
          if( !e.getFrom().isPruned() && !e.getTo().isPruned() )
            applyPropertyRestrictions( e );
         
          Individual subj= e.getFrom();
          subj.applyNext[Node.ALL] = 0;
          allValuesRule.apply( subj );
        }
      }
    }
   
        abox.setChanged( true );
        abox.setComplete( false );
        abox.setInitialized( true );

        t.stop();
       
    if(log.isLoggable( Level.FINE ))
      log.fine("Initialize Ended");
  }
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 );

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

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

    timer.stop();
  }
View Full Code Here

  private void expand(Individual x) {
    checkTimer();

    if( !abox.doExplanation() && PelletOptions.USE_ADVANCED_CACHING ) {
      Timer t = abox.getKB().timers.startTimer( "cache" );
      Bool cachedSat = isCachedSat( x );
      t.stop();
      if( cachedSat.isKnown() ) {
        if( cachedSat.isTrue() ) {
          if( log.isLoggable( Level.FINE ) )
            log.fine( "Stop cached " + x );
          mayNeedExpanding.remove( 0 );
View Full Code Here

  public void restoreLocal(Individual ind, Branch br) {
    restore( br );
  }

  public void restore(Branch br) {
     Timer timer = timers.startTimer("restore");

    abox.stats.globalRestores++;
   
    Node clashNode = abox.getClash().getNode();
    List<ATermAppl> clashPath = clashNode.getPath();
    clashPath.add( clashNode.getName() );

    abox.setBranch( br.getBranch() );
    abox.setClash( null );
        // Setting the anonCount to the value at the time of branch creation is incorrect
        // when SMART_RESTORE option is turned on. If we create an anon node after branch
        // creation but node depends on an earlier branch restore operation will not remove
        // the node. But setting anonCount to a smaller number may mean the anonCount will
        // be incremented to that value and creating a fresh anon node will actually reuse
        // the not-removed node. The only advantage of setting anonCount to a smaller value
        // is to keep the name of anon nodes smaller to make debugging easier. For this reason,
        // the above line is not removed and under special circumstances may be uncommented
        // to help debugging only with the intent that it will be commented again after
        // debugging is complete 
    // abox.setAnonCount( br.getAnonCount() );

    mergeList.clear();

    List<ATermAppl> nodeList = abox.getNodeNames();

    if( log.isLoggable( Level.FINE ) ) {
      log.fine( "RESTORE: Branch " + br.getBranch() );
      if( br.getNodeCount() < nodeList.size() )
        log.fine( "Remove nodes " + nodeList.subList( br.getNodeCount(), nodeList.size() ) );
    }
    for( int i = 0; i < nodeList.size(); i++ ) {
      ATermAppl x = nodeList.get( i );

      Node node = abox.getNode( x );
      if( i >= br.getNodeCount() ) {
        abox.removeNode( x );
        ATermAppl c = cachedNodes.remove( node );
        if( c != null && PelletOptions.USE_ADVANCED_CACHING ) {
          if( clashPath.contains( x ) ) {
            if( log.isLoggable( Level.FINEST ) )
              log.finest( "+++ Cache unsat concept " + c );
            abox.getCache().putSat( c, false );
          }
          else if( log.isLoggable( Level.FINEST ) )
            log.finest( "--- Do not cache concept " + c + " " + x + " "
                + clashNode + " " + clashPath );
        }
      }
      else {
        node.restore( br.getBranch() );

        // FIXME should we look at the clash path or clash node
        if( node.equals( clashNode ) ) {
          cachedNodes.remove( node );
        }
      }
    }
    nodeList.subList( br.getNodeCount(), nodeList.size() ).clear();

    for( Iterator<Individual> i = abox.getIndIterator(); i.hasNext(); ) {
      Individual ind = i.next();
      allValuesRule.apply( ind );
    }

    if( log.isLoggable( Level.FINE ) )
      abox.printTree();

     timer.stop();
  }
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

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.