コード例 #1
0
  // Redress is called here for prediction
  private LinkedHashMap<String, LinkedHashMap<String, LinkedHashMap<String, Double>>>
      PredictingMetrics(List<RefactoringOperation> operations)
          throws ReadException, IOException, CompilUnitException, WritingException {

    List<RefactoringOperation> operationsClone;
    // (List<RefactoringOperation>)Clone.create(operations);
    for (RefactoringOperation operRef : operations) {

      if (recordar(operRef)) {
        System.out.println("Recalling metrics");
        predictMetrics.putAll(
            (LinkedHashMap<String, LinkedHashMap<String, LinkedHashMap<String, Double>>>)
                Clone.create(predictMetricsRecordar));
        predictMetricsRecordar =
            new LinkedHashMap<String, LinkedHashMap<String, LinkedHashMap<String, Double>>>();

      } else {

        System.out.println("Predicting metrics");
        operationsClone = new ArrayList<RefactoringOperation>();
        operationsClone.add(operRef);
        MetricCalculator calc = new MetricCalculator();
        // predictMetrics = calc.predictMetrics(operations, metaphor.getMetrics(), prevMetrics);
        // predictMetrics = calc.predictMetrics(operationsClone, metaphor.getMetrics(),
        // prevMetrics);
        predictMetricsMemorizar.putAll(
            calc.predictMetrics(operationsClone, metaphor.getMetrics(), prevMetrics));
        predictMetrics.putAll(
            (LinkedHashMap<String, LinkedHashMap<String, LinkedHashMap<String, Double>>>)
                Clone.create(predictMetricsMemorizar));
        // Memoriza en Archivo lo que se encuentra en la predicción y vacís la estructura
        memorizar(operRef);
      }
    }

    return predictMetrics;
  }
コード例 #2
0
 /**
  * Flips a bit in the given genome
  *
  * @param gen Genome to be modified
  * @return Number of mutated bits
  */
 @Override
 public List<QubitRefactor> apply(List<QubitRefactor> gen) {
   try {
     List<QubitRefactor> genome = (List<QubitRefactor>) Clone.create(gen);
     double rate = 1.0 - ((bit_mutation_rate == 0.0) ? 1.0 / genome.size() : bit_mutation_rate);
     RandBool g = new RandBool(rate);
     RefOperQUMutation variation = new RefOperQUMutation();
     for (int i = 0; i < genome.size(); i++) {
       if (g.next()) {
         // genome.not(i);
         genome.set(i, variation.apply(genome.get(i)));
       }
     }
     return genome;
   } catch (Exception e) {
     e.printStackTrace();
     System.err.println("[Mutation]" + e.getMessage());
   }
   return null;
 }
コード例 #3
0
 @Override
 public double[][] plus(double[][] one, double[][] two) {
   return fastPlus((double[][]) Clone.get(one), two);
 }