All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.jenetics.Gene Maven / Gradle / Ivy

There is a newer version: 8.1.0
Show newest version
/*
 * Java Genetic Algorithm Library (jenetics-4.0.0).
 * Copyright (c) 2007-2017 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 ([email protected])
 */
package io.jenetics;

import io.jenetics.util.Factory;
import io.jenetics.util.Verifiable;

/**
 * Genes are the atoms of the Jenetics library. They contain the actual
 * information (alleles) of the encoded solution. All implementations of the
 * this interface are final, immutable and can be only created via static
 * factory methods which have the name {@code of}. When extending the library
 * with own {@code Gene} implementations, it is recommended to also implement it
 * as value objects.
 *
 * @see Value object
 * @see Chromosome
 *
 * @param  the Allele type
 *         of this gene.
 *
 * @author Franz Wilhelmstötter
 * @since 1.0
 * @version 3.1
 */
public interface Gene>
	extends
		Factory,
		Verifiable
{

	/**
	 * Return the allele of this gene.
	 *
	 * @return the allele of this gene.
	 */
	public A getAllele();

	/**
	 * Return a new, random gene with the same type and with the same constraints
	 * than this gene. For all genes returned by this method holds
	 * {@code gene.getClass() == gene.newInstance().getClass()}. Implementations
	 * of this method has to use the {@link java.util.Random} object which can
	 * be fetched from the {@link io.jenetics.util.RandomRegistry}.
	 */
	@Override
	public G newInstance();

	/**
	 * Create a new gene from the given {@code value} and the gene context.
	 *
	 * @since 2.0
	 * @param value the value of the new gene.
	 * @return a new gene with the given value.
	 */
	public G newInstance(final A value);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy