@Test public void example() { final Codec<LocalDate, LongGene> dateCodec1 = Codec.of( Genotype.of(LongChromosome.of(0, 10_000)), gt -> LocalDate.ofEpochDay(gt.gene().longValue()) ); final Codec<LocalDate, LongGene> dateCodec2 = Codec.of( Genotype.of(LongChromosome.of(1_000_000, 10_000_000)), gt -> LocalDate.ofEpochDay(gt.gene().longValue()) ); final Codec<Duration, LongGene> durationCodec = Codec.of( dateCodec1, dateCodec2, (d1, d2) -> Duration.ofDays(d2.toEpochDay() - d1.toEpochDay()) ); final Engine<LongGene, Long> engine = Engine .builder(Duration::toMillis, durationCodec) .build(); final Phenotype<LongGene, Long> pt = engine.stream() .limit(100) .collect(EvolutionResult.toBestPhenotype()); final Duration duration = durationCodec.decoder() .apply(pt.genotype()); }
@Override public Function<Genotype<G>, T> decoder() { return gt -> _decoder.apply(groups(gt)); }
CompositeCodec implements Codec<T, G> { @Override public Function<Genotype<G>, T> decoder() { return gt -> _decoder.apply(groups(gt)); } }
CompositeCodec implements Codec<T, G> { @Override public Function<Genotype<G>, T> decoder() { return gt -> _decoder.apply(groups(gt)); } CompositeCodec(
		final ISeq<? extends Codec<?, G>> codecs,
		final Function<? super Object[], ? extends T> decoder
	); }
CompositeCodec implements Codec<T, G> { @Override public Function<Genotype<G>, T> decoder() { return gt -> _decoder.apply(groups(gt)); } CompositeCodec(
		final ISeq<? extends Codec<?, G>> codecs,
		final Function<? super Object[], ? extends T> decoder
	); @Override Factory<Genotype<G>> encoding(); @Override Function<Genotype<G>, T> decoder(); @Override String toString(); }
CompositeCodec implements Codec<T, G> { @Override public Function<Genotype<G>, T> decoder() { return gt -> _decoder.apply(groups(gt)); } CompositeCodec(
		final ISeq<? extends Codec<?, G>> codecs,
		final Function<? super Object[], ? extends T> decoder
	); @Override Factory<Genotype<G>> encoding(); @Override Function<Genotype<G>, T> decoder(); @Override String toString();  }