001 package org.jaga.definitions;
002
003
004
005 /**
006 * Basis for all populations.
007 *
008 * <p><u>Project:</u> JAGA - Java API for Genetic Algorithms.</p>
009 *
010 * <p><u>Company:</u> University College London and JAGA.Org
011 * (<a href="http://www.jaga.org" target="_blank">http://www.jaga.org</a>).
012 * </p>
013 *
014 * <p><u>Copyright:</u> (c) 2004 by G. Paperin.<br/>
015 * This program is free software; you can redistribute it and/or modify
016 * it under the terms of the GNU General Public License as published by
017 * the Free Software Foundation, ONLY if you include a note of the original
018 * author(s) in any redistributed/modified copy.<br/>
019 * This program is distributed in the hope that it will be useful,
020 * but WITHOUT ANY WARRANTY; without even the implied warranty of
021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
022 * GNU General Public License for more details.<br/>
023 * You should have received a copy of the GNU General Public License
024 * along with this program; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
026 * or see http://www.gnu.org/licenses/gpl.html</p>
027 *
028 * @author Greg Paperin (greg@jaga.org)
029 *
030 * @version JAGA public release 1.0 beta
031 */
032
033 public interface Population {
034
035 /**
036 * Gets the size of the population.
037 *
038 * @return The number of individuals in the population.
039 */
040 public int getSize();
041
042 /**
043 * Adds a list of individuals to the population.
044 *
045 * @param individuals An array of individuals which should be added to the#
046 * population.
047 */
048 public void addAll(Individual [] individuals);
049
050 /**
051 * Adds a specified individual to the population.
052 *
053 * @param individual To add to the population.
054 */
055 public void add(Individual individual);
056
057 /**
058 * Gets an array of all individuals in the population.
059 *
060 * @return An array containing all individuals in the population.
061 */
062 public Individual [] getAllMembers();
063
064 /**
065 * Gets an individual at the specifies index from the population.<br/>
066 * If this population does not support an ordering, this method may
067 * throw an <code>UnsupportedOperationException</code>.
068 *
069 * @param index The index of the population member to return.
070 *
071 * @return The member of the mopulation at the specified index.
072 *
073 * @throws ArrayIndexOutOfBoundsException If index is invalid.
074 */
075 public Individual getMember(int index) throws ArrayIndexOutOfBoundsException;
076
077 }