Package nl.vu.few.anytimereasoning.workbench.selectionstrategies

Examples of nl.vu.few.anytimereasoning.workbench.selectionstrategies.StepSizeStrategy


    /* remove tbox and abox from manager as we don't need them anymore */
    manager.removeOntology(tboxLogicalURI);
    manager.removeOntology(aboxLogicalURI);
       
    /* Initialize approximation */
    StepSizeStrategy stepSizeStrategy = StrategyFactory.newStepSizeStrategy(stepID, concepts.size());
    SelectionStrategy selectionStrategy = StrategyFactory.newSelectionStrategy(selectionID, concepts, properties, stepSizeStrategy, tboxPhysicalURI, aboxPhysicalURI);
    ApproximationTask approximation = new ApproximationTask(selectionStrategy, tboxPhysicalURI, aboxPhysicalURI, file_prefix, tmpOntologyURI, rParameter, iParameter, PATH_TO_RESULTS);
   
    try {
      logger.info("Running baseline...");
View Full Code Here


    // get the starting point for the simulated annealing process
    ArrayList<OWLClass> currentPoint = getStartingPoint(tboxPhysicalURI,
        aboxPhysicalURI, method, ontology);
    Set<OWLProperty<?, ?>> currentProperties = new HashSet<OWLProperty<?, ?>>();

    StepSizeStrategy currentStepSizeStrategy = StrategyFactory
        .newStepSizeStrategy("EqualParts", currentPoint.size());

    TrivialStrategy currentSelectionStrategy = new TrivialStrategy(
        new HashSet<OWLClass>(currentPoint), currentProperties,
        currentStepSizeStrategy, currentPoint, currentID + "");

    /*new ExperimentManager().run(currentSelectionStrategy,
        datasetsDirectory, ontology, resultsDirectory, tmpDirectory);
    currentGainScore = new IntegralCalculator().getGainScore(
        resultsDirectory, ontology, currentSelectionStrategy.getID());*/

    double maxGainScore = currentGainScore;
    ArrayList<OWLClass> maxPoint = new ArrayList<OWLClass>(currentPoint);
    double maxID = currentID;

    currentID++;

    for (int i = 0; i < maxIterations; i++)
    {
      ArrayList<OWLClass> neighborPoint = getNeighborPoint(currentPoint);
      for (int j = 0; j < 7; j++)
        neighborPoint = getNeighborPoint(neighborPoint);
      Set<OWLProperty<?, ?>> neighborProperties = new HashSet<OWLProperty<?, ?>>();

      StepSizeStrategy neighborStepSizeStrategy = StrategyFactory
          .newStepSizeStrategy("EqualParts", currentPoint.size());

      TrivialStrategy neighborSelectionStrategy = new TrivialStrategy(
          new HashSet<OWLClass>(neighborPoint), neighborProperties,
          neighborStepSizeStrategy, neighborPoint, currentID + "");
      /*new ExperimentManager()
          .run(neighborSelectionStrategy, datasetsDirectory,
              ontology, resultsDirectory, tmpDirectory);*/
      double neighborGainScore = new IntegralCalculator().getGainScore(
          resultsDirectory, ontology, neighborSelectionStrategy
              .getID());

      double probability = 1;

      if (neighborGainScore < currentGainScore)
      {
        double c = 1 - (i + 1) / (double) maxIterations;
        probability = Math.pow(Math.E,
            (neighborGainScore - currentGainScore) / c);
      }

      if (random.nextDouble() < probability)
      {
        currentPoint = new ArrayList<OWLClass>(neighborPoint);
        currentGainScore = neighborGainScore;
        currentID++;
      }

      if (maxGainScore < currentGainScore)
      {
        maxGainScore = currentGainScore;
        maxPoint = new ArrayList<OWLClass>(currentPoint);
        maxID = currentID;
      }
    }
    try
    {
      OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
      OWLOntology tboxOntology = null, aboxOntology = null;
      try
      {
        // load the Tbox and Abox
        tboxOntology = manager.loadOntology(tboxPhysicalURI);
        aboxOntology = manager
            .loadOntologyFromPhysicalURI(aboxPhysicalURI);
      } catch (OWLOntologyCreationException e)
      {
        e.printStackTrace();
        System.exit(0);
      }

      StepSizeStrategy stepSizeStrategy = StrategyFactory
          .newStepSizeStrategy("EqualParts", maxPoint.size());

      String methodString = "Random";
      if (method == 1)
      {
        methodString = "Google";
      }
      File file = new File(resultsDirectory + ontology + "_"
          + methodString + "_" + round2Decimals(maxGainScore)
          + ".csv");
      DataOutputStream dos = new DataOutputStream(new FileOutputStream(
          file));

      // dos.writeBytes("Gain Score, " + maxGainScore + "\n");
      dos
          .writeBytes("Concept, Google Score, No Descendats, No Ancestors, No Definig Axioms, No Referencing Axioms, Classes in Signature, No Superclasses, No Subclasses, No Disjoint Classes, No Equivalent Clases, No Direct Individuals, Bin No\n");

      int s = stepSizeStrategy.getNextStepSize();
      int bin = 1;
      int i = 0;
      for (OWLClass c : maxPoint)
      {
        dos.writeBytes(c.getURI().toString() + ", ");
        dos.writeBytes(((Integer) googleScores.get(c.getURI()
            .toString())).toString()
            + ", ");
        dos.writeBytes(getNoDescendants(c, tboxOntology) + ", ");
        dos.writeBytes(getNoAncestors(c, tboxOntology) + ", ");
        dos.writeBytes(tboxOntology.getAxioms(c).size() + ", ");
        dos.writeBytes(tboxOntology.getReferencingAxioms(c).size()
            + ", ");
        dos.writeBytes(c.getClassesInSignature().size() + ", ");
        dos.writeBytes(c.getSuperClasses(tboxOntology).size() + ", ");
        dos.writeBytes(c.getSubClasses(tboxOntology).size() + ", ");
        dos
            .writeBytes(c.getDisjointClasses(tboxOntology).size()
                + ", ");
        dos.writeBytes(c.getEquivalentClasses(tboxOntology).size()
            + ", ");
        dos.writeBytes(c.getIndividuals(aboxOntology).size() + ", ");
        dos.writeBytes(bin + "\n");
        if (i == s - 1)
        {
          s = stepSizeStrategy.getNextStepSize();
          bin++;
          i = 0;
        } else
        {
          i++;
View Full Code Here

    }
    int index1 = 0, index2 = 0;
    int[] stepSizes = new int[noApproximations];
    int[] approximationSizes = new int[noApproximations];

    StepSizeStrategy stepSizeStrategy = StrategyFactory
        .newStepSizeStrategy("EqualParts", currentPoint.size());
    for (int i = 0; i < noApproximations; i++)
    {
      stepSizes[i] = stepSizeStrategy.getNextStepSize();
      if (i == 0)
      {
        approximationSizes[i] = stepSizes[i];
      } else
      {
View Full Code Here

      Set<OWLProperty<?, ?>> properties = new HashSet<OWLProperty<?, ?>>();

      manager.removeOntology(tboxLogicalURI);
      manager.removeOntology(aboxLogicalURI);

      StepSizeStrategy stepSizeStrategy = StrategyFactory
          .newStepSizeStrategy(stepSizeStrategyID, concepts.size());
      /*
       * SelectionStrategy selectionStrategy = StrategyFactory
       * .newSelectionStrategy(selectionStrategyID, concepts, properties,
       * stepSizeStrategy, tboxPhysicalURI, aboxPhysicalURI);
View Full Code Here

TOP

Related Classes of nl.vu.few.anytimereasoning.workbench.selectionstrategies.StepSizeStrategy

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.