eaLib API Docs
Last Modified : January 7 2002

mss.ea.core
Class AbstractPopulation

java.lang.Object
  |
  +--mss.ea.core.GeneticOperator
        |
        +--mss.ea.core.AbstractPopulation
All Implemented Interfaces:
java.util.EventListener, IndividualGate, NotificationListener
Direct Known Subclasses:
GenericPopulation, SortedPopulation

public abstract class AbstractPopulation
extends GeneticOperator
implements IndividualGate, NotificationListener

Abstract base class for a population. This class provides some common methods for a population. Most of the implemented methods should be overloaded due to performance reasons.

Since:
0.1
Version:
$Revision: 1.11 $ $Date: 2001/12/18 10:04:11 $
Author:
Andreas Rummler

Field Summary
protected  IndividualFilter filter
          Individual filter for insertion of individuals into this population.
protected  LongCounter gc
          Generation counter.
 
Fields inherited from class mss.ea.core.GeneticOperator
description, ID, name
 
Constructor Summary
AbstractPopulation()
          Default constructor.
AbstractPopulation(IndividualFilter filt)
          Constructor with individual filter.
 
Method Summary
 void add(java.util.Collection ic)
          Adds a collection of individuals to this population.
abstract  void add(Individual i)
          Adds an individual.
 void add(Individual[] ia)
          Adds an array with individuals to this population.
 void add(IndividualStream is)
          Adds a stream of individuals to this population.
abstract  Individual get(int i)
          Gets the individual at a particular index.
 LongCounter getCounter()
          Gets the generation counter.
 IndividualFilter getFilter()
          Gets the reinsertion filter.
 IndividualStream getStream()
          Deprecated. replaced by toStream()
 void notificationSignal()
          Cycle notification.
abstract  void remove(int i)
          Removes an individual from the population.
 void remove(int lowerIndex, int upperIndex)
          Removes a range of individuals.
 void removeAll()
          Removes all individuals.
abstract  void replace(Individual i, int index)
          Replaces an individual at a particular position.
 void setFilter(IndividualFilter filter)
          Sets a new reinsertion operator.
abstract  int size()
          Gets the current size of the population.
 Individual[] toArray()
          Gets a copy of the internal buffer with all individuals.
 java.util.Collection toCollection()
          Gets a all individuals of the population contained in an arraylist.
 IndividualStream toStream()
          Returns all individuals as an array stream.
 
Methods inherited from class mss.ea.core.GeneticOperator
getDescription, getID, getName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

gc

protected LongCounter gc
Generation counter. This counter contains the current generation number. The counter is incremented everytime the add( IndividualStream ) method is called.

filter

protected IndividualFilter filter
Individual filter for insertion of individuals into this population.
Constructor Detail

AbstractPopulation

public AbstractPopulation()
Default constructor. Only initializes the internal generation counter.

AbstractPopulation

public AbstractPopulation(IndividualFilter filt)
Constructor with individual filter. The filter is used to control the insertion of individual into this population.
Parameters:
filt - individual filter for this population
Method Detail

notificationSignal

public void notificationSignal()
Cycle notification. This simply increments the internal generation counter on the given signal.
Specified by:
notificationSignal in interface NotificationListener

size

public abstract int size()
Gets the current size of the population.
Specified by:
size in interface IndividualGate
Returns:
population size

add

public abstract void add(Individual i)
Adds an individual. This method must be implemented by the subclasses and should make use of the filter.
Specified by:
add in interface IndividualGate
Parameters:
i - individual to add

add

public void add(Individual[] ia)
Adds an array with individuals to this population.
Specified by:
add in interface IndividualGate
Parameters:
ia - array with individuals

add

public void add(java.util.Collection ic)
Adds a collection of individuals to this population.
Parameters:
ic - collection with individuals

add

public void add(IndividualStream is)
Adds a stream of individuals to this population. This method makes use of the individual filter. If a filter is present the stream is filtered before it is inserted into the population.
Specified by:
add in interface IndividualGate
Parameters:
is - stream with individuals

get

public abstract Individual get(int i)
Gets the individual at a particular index. Attention : the first individual has the index 0, but the rank 1 !!!
Specified by:
get in interface IndividualGate
Parameters:
i - position of the individual
Returns:
individual at given position

toArray

public Individual[] toArray()
Gets a copy of the internal buffer with all individuals.
Specified by:
toArray in interface IndividualGate
Returns:
all individuals of the population as an array

toCollection

public java.util.Collection toCollection()
Gets a all individuals of the population contained in an arraylist.
Returns:
all individuals contained in an arraylist

getStream

public IndividualStream getStream()
Deprecated. replaced by toStream()

Returns all individuals as an array stream.
Specified by:
getStream in interface IndividualGate
Returns:
individuals of this population in an array stream.

toStream

public IndividualStream toStream()
Returns all individuals as an array stream.
Specified by:
toStream in interface IndividualGate
Returns:
individuals of this population in an array stream.

replace

public abstract void replace(Individual i,
                             int index)
Replaces an individual at a particular position.
Parameters:
i - new individual
index - position of the individual to replace

remove

public abstract void remove(int i)
Removes an individual from the population.
Specified by:
remove in interface IndividualGate
Parameters:
i - position of the individual

remove

public void remove(int lowerIndex,
                   int upperIndex)
Removes a range of individuals. The range reaches from lowerIndex (inclusive) to upperIndex (exclusive).
Specified by:
remove in interface IndividualGate
Parameters:
lowerIndex - lower bound
upperIndex - upper bound

removeAll

public void removeAll()
Removes all individuals.
Specified by:
removeAll in interface IndividualGate

getCounter

public LongCounter getCounter()
Gets the generation counter.
Returns:
generation counter of this population

setFilter

public void setFilter(IndividualFilter filter)
Sets a new reinsertion operator.
Parameters:
filter - new reinsertion operator

getFilter

public IndividualFilter getFilter()
Gets the reinsertion filter.
Returns:
current reinsertion filter

eaLib API Docs
Last Modified : January 7 2002

Copyright © 2000-2001 Technical University of Ilmenau, Department ESS