Package madkit.simulation.activator
Class DateBasedDiscreteEventActivator<A extends AbstractAgent>
java.lang.Object
madkit.kernel.Activator<A>
madkit.simulation.activator.GenericBehaviorActivator<A>
madkit.simulation.activator.DateBasedDiscreteEventActivator<A>
- Type Parameters:
A
-
- All Implemented Interfaces:
Comparable<DateBasedDiscreteEventActivator<A>>
public class DateBasedDiscreteEventActivator<A extends AbstractAgent>
extends GenericBehaviorActivator<A>
implements Comparable<DateBasedDiscreteEventActivator<A>>
A behavior activator that is designed to work with 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.- Author:
- Fabien Michel
-
Constructor Summary
ConstructorsConstructorDescriptionDateBasedDiscreteEventActivator
(String community, String group, String role, String theBehaviorToActivate) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Called when a list of agents joins the corresponding group and role.void
Makes all the agents leave the corresponding role at once.int
Defines an ordering so that the scheduler can classify activators according to their date and priority.void
Triggers the corresponding behavior on all the agents which are at the CGR location defined by this activator.Gets the community to which this activator/probe is binded to.Returns a snapshot at moment t of the agents handling the group/role couplegetGroup()
Gets the group to which this activator/probe is binded to.Returns the next date at which this activator should be triggered.getRole()
Gets the role to which this activator/probe is binded to.Returns a ListIterator over the agents which is shuffledvoid
Called by the MaDKit kernel when the Activator or Probe is first added.void
Kills all the agents which are monitored.protected void
This method is automatically called when an agent leaves the corresponding group and role.protected void
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 triggeredint
size()
Returns the number of the agents handling the group/role coupletoString()
returns a string containing the CGR location and the number of monitored agents.Methods inherited from class madkit.simulation.activator.GenericBehaviorActivator
getBehaviorName
Methods inherited from class madkit.kernel.Activator
adding, execute, executeBehaviorOf, findMethodOn, findMethodOnFromArgsSample, getMadkitServiceExecutor, getPriority, getSimulationTime, isMulticoreModeOn, multicoreExecute, nbOfParallelTasks, useMulticore
-
Constructor Details
-
DateBasedDiscreteEventActivator
-
-
Method Details
-
compareTo
Defines an ordering so that the scheduler can classify activators according to their date and priority.- Specified by:
compareTo
in interfaceComparable<A extends AbstractAgent>
-
getNextActivationDate
Returns the next date at which this activator should be triggered.- Returns:
- next date at which this activator should be triggered.
-
setNextActivationDate
Sets the next date at which the activator will be triggered- Parameters:
nextActivationDate
- aLocalDateTime
which should be greater than the current simulation time
-
execute
Description copied from class:GenericBehaviorActivator
Triggers the corresponding behavior on all the agents which are at the CGR location defined by this activator.- Overrides:
execute
in classGenericBehaviorActivator<A extends AbstractAgent>
- See Also:
-
toString
returns a string containing the CGR location and the number of monitored agents.- Overrides:
toString
in classActivator<A extends AbstractAgent>
- Returns:
- a string representation of this tool.
-
getDefaultInterval
-
setDefaultInterval
-
getCommunity
Gets the community to which this activator/probe is binded to.- Returns:
- a string representing the community's name
-
getGroup
Gets the group to which this activator/probe is binded to.- Returns:
- a string representing the group's name
-
getRole
Gets the role to which this activator/probe is binded to.- Returns:
- a string representing the role's name
-
initialize
public void initialize()Called by the MaDKit kernel when the Activator or Probe is first added. Default behavior is:adding(getCurrentAgentsList());
-
adding
Called when a list of agents joins the corresponding group and role. This method is automatically called by the MaDKit kernel when agents enter a role due to the use ofAbstractAgent.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); } }
- Parameters:
agents
- the list of agents which have been added to this group/role at once.
-
removing
This method is automatically called when a list of agents has leaved the corresponding group and role. This method is empty by default. Override this method when you want to do some initialization on the agents that enter the group/role. Default implementation is:protected void removing(final List<A> agents) { for (A agent : agents) { removing(agent); } }
- Parameters:
agents
- the list of agents which have been removed from this group/role
-
removing
This method is automatically called when an agent leaves the corresponding group and role. This method is empty by default. Override this method when you want to do some work when an agent leaves the group/role. Note that the role is still handled by the agent when invoked.- Parameters:
agent
- the agent which is being removed from this group/role
-
size
public int size()Returns the number of the agents handling the group/role couple- Returns:
- the number of the agents that handle the group/role couple
-
getCurrentAgentsList
Returns a snapshot at moment t of the agents handling the group/role couple- Returns:
- a list view (a snapshot at moment t) of the agents that handle the group/role couple (in proper sequence)
- Since:
- MaDKit 3.0
-
getShuffledList
Returns a ListIterator over the agents which is shuffled- Returns:
- a ListIterator which has been previously shuffled
- Since:
- MaDKit 3.0
-
killAgents
public void killAgents()Kills all the agents which are monitored. -
allAgentsLeaveRole
public void allAgentsLeaveRole()Makes all the agents leave the corresponding role at once.
-