コード例 #1
0
 @Override
 public void configure(Configuration conf) {
   try {
     super.configure(conf);
     this.fes_prints = conf.getList("Fes_Prints");
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
コード例 #2
0
  @Override
  public void update(Observable o, Object arg) {

    ParallelEvolutionaryAlgorithm pea = (ParallelEvolutionaryAlgorithm) o;

    if (pea.getCurrentObservable() instanceof EvolutionaryAlgorithm) {
      super.update(o, arg);
      EvolutionaryAlgorithm algorithm = (EvolutionaryAlgorithm) pea.getCurrentObservable();

      BestIndividualSpecification bestSpec = new BestIndividualSpecification();
      Individual best;
      int algorithm_fes;

      best =
          IndividualsProductTrader.get(
                  bestSpec, algorithm.getPopulation().getIndividuals(), 1, pea.getComparator())
              .get(0);

      if (algorithm.getState() == EvolutionaryAlgorithm.REPLACE_STATE) {
        algorithm_fes = algorithm.getFEs();

        if (num_prints < this.fes_prints.size()
            && algorithm_fes >= Integer.parseInt((String) this.fes_prints.get(fes_index))) {
          super.getLog().println(best);
          this.fes_index++;
          num_prints++;
        }
      }

      if (algorithm.getState() == EvolutionaryAlgorithm.FINAL_STATE) {
        while (num_prints < this.fes_prints.size()) {
          super.getLog().println(best);
          num_prints++;
        }
      }
    }
  }