예제 #1
0
  protected double[] fitness(final P param) {
    final Predicate<? super EvolutionResult<G, N>> terminator = _terminator.apply(param);

    final long start = System.currentTimeMillis();
    final EvolutionResult<G, N> result =
        _engine
            .apply(param)
            .stream()
            .limit(terminator)
            .collect(EvolutionResult.toBestEvolutionResult());
    final long end = System.currentTimeMillis();

    return new double[] {
      result.getTotalGenerations(),
      result.getBestFitness() != null
          ? result.getBestFitness().doubleValue()
          : Double.NEGATIVE_INFINITY,
      end - start
    };
  }