@Test(expectedExceptions = CompletionException.class)
public void withEngineOutOfBounds() {

	// Problem definition.
	final Problem<Double, DoubleGene, Double> problem = Problem.of(
		x -> cos(0.5 + sin(x))*cos(x),
		Codecs.ofScalar(DoubleRange.of(0.0, 2.0*PI))
	);
	final Genotype<DoubleGene> gtf = Genotype.of(
		DoubleChromosome.of(0, 1),
		DoubleChromosome.of(1, 2),
		DoubleChromosome.of(2, 3),
		DoubleChromosome.of(3, 4)
	);
	// Define the GA engine.
	final Engine<DoubleGene, Double> engine = Engine
		.builder(gt -> gt.gene().doubleValue(), gtf)
		.selector(new RouletteWheelSelector<>())
		.alterers(
			PartialAlterer.of(new Mutator<DoubleGene, Double>(), 0, 2),
			PartialAlterer.of(new MeanAlterer<DoubleGene, Double>(), 3, 4),
			new GaussianMutator<>()
		)
		.build();
	engine.stream()
		.limit(100)
		.collect(EvolutionResult.toBestEvolutionResult());
}