A
- public class DateBasedDiscreteEventActivator<A extends AbstractAgent> extends GenericBehaviorActivator<A> implements Comparable<DateBasedDiscreteEventActivator<A>>
DateBasedDiscreteEventScheduler
,
that is following a discrete-event simulation scheme.
This activator activates all the agents of the corresponding CGR for each specific date for
which it is activated.
It encapsulates an activation date which is coded using a LocalDateTime
object.Constructor and Description |
---|
DateBasedDiscreteEventActivator(String community,
String group,
String role,
String theBehaviorToActivate) |
Modifier and Type | Method and Description |
---|---|
protected void |
adding(List<A> agents)
Called when a list of agents joins the corresponding group and role.
|
void |
allAgentsLeaveRole()
Makes all the agents leave the corresponding role at once.
|
int |
compareTo(DateBasedDiscreteEventActivator<A> o)
Defines an ordering so that the scheduler can classify activators according to their date and priority.
|
void |
execute(List<A> agents,
Object... args)
Triggers the corresponding behavior on all the agents which are at the CGR location defined by this activator.
|
String |
getCommunity()
Gets the community to which this activator/probe is binded to.
|
List<A> |
getCurrentAgentsList()
Returns a snapshot at moment t of the agents handling the group/role couple
|
Duration |
getDefaultInterval() |
String |
getGroup()
Gets the group to which this activator/probe is binded to.
|
LocalDateTime |
getNextActivationDate()
Returns the next date at which this activator should be triggered.
|
String |
getRole()
Gets the role to which this activator/probe is binded to.
|
List<A> |
getShuffledList()
Returns a ListIterator over the agents which is shuffled
|
void |
initialize()
Called by the MaDKit kernel when the Activator or Probe is first added.
|
void |
killAgents()
Kills all the agents which are monitored.
|
protected void |
removing(A agent)
This method is automatically called when an agent leaves the corresponding group and role.
|
protected void |
removing(List<A> agents)
This method is automatically called when a list of agents has leaved the corresponding group and role.
|
void |
setDefaultInterval(Duration defaultInterval) |
void |
setNextActivationDate(LocalDateTime nextActivationDate)
Sets the next date at which the activator will be triggered
|
int |
size()
Returns the number of the agents handling the group/role couple
|
String |
toString()
returns a string containing the CGR location and the number of monitored agents.
|
getBehaviorName
adding, execute, executeBehaviorOf, findMethodOn, findMethodOnFromArgsSample, getMadkitServiceExecutor, getPriority, getSimulationTime, isMulticoreModeOn, multicoreExecute, nbOfParallelTasks, useMulticore
public int compareTo(DateBasedDiscreteEventActivator<A> o)
compareTo
in interface Comparable<DateBasedDiscreteEventActivator<A extends AbstractAgent>>
public LocalDateTime getNextActivationDate()
public void setNextActivationDate(LocalDateTime nextActivationDate)
nextActivationDate
- a LocalDateTime
which should be greater
than the current simulation timepublic void execute(List<A> agents, Object... args)
GenericBehaviorActivator
execute
in class GenericBehaviorActivator<A extends AbstractAgent>
Activator.execute(List, Object...)
public String toString()
toString
in class Activator<A extends AbstractAgent>
public Duration getDefaultInterval()
public void setDefaultInterval(Duration defaultInterval)
public String getCommunity()
public String getGroup()
public String getRole()
public void initialize()
adding(getCurrentAgentsList());
protected void adding(List<A> agents)
AbstractAgent.launchAgentBucket(String, int, String...)
. Override this method when you want to do some
initialization on the agents that enter the group/role. Default implementation is:
protected void adding(final List<A> agents) { for (A agent : agents) { adding(agent); } }
agents
- the list of agents which have been added to this group/role at once.protected void removing(List<A> agents)
protected void removing(final List<A> agents) { for (A agent : agents) { removing(agent); } }
agents
- the list of agents which have been removed from this group/roleprotected void removing(A agent)
agent
- the agent which is being removed from this group/rolepublic int size()
public List<A> getCurrentAgentsList()
public List<A> getShuffledList()
public void killAgents()
public void allAgentsLeaveRole()
Fabien Michel, Olivier Gutknecht, Jacques Ferber - February 17 2020