/*
 * Java Genetic Algorithm Library (@__identifier__@).
 * Copyright (c) @__year__@ Franz Wilhelmstötter
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author:
 *    Franz Wilhelmstötter (franz.wilhelmstoetter@gmx.at)
 */
package org.jenetics.engine;

import java.util.function.Predicate;

/**
 * @author <a href="mailto:franz.wilhelmstoetter@gmx.at">Franz Wilhelmstötter</a>
 * @version !__version__!
 * @since !__version__!
 */
public class FitnessConvergenceLimit<N extends Number & Comparable<? super N>>
	implements Predicate<EvolutionResult<?, N>>
{


	@Override
	public boolean test(final EvolutionResult<?, N> result) {
		return false;
	}


}

@@ -775,36 +775,256 @@
 ort 
-java.util.function.Predicate
+static java.util.Objects.requireNonNull;%0A%0Aimport java.util.function.BiPredicate;%0Aimport java.util.function.DoubleConsumer;%0Aimport java.util.function.Predicate;%0A%0Aimport org.jenetics.stat.DoubleMomentStatistics;%0Aimport org.jenetics.stat.DoubleMoments
 ;%0A%0A/
@@ -1162,22 +1162,21 @@
 __!%0A */%0A
-public
+final
  class F
@@ -1292,98 +1292,1465 @@
 %0A%7B%0A%0A
-%0A%09@Override%0A%09public boolean test(final EvolutionResult%3C?, N%3E result) %7B%0A%09%09return false;%0A%09%7D%0A
+%09private final Buffer _shortBuffer;%0A%09private final Buffer _longBuffer;%0A%09private final BiPredicate%3CDoubleMoments, DoubleMoments%3E _limit;%0A%0A%09private long _generation;%0A%0A%09FitnessConvergenceLimit(%0A%09%09final int shortFilterSize,%0A%09%09final int longFilterSize,%0A%09%09final BiPredicate%3CDoubleMoments, DoubleMoments%3E limit%0A%09) %7B%0A%09%09_shortBuffer = new Buffer(shortFilterSize);%0A%09%09_longBuffer = new Buffer(longFilterSize);%0A%09%09_limit = requireNonNull(limit);%0A%09%7D%0A%0A%09@Override%0A%09public boolean test(final EvolutionResult%3C?, N%3E result) %7B%0A%09%09final Number fitness = result.getBestFitness();%0A%0A%09%09if (fitness != null) %7B%0A%09%09%09_shortBuffer.accept(fitness.doubleValue());%0A%09%09%09_longBuffer.accept(fitness.doubleValue());%0A%09%09%09++_generation;%0A%09%09%7D%0A%0A%09%09return _generation %3C _longBuffer.length() %7C%7C%0A%09%09%09_limit.test(_shortBuffer.doubleMoments(), _longBuffer.doubleMoments());%0A%09%7D%0A%0A%09private static final class Buffer implements DoubleConsumer %7B%0A%09%09private final double%5B%5D _buffer;%0A%0A%09%09private int _next;%0A%0A%09%09Buffer(final int length) %7B%0A%09%09%09_buffer = new double%5Blength%5D;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public void accept(final double value) %7B%0A%09%09%09_buffer%5B_next++%5D = value;%0A%09%09%09if (_next == _buffer.length) %7B%0A%09%09%09%09_next = 0;%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09public int length() %7B%0A%09%09%09return _buffer.length;%0A%09%09%7D%0A%0A%09%09public DoubleMoments doubleMoments() %7B%0A%09%09%09final DoubleMomentStatistics statistics = new DoubleMomentStatistics();%0A%09%09%09for (int i = _buffer.length; --i %3E=0;) %7B%0A%09%09%09%09statistics.accept(_buffer%5Bi%5D);%0A%09%09%09%7D%0A%0A%09%09%09return DoubleMoments.of(statistics);%0A%09%09%7D%0A%09%7D
 %0A%0A%7D%0A

Implement 'FitnessConvergenceLimit' class.