Package nl.vu.few.anytimereasoning.workbench.approximation

Examples of nl.vu.few.anytimereasoning.workbench.approximation.ApproximationResult


      // FaCTPlusPlusReasonerFactory();
      OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
      OWLReasoner reasoner = null;

      OWLOntology aboxOntology = null;
      ApproximationResult approximationResult = null;
      OWLOntology approximatedTboxOntology = null;

      HashMap<OWLClass, Integer> allIndividualsCounts = new HashMap<OWLClass, Integer>();
      HashMap<OWLClass, Integer> directIndividualsCounts = new HashMap<OWLClass, Integer>();
      HashMap<OWLClass, Integer> indirectIndividualsCounts = new HashMap<OWLClass, Integer>();

      int cumulativeDirectIndividualsCounts = 0;
      int cumulativeIndirectIndividualsCounts = 0;

      Timers timers = new Timers();

      double classificationTime = 0;
      double approximationTime = 0;
      double instanceRetrievalTime = 0;
      double aboxUpdateTime = 0;
      double time = 0;

      // System.out.println("--->approximating...");
      timers.createTimer("approximation");
      Timer timerApproximation = timers.startTimer("approximation");
      approximationResult = approximation.getNextTBox();
      timerApproximation.stop();
      if (measureApproximationTime)
      {
        approximationTime += timerApproximation.getTotal();
      }

      if (approximationResult != null)
      {
        approximatedTboxOntology = approximationResult
            .approximatedOntology();

        URI tboxPhysicalURI = createURI(tmpTboxPhysicalURI, runCounter);
        if (saveApproximatedTbox)
        {
          saveOntology(approximatedTboxOntology, tboxPhysicalURI);
        }

        // System.out.println("--->classifying...");
        reasoner = reasonerFactory.createReasoner(manager);
        reasoner.loadOntologies(Collections
            .singleton(approximatedTboxOntology));
        timers.createTimer("classification");
        if (!(reasoner.isClassified()))
        {
          Timer timerClassify = timers.startTimer("classification");
          reasoner.classify();
          timerClassify.stop();
          classificationTime += timerClassify.getTotal();
        }

        if (approximationResult.isOriginal())
        {
          aboxPhysicalURI = originalAboxPhysicalURI;
        }

        aboxOntology = manager
            .loadOntologyFromPhysicalURI(aboxPhysicalURI);

        reasoner.loadOntologies(Collections.singleton(aboxOntology));

        // System.out.println("--->retrieving instances...");
        for (OWLClass cc : concepts)
        {
          Set<OWLIndividual> individuals = new HashSet<OWLIndividual>();
          Set<OWLIndividual> directIndividuals = new HashSet<OWLIndividual>();

          if (reasoner.isDefined(cc))
          {
            timers.createTimer("retrieval");
            Timer timerRetrieval = timers.startTimer("retrieval");
            individuals = reasoner.getIndividuals(cc, false);
            timerRetrieval.stop();
            instanceRetrievalTime += timerRetrieval.getTotal();
          }

          directIndividuals = reasoner.getIndividuals(cc, true);
          allIndividualsCounts.put(cc,
              new Integer(individuals.size()));
          directIndividualsCounts.put(cc, new Integer(
              directIndividuals.size()));
          indirectIndividualsCounts.put(cc, new Integer(individuals
              .size()
              - directIndividuals.size()));

          if (isInterruptible)
          {

            List<OWLOntologyChange> changesToMake = new Vector<OWLOntologyChange>();
            OWLDataFactory factory = manager.getOWLDataFactory();
            timers.createTimer("aboxupdate");
            Timer timerAboxUpdate = timers.startTimer("aboxupdate");
            for (OWLIndividual ci : individuals)
            {
              changesToMake.add(new AddAxiom(aboxOntology,
                  factory.getOWLClassAssertionAxiom(ci, cc)));
            }
            timerAboxUpdate.stop();
            aboxUpdateTime += timerAboxUpdate.getTotal();
          }

          cumulativeDirectIndividualsCounts += directIndividuals
              .size();
          cumulativeIndirectIndividualsCounts += (individuals.size() - directIndividuals
              .size());
        }

        time = approximationTime + classificationTime
            + instanceRetrievalTime + aboxUpdateTime;

        /* Save the results of the run */
        runResult = new RunResult(allIndividualsCounts, time,
            approximation.getCurrentVocabularyConceptSize(),
            approximation.getCurrentVocabularyPropertySize());
        runResult.setIndirectIndividuals(indirectIndividualsCounts);
        runResult.setDirectIndividuals(directIndividualsCounts);
        runResult.setClassificationTime(classificationTime);
        runResult.setAboxUpdateTime(aboxUpdateTime);
        runResult.setInstanceRetrievalTime(instanceRetrievalTime);
        runResult.setApproximationTime(approximationTime);
        runResult.setInstances(approximateClassInstances);
        runResult.setAxiomRewriteTime(approximationResult
            .axiomRewriteTime());
        runResult.setVocabularySelectionTime(approximationResult
            .selectionTime());
        runResult.setRunNumber(runCounter);

        if (StrategyManager.getLastSelectionStrategy() != null)
          StrategyManager.getLastSelectionStrategy().feedback(
View Full Code Here

TOP

Related Classes of nl.vu.few.anytimereasoning.workbench.approximation.ApproximationResult

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.