de.cesr.sesamgim.init.group
Class GGroupOrganiser<AgentType extends GimMilieuAgent<?>>

java.lang.Object
  extended by de.cesr.sesamgim.init.group.GGroupOrganiser<AgentType>
All Implemented Interfaces:
GimGroupInitialiser<AgentType>, repast.simphony.context.ContextListener<AgentType>

public class GGroupOrganiser<AgentType extends GimMilieuAgent<?>>
extends Object
implements GimGroupInitialiser<AgentType>, repast.simphony.context.ContextListener<AgentType>

SesamGIM - Geographical Initialisation for Milieu Agents


Field Summary
protected  List<GimGroupContext<AgentType>> groupBasket
           
protected  GimGroupInitialiseService<AgentType> groupIS
           
protected  int maxGroupSize
           
protected  int[] milieuSums
           
protected  cern.jet.random.Uniform uniformDist
           
 
Constructor Summary
GGroupOrganiser(int[] milieuSums, GimGroupInitialiseService<AgentType> groupIS)
          Init a GroupOrganizer for a certain market cell.
 
Method Summary
 void eventOccured(repast.simphony.context.ContextEvent<AgentType> ev)
          Observe Group Contexts to adapt group basket when their size reaches BasicPa.NEIGHBOURHOOD_SIZE:
 List<GimGroupContext<AgentType>> getGroupBasket()
           
 GimGroupContext<AgentType> getGroupContext(AgentType agent)
          Get the group context the next agent should be placed within.
 Collection<GimGroupContext<AgentType>> getInitialisedGroupContexts()
          Returns the collection of initialised group contexts.
 int getNumberOfInitialisedGroupContext()
          Returns the number of group contexts that have been initialised at the call of GimGroupInitialiser#initGroupContexts(GimMarketCellContext).
 int getNumNeighbourhoods()
           
 Collection<GimGroupContext<AgentType>> initGroupContexts(GimUpdatableContext<AgentType> uc)
          Initialises the group basket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxGroupSize

protected int maxGroupSize

groupBasket

protected List<GimGroupContext<AgentType extends GimMilieuAgent<?>>> groupBasket

groupIS

protected GimGroupInitialiseService<AgentType extends GimMilieuAgent<?>> groupIS

milieuSums

protected int[] milieuSums

uniformDist

protected cern.jet.random.Uniform uniformDist
Constructor Detail

GGroupOrganiser

public GGroupOrganiser(int[] milieuSums,
                       GimGroupInitialiseService<AgentType> groupIS)
Init a GroupOrganizer for a certain market cell.

Parameters:
milieuSums - sums of agents (not represented population) per milieu
area -
Method Detail

initGroupContexts

public Collection<GimGroupContext<AgentType>> initGroupContexts(GimUpdatableContext<AgentType> uc)
Initialises the group basket.

Specified by:
initGroupContexts in interface GimGroupInitialiser<AgentType extends GimMilieuAgent<?>>
Parameters:
uc - market cell context
See Also:
de.cesr.sesamgim.init.group.GimGroupInitialiser#initGroupContexts(de.cesr.sesamgim.context.GimMarketCellContext)

getGroupContext

public GimGroupContext<AgentType> getGroupContext(AgentType agent)
Get the group context the next agent should be placed within. Registering this group organiser at each GGroupContext allows to be informed of every added agent and to remove the according group context from the basket ensures that no context is over-filled.

Specified by:
getGroupContext in interface GimGroupInitialiser<AgentType extends GimMilieuAgent<?>>
Parameters:
agentInitUniform -
Returns:
the group context the next agent should be placed within.

eventOccured

public void eventOccured(repast.simphony.context.ContextEvent<AgentType> ev)
Observe Group Contexts to adapt group basket when their size reaches BasicPa.NEIGHBOURHOOD_SIZE:

Specified by:
eventOccured in interface repast.simphony.context.ContextListener<AgentType extends GimMilieuAgent<?>>
See Also:
ContextListener.eventOccured(repast.simphony.context.ContextEvent)

getNumNeighbourhoods

public int getNumNeighbourhoods()
Returns:
number of group contexts

getGroupBasket

public List<GimGroupContext<AgentType>> getGroupBasket()
Returns:
group basket

getNumberOfInitialisedGroupContext

public int getNumberOfInitialisedGroupContext()
Description copied from interface: GimGroupInitialiser
Returns the number of group contexts that have been initialised at the call of GimGroupInitialiser#initGroupContexts(GimMarketCellContext). Return 0 if groups contexts have not been initialised.

Specified by:
getNumberOfInitialisedGroupContext in interface GimGroupInitialiser<AgentType extends GimMilieuAgent<?>>
Returns:
See Also:
GimGroupInitialiser.getNumberOfInitialisedGroupContext()

getInitialisedGroupContexts

public Collection<GimGroupContext<AgentType>> getInitialisedGroupContexts()
Description copied from interface: GimGroupInitialiser
Returns the collection of initialised group contexts. Return null if group contexts have not been initialised.

Specified by:
getInitialisedGroupContexts in interface GimGroupInitialiser<AgentType extends GimMilieuAgent<?>>
Returns:
collection of group contexts.
See Also:
GimGroupInitialiser.getInitialisedGroupContexts()