Class DateBasedDiscreteEventActivator
java.lang.Object
madkit.kernel.Activator
madkit.simulation.scheduler.MethodActivator
madkit.simulation.scheduler.DateBasedDiscreteEventActivator
- All Implemented Interfaces:
Comparable<Activator>
- Direct Known Subclasses:
DiscreteEventAgentsActivator
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.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDateBasedDiscreteEventActivator
(String group, String role, String theBehaviorToActivate) Constructs a new DateBasedDiscreteEventActivator with the specified group, role, and behavior to activate. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
Executes the behavior of the activator and updates the next activation date.Returns a snapshot at moment t of the agents handling the group/role coupleGets the community to which this activator/probe is binded to.Returns the current simulation time.Returns the default interval between activations.getGroup()
Gets the group to which this activator/probe is binded to.getName()
Gets the name.Returns the next date at which this activator should be triggered.getRole()
Gets the role to which this activator/probe is binded to.Returns the scheduler associated with this activator.boolean
isEmpty()
Checks if there is no agent in the group/role couplevoid
Kills all the agents which are monitored.protected void
Automatically called when an agent joins the corresponding group and role.protected void
onRemoving
(Agent agent) Automatically called when an agent leaves the corresponding group and role.void
setDefaultInterval
(Duration defaultInterval) Sets the default interval between activations.void
setNextActivationDate
(LocalDateTime nextActivationDate) Sets the next date at which the activator will be triggered.int
size()
Returns the number of targeted agents.toString()
Returns a string representation of the activator, including the next activation date.Methods inherited from class madkit.simulation.scheduler.MethodActivator
execute, executeInParallel, getMethod, isParallelMode, isShufflingMode, setParallelMode, setShufflingMode
Methods inherited from class madkit.kernel.Activator
executeBehaviorOf, getPriority, getSimuTimer, setPriority
-
Constructor Details
-
DateBasedDiscreteEventActivator
Constructs a new DateBasedDiscreteEventActivator with the specified group, role, and behavior to activate.- Parameters:
group
- the group of the agentsrole
- the role of the agentstheBehaviorToActivate
- the behavior to activate
-
-
Method Details
-
getCurrentTime
Returns the current simulation time.- Returns:
- the current simulation time
-
compareTo
Defines an ordering so that the scheduler can classify activators according to their date and priority.- Specified by:
compareTo
in interfaceComparable<Activator>
- Overrides:
compareTo
in classActivator
- Parameters:
o
- the activator to compare to- Returns:
- a negative integer, zero, or a positive integer as this activator is less than, equal to, or greater than the specified activator
-
getScheduler
Returns the scheduler associated with this activator.- Overrides:
getScheduler
in classActivator
- Returns:
- the scheduler associated with this activator
-
getNextActivationDate
Returns the next date at which this activator should be triggered.- Returns:
- the 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
Executes the behavior of the activator and updates the next activation date.- Overrides:
execute
in classMethodActivator
- Parameters:
args
- the arguments to pass to the behavior- See Also:
-
toString
Returns a string representation of the activator, including the next activation date.- Overrides:
toString
in classMethodActivator
- Returns:
- a string representation of the activator
-
getDefaultInterval
Returns the default interval between activations.- Returns:
- the default interval between activations
-
setDefaultInterval
Sets the default interval between activations.- Parameters:
defaultInterval
- the default interval between activations
-
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
-
onAdding
Automatically called when an agent joins the corresponding group and role. Override this method when you want to do some initialization when an agent enters the group/role.- Parameters:
agent
- which has been added to this group/role
-
onRemoving
Automatically called when an agent leaves the corresponding group and role. 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 targeted agents.- Returns:
- the number of targeted agents
-
isEmpty
public boolean isEmpty()Checks if there is no agent in the group/role couple- Returns:
- true, if no agent is handling the group/role couple
-
getAgents
-
getName
-
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.
-