com.groovyj.jgprog
Class Population

java.lang.Object
  |
  +--com.groovyj.jgprog.Population
All Implemented Interfaces:
java.io.Serializable

public class Population
extends java.lang.Object
implements java.io.Serializable

Represents a population of individuals.

Copyright: Copyright (c) 2000 Robert Baruch. This code is released under the GNU General Public License (GPL).

Version:
$Id: Population.java,v 1.4 2000/10/12 15:22:55 groovyjava Exp $
Author:
Robert Baruch (jgprog@sourceforge.net)
See Also:
Serialized Form

Constructor Summary
Population(int size)
          Constructs a population of the given size, with empty individuals.
 
Method Summary
 void create(Type[] types, Type[][] argTypes, Function[][] nodeSets)
          Creates a population using the ramped half-and-half method.
 boolean execute_boolean(int n, int c)
           
 double execute_double(int n, int c)
           
 float execute_float(int n, int c)
           
 int execute_int(int n, int c)
           
 long execute_long(int n, int c)
           
 void execute_void(int n, int c)
           
 Individual getIndividual(int i)
          Gets a particular individual.
 int getSize()
          Gets the number of individuals in this population.
 void setIndividual(int i, Individual ind)
          Sets a particular individual.
 void sort(java.util.Comparator c)
          Sorts the population into "ascending" order using some criterion for "ascending".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Population

public Population(int size)
Constructs a population of the given size, with empty individuals.

Parameters:
size - the number of individuals in the population
Method Detail

create

public void create(Type[] types,
                   Type[][] argTypes,
                   Function[][] nodeSets)
Creates a population using the ramped half-and-half method.

Parameters:
random - the random number generator
maxdepth - the maximum depth of the initial individuals
types - the type of each chromosome, the length is the number of chromosomes
argTypes - the types of the arguments to each chromosome, must be an array of arrays, the first dimension of which is the number of chromosomes and the second dimension of which is the number of arguments to the chromosome.
nodeSets - the nodes which are allowed to be used by each chromosome, must be an array of arrays, the first dimension of which is the number of chromosomes and the second dimension of which is the number of nodes. Note that it is not necessary to include the arguments of a chromosome as terminals in the chromosome's node set. This is done automatically for you.
Since:
1.0

getSize

public int getSize()
Gets the number of individuals in this population.

Returns:
the number of individuals in this population
Since:
1.0

getIndividual

public Individual getIndividual(int i)
Gets a particular individual.

Parameters:
i - the individual number, 0 to population size-1.
Returns:
the individual
Since:
1.0

setIndividual

public void setIndividual(int i,
                          Individual ind)
Sets a particular individual.

Parameters:
i - the individual number, 0 to population size-1
ind - the individual
Since:
1.0

sort

public void sort(java.util.Comparator c)
Sorts the population into "ascending" order using some criterion for "ascending". A Comparator is given which will compare two individuals, and if one individual compares as lower than another individual, the first individual will appear in the population before the second individual.

Parameters:
c - the Comparator to use

execute_void

public void execute_void(int n,
                         int c)

execute_boolean

public boolean execute_boolean(int n,
                               int c)

execute_int

public int execute_int(int n,
                       int c)

execute_long

public long execute_long(int n,
                         int c)

execute_float

public float execute_float(int n,
                           int c)

execute_double

public double execute_double(int n,
                             int c)