001 package org.jaga.definitions;
002
003 /**
004 * Basis for all algorithms which perform selection for reproduction.
005 *
006 * <p><u>Project:</u> JAGA - Java API for Genetic Algorithms.</p>
007 *
008 * <p><u>Company:</u> University College London and JAGA.Org
009 * (<a href="http://www.jaga.org" target="_blank">http://www.jaga.org</a>).
010 * </p>
011 *
012 * <p><u>Copyright:</u> (c) 2004 by G. Paperin.<br/>
013 * This program is free software; you can redistribute it and/or modify
014 * it under the terms of the GNU General Public License as published by
015 * the Free Software Foundation, ONLY if you include a note of the original
016 * author(s) in any redistributed/modified copy.<br/>
017 * This program is distributed in the hope that it will be useful,
018 * but WITHOUT ANY WARRANTY; without even the implied warranty of
019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
020 * GNU General Public License for more details.<br/>
021 * You should have received a copy of the GNU General Public License
022 * along with this program; if not, write to the Free Software
023 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024 * or see http://www.gnu.org/licenses/gpl.html</p>
025 *
026 * @author Greg Paperin (greg@jaga.org)
027 *
028 * @version JAGA public release 1.0 beta
029 */
030
031 public interface SelectionAlgorithm {
032
033 /**
034 * Selects an individual from the specified population according to the fitness.
035 *
036 * @param population The population to select from. All individuals in the
037 * population should return a fitness object which is possible to cast to
038 * the class returned by <code>getApplicableFitnessClass</code>.
039 *
040 * @param age The current generation of the population.
041 *
042 * @param params Experiment parameters.
043 *
044 * @return A selected individual.
045 *
046 * @throws ClassCastException If the population specified contains
047 * individuals which return a fitness-object, which cannot be cast to the
048 * class returned by <code>getApplicableFitnessClass</code>.
049 */
050 public Individual select(Population population, int age,
051 GAParameterSet params) throws ClassCastException;
052
053 /**
054 * Selects a spacified number of individuals from the population according
055 * to their fitness.
056 *
057 * @param population The population to select from. All individuals in the
058 * population should return a fitness object which is possible to cast to
059 * the class returned by <code>getApplicableFitnessClass</code>.
060 *
061 * @param howMany The numbetr of individuals to select.
062 *
063 * @param age The current generation of the population.
064 *
065 * @param params Experiment parameters.
066 *
067 * @return An array of selected individuals.
068 *
069 * @throws ClassCastException If the population specified contains
070 * individuals which return a fitness-object, which cannot be cast to the
071 * class returned by <code>getApplicableFitnessClass</code>.
072 */
073 public Individual [] select(Population population, int howMany, int age,
074 GAParameterSet params) throws ClassCastException;
075
076 /**
077 * Gets the <code>Fitness</code>-class handles by this selector.
078 *
079 * @return A class, such that all individuals in the populations passed to
080 * the <code>select</code>-methods must have a fitness of that class or
081 * its subclass.
082 */
083 public Class getApplicableFitnessClass();
084
085 }