net.sourceforge.jabm.agent
Class AgentList

java.lang.Object
  extended by net.sourceforge.jabm.agent.AgentList
All Implemented Interfaces:
java.io.Serializable

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

A list of agents.

See Also:
Serialized Form
 

Field Summary
protected  org.springframework.beans.factory.ObjectFactory<Agent> agentFactory
           
protected  java.util.List<Agent> agents
          The agents comprising this list.
static java.util.Comparator<Agent> ascendingFitnessComparator
           
static java.util.Comparator<Agent> descendingFitnessComparator
           
protected  int size
           
 
Constructor Summary
AgentList()
          Create an empty AgentList.
AgentList(Agent agent)
          Create a list comprising a single agent.
AgentList(java.util.ArrayList<AgentList> lists)
          Create an AgentList by merging a list of AgentList objects.
AgentList(java.util.Collection<Agent> agents)
          Create an AgentList from the supplied Collection of agents.
AgentList(int size)
          Create an empty AgentList with the specified capacity.
AgentList(int size, org.springframework.beans.factory.ObjectFactory<Agent> agentFactory)
          Create an AgentList by manufacturing objects from the supplied factory.
 
Method Summary
 void add(Agent agent)
           
 boolean addAll(java.util.Collection<? extends Agent> c)
           
 Agent get(int i)
           
 org.springframework.beans.factory.ObjectFactory<Agent> getAgentFactory()
           
 java.util.List<Agent> getAgents()
           
 double getMaxFitness()
           
 int getSize()
           
 double getTotalFitness()
           
 java.util.Iterator<Agent> iterator()
           
 void populateFromFactory()
           
 Agent remove(int index)
           
 void set(int i, Agent agent)
           
 void setAgentFactory(org.springframework.beans.factory.ObjectFactory<Agent> agentFactory)
           
 void setAgents(java.util.List<Agent> agents)
           
 void setSize(int size)
           
 void shuffle(cern.jet.random.engine.RandomEngine prng)
          Randomly sort the agents in this list.
 int size()
           
 void sortAgents(java.util.Comparator<Agent> comparator)
           
 void sortAgentsByFitness()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

agents

protected java.util.List<Agent> agents
The agents comprising this list.


size

protected int size

agentFactory

protected org.springframework.beans.factory.ObjectFactory<Agent> agentFactory

ascendingFitnessComparator

public static final java.util.Comparator<Agent> ascendingFitnessComparator

descendingFitnessComparator

public static final java.util.Comparator<Agent> descendingFitnessComparator
Constructor Detail

AgentList

public AgentList(int size)
Create an empty AgentList with the specified capacity.

Parameters:
size -

AgentList

public AgentList()
Create an empty AgentList.


AgentList

public AgentList(Agent agent)
Create a list comprising a single agent.

Parameters:
agent -

AgentList

public AgentList(java.util.Collection<Agent> agents)
Create an AgentList from the supplied Collection of agents.

Parameters:
agents -

AgentList

public AgentList(java.util.ArrayList<AgentList> lists)
Create an AgentList by merging a list of AgentList objects.

Parameters:
lists - An ArrayList holding an array of AgentList objects.

AgentList

public AgentList(int size,
                 org.springframework.beans.factory.ObjectFactory<Agent> agentFactory)
Create an AgentList by manufacturing objects from the supplied factory.

Parameters:
size - The number of agents to manufacture.
agentFactory - The factory used to manufacture agents.
Method Detail

populateFromFactory

public void populateFromFactory()

get

public Agent get(int i)

set

public void set(int i,
                Agent agent)

add

public void add(Agent agent)

addAll

public boolean addAll(java.util.Collection<? extends Agent> c)

remove

public Agent remove(int index)

getAgents

public java.util.List<Agent> getAgents()

iterator

public java.util.Iterator<Agent> iterator()

size

public int size()

setAgents

public void setAgents(java.util.List<Agent> agents)

getTotalFitness

public double getTotalFitness()

getMaxFitness

public double getMaxFitness()

shuffle

public void shuffle(cern.jet.random.engine.RandomEngine prng)
Randomly sort the agents in this list.

Parameters:
prng -

sortAgentsByFitness

public void sortAgentsByFitness()

sortAgents

public void sortAgents(java.util.Comparator<Agent> comparator)

getSize

public int getSize()

setSize

public void setSize(int size)

getAgentFactory

public org.springframework.beans.factory.ObjectFactory<Agent> getAgentFactory()

setAgentFactory

public void setAgentFactory(org.springframework.beans.factory.ObjectFactory<Agent> agentFactory)