Class DiscreteEventAgentsActivator
java.lang.Object
madkit.kernel.Activator
madkit.simulation.scheduler.MethodActivator
madkit.simulation.scheduler.DateBasedDiscreteEventActivator
madkit.simulation.scheduler.DiscreteEventAgentsActivator
- All Implemented Interfaces:
Comparable<Activator>
An activator that works using a discrete-event simulation scheme.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PriorityQueue<SimuAgent> The priority queue that holds the simulated agents based on their next event date. -
Constructor Summary
ConstructorsConstructorDescriptionDiscreteEventAgentsActivator(String group, String role, String theBehaviorToActivate) Constructs a new DiscreteEventAgentsActivator with the specified group, role, and behavior to activate. -
Method Summary
Modifier and TypeMethodDescriptionvoidMakes all the agents leave the corresponding role at once.voidExecutes the behavior of the next agent in the activation list.Returns a snapshot at moment t of the agents handling the group/role coupleGets the community to which this activator/probe is binded to.getGroup()Gets the group to which this activator/probe is binded to.getName()Gets the name.Returns the next activation date based on the activation list.getRole()Gets the role to which this activator/probe is binded to.booleanisEmpty()Checks if there is no agent in the group/role couplevoidKills all the agents which are monitored.protected voidCalled when an agent is added to the activator.protected voidonRemoving(Agent agent) Called when an agent is removed from the activator.intsize()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.DateBasedDiscreteEventActivator
compareTo, getCurrentTime, getDefaultInterval, getScheduler, setDefaultInterval, setNextActivationDateMethods inherited from class madkit.simulation.scheduler.MethodActivator
execute, executeInParallel, getMethod, isParallelMode, isShufflingMode, setParallelMode, setShufflingModeMethods inherited from class madkit.kernel.Activator
executeBehaviorOf, getPriority, getSimuTimer, setPriority
-
Field Details
-
activationList
The priority queue that holds the simulated agents based on their next event date.
-
-
Constructor Details
-
DiscreteEventAgentsActivator
Constructs a new DiscreteEventAgentsActivator 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
-
onAdding
Called when an agent is added to the activator. Updates the activation list and the next activation date.- Parameters:
agent- the agent being added
-
getNextActivationDate
Returns the next activation date based on the activation list.- Overrides:
getNextActivationDatein classDateBasedDiscreteEventActivator- Returns:
- the next activation date
-
onRemoving
Called when an agent is removed from the activator. Updates the activation list and the next activation date.- Parameters:
agent- the agent being removed
-
execute
Executes the behavior of the next agent in the activation list.- Overrides:
executein classDateBasedDiscreteEventActivator- 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:
toStringin classDateBasedDiscreteEventActivator- Returns:
- a string representation of the activator
-
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
-
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.
-