<commit_before>/*
 * Java Genetic Algorithm Library (@__identifier__@).
 * Copyright (c) @__year__@ <NAME>
 *
 * 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:
 *    <NAME> (<EMAIL>)
 */
package io.jenetics.engine;

import static java.util.Objects.requireNonNull;

import java.util.function.Function;

import io.jenetics.Gene;
import io.jenetics.Genotype;

/**
 * This interface describes a <i>problem</i> which can be solved by the GA
 * evolution {@code Engine}. It connects the actual {@link #fitness()} function
 * and the needed {@link #codec()}.
 *
 * <pre>{@code
 * final Problem<ISeq<BitGene>, BitGene, Integer> counting = Problem.of(
 *     // Native fitness function
 *     genes -> (int)genes.stream()
 *         .filter(BitGene::getBit)
 *         .count(),
 *     // Problem encoding
 *     Codec.of(
 *         Genotype.of(BitChromosome.of(100)),
 *         gt -> gt.getChromosome().toSeq()
 *     )
 * );
 * }</pre>
 *
 * The example above shows the Ones-Counting problem definition.
 *
 * @see Codec
 * @see Engine
 *
 * @param <T> the (<i>native</i>) argument type of the problem fitness function
 * @param <G> the gene type the evolution engine is working with
 * @param <C> the result type of the fitness function
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version 4.1
 * @since 3.4
 */
public interface Problem<
	T,
	G extends Gene<?, G>,
	C extends Comparable<? super C>
> {

	/**
	 * Return the fitness function of the <i>problem</i> in the <i>native</i>
	 * problem domain.
	 *
	 * @return the fitness function
	 */
	public Function<T, C> fitness();

	/**
	 * Return the codec, which translates the types of the problem domain into
	 * types, which can be understand by the evolution {@code Engine}.
	 *<commit_msg>Update version number.<commit_after>/*
 * Java Genetic Algorithm Library (@__identifier__@).
 * Copyright (c) @__year__@ <NAME>
 *
 * 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:
 *    <NAME> (<EMAIL>)
 */
package io.jenetics.engine;

import static java.util.Objects.requireNonNull;

import java.util.function.Function;

import io.jenetics.Gene;
import io.jenetics.Genotype;

/**
 * This interface describes a <i>problem</i> which can be solved by the GA
 * evolution {@code Engine}. It connects the actual {@link #fitness()} function
 * and the needed {@link #codec()}.
 *
 * <pre>{@code
 * final Problem<ISeq<BitGene>, BitGene, Integer> counting = Problem.of(
 *     // Native fitness function
 *     genes -> (int)genes.stream()
 *         .filter(BitGene::getBit)
 *         .count(),
 *     // Problem encoding
 *     Codec.of(
 *         Genotype.of(BitChromosome.of(100)),
 *         gt -> gt.getChromosome().toSeq()
 *     )
 * );
 * }</pre>
 *
 * The example above shows the Ones-Counting problem definition.
 *
 * @see Codec
 * @see Engine
 *
 * @param <T> the (<i>native</i>) argument type of the problem fitness function
 * @param <G> the gene type the evolution engine is working with
 * @param <C> the result type of the fitness function
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version 4.2
 * @since 3.4
 */
public interface Problem<
	T,
	G extends Gene<?, G>,
	C extends Comparable<? super C>
> {

	/**
	 * Return the fitness function of the <i>problem</i> in the <i>native</i>
	 * problem domain.
	 *
	 * @return the fitness function
	 */
	public Function<T, C> fitness();

	/**
	 * Return the codec, which translates the types of the problem domain into
	 * types, which can be understand by the evolution {@code Engine}.
	 *
{'fraction_non_alphanumeric': 0.12601715416758302, 'fraction_numerical': 0.004838354959313834, 'mean_word_length': 3.3479923518164436, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6435668', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1324, 'n_words': 512}