es.udc.gii.common.eaf.algorithm.population
Class Population

java.lang.Object
  extended by es.udc.gii.common.eaf.algorithm.population.Population

public class Population
extends java.lang.Object

This class represents the list of individuals that will be used to solve the problem.

Since:
1.0.
Author:
Grupo Integrado de IngenierĂ­a (www.gii.udc.es)
See Also:
Individual

Field Summary
private  java.util.List<Individual> individuals
          A list of individuals.
private  int size
          The size of this population.
 
Constructor Summary
Population()
          Creates an instance of this class with an empty list of individuals.
Population(java.util.List<Individual> individuals)
          Creates an instance of this class with individuals as the list of individuals.
 
Method Summary
 void addIndividual(Individual individual)
          Adds an individual to the current list.
 void addIndividuals(java.util.List<Individual> individuals)
          Adds a list of individuals to the current list.
 void generate()
          Generates a new list of individuals.
 Individual getIndividual(int index)
          Returns the individial at position index in the list of individuals.
 java.util.List<Individual> getIndividuals()
          Returns the list of individuals.
 java.util.List<Individual> getIndividualsCopy()
          Returns a copy of the individuals' list.
 int getSize()
          Returns the size of the population.
 void modifyPopulationSize(int size)
          Increses or decreases the size of the population depending on the value of the parameter size.
 void removeIndividuals(java.util.List<Individual> individuals)
          Removes a list of individuals from the current list.
 void setDimension(int[] dimensions)
          Sets the dimensions of the chromosomes of all the individuals.
 void setIndividuals(java.util.List<Individual> individuals)
          Sets the list of individuals as the current list of individuals.
 void setSize(int size)
          Sets the size of the population.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

individuals

private java.util.List<Individual> individuals
A list of individuals.


size

private int size
The size of this population.

Constructor Detail

Population

public Population()
Creates an instance of this class with an empty list of individuals.


Population

public Population(java.util.List<Individual> individuals)
Creates an instance of this class with individuals as the list of individuals.

Parameters:
individuals - a list of individuals.
Method Detail

generate

public void generate()
Generates a new list of individuals.

See Also:
Individual.generate()

modifyPopulationSize

public void modifyPopulationSize(int size)
Increses or decreases the size of the population depending on the value of the parameter size. If it is necessary create new individuals, these individuals are also generate.

Parameters:
size - the new population size. If size is greater than current size, new individuals are added. If size is lower than current size, the last individuals are removed.

getSize

public int getSize()
Returns the size of the population.

Returns:
the size of the current population.

setSize

public void setSize(int size)
Sets the size of the population.

Parameters:
size - the new population size.

getIndividuals

public java.util.List<Individual> getIndividuals()
Returns the list of individuals.

Returns:
the list of individuals.

setIndividuals

public void setIndividuals(java.util.List<Individual> individuals)
Sets the list of individuals as the current list of individuals.

Parameters:
individuals - a new list of individuals.

getIndividual

public Individual getIndividual(int index)
Returns the individial at position index in the list of individuals.

Parameters:
index - the index of the desired individual.
Returns:
the individual at position index.

getIndividualsCopy

public java.util.List<Individual> getIndividualsCopy()
Returns a copy of the individuals' list.

Returns:
a copy of the individuals' list.

addIndividual

public void addIndividual(Individual individual)
Adds an individual to the current list.

Parameters:
individual - an individual to be added.

addIndividuals

public void addIndividuals(java.util.List<Individual> individuals)
Adds a list of individuals to the current list.

Parameters:
individuals - a list of individuals to be added.

removeIndividuals

public void removeIndividuals(java.util.List<Individual> individuals)
Removes a list of individuals from the current list.

Parameters:
individuals - a list of individuals to be removed.

setDimension

public void setDimension(int[] dimensions)
Sets the dimensions of the chromosomes of all the individuals.

Parameters:
dimensions - an array of dimensions.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object