001    package org.jaga.definitions;
002    
003    /**
004     * 
005     * Basis for all classes which implement the fitness of an individual.
006     * Every individual has a property of this type (its subtype), which describes
007     * how fit that indivudual is compared to others.
008     * It must be possible to compare two fitness-objects. However, the fitnesses
009     * of all indivuduals in the population are not nessecerily all comparable:
010     * for example, it is possible that the fitness is determined in an N-Tournament
011     * selection process. According to the nature of that tournament the fitness
012     * might not be absolut, i.e. fitness doen not have to be transitive:
013     * A < B and B < C does not always mean A <. In particular, this
014     * applies to fitnesses of game strategies.
015     * 
016     * <p><u>Project:</u> JAGA - Java API for Genetic Algorithms.</p>
017     * 
018     * <p><u>Company:</u> University College London and JAGA.Org
019     *    (<a href="http://www.jaga.org" target="_blank">http://www.jaga.org</a>).
020     * </p>
021     * 
022     * <p><u>Copyright:</u> (c) 2004 by G. Paperin.<br/>
023     *    This program is free software; you can redistribute it and/or modify
024     *    it under the terms of the GNU General Public License as published by
025     *    the Free Software Foundation, ONLY if you include a note of the original
026     *    author(s) in any redistributed/modified copy.<br/>
027     *    This program is distributed in the hope that it will be useful,
028     *    but WITHOUT ANY WARRANTY; without even the implied warranty of
029     *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
030     *    GNU General Public License for more details.<br/>
031     *    You should have received a copy of the GNU General Public License
032     *    along with this program; if not, write to the Free Software
033     *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
034     *    or see http://www.gnu.org/licenses/gpl.html</p>
035     * 
036     * @author Greg Paperin (greg@jaga.org)
037     * 
038     * @version JAGA public release 1.0 Beta
039     */
040    public interface Fitness {
041            
042            /**
043             * Compares this fitness to the specified fitness.
044             * 
045             * @param fitness - another fitness object.
046             * @return true, if this fitness is "fitter" then the specified,
047             * false otherwise.
048             * @throws ClassCastException if these types of fitness are not comparable.
049             */
050            public boolean isBetter(Fitness fitness) throws ClassCastException;
051            
052            /**
053             * Compares this fitness to the specified fitness.
054             * 
055             * @param fitness - another fitness object.
056             * @return true, if this fitness is "less fit" then the specified,
057             * false otherwise.
058             * @throws ClassCastException if these types of fitness are not comparable.
059             */
060            public boolean isWorse(Fitness fitness) throws ClassCastException;
061            
062    }