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

public class DateBasedDiscreteEventActivator extends MethodActivator
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 Details

    • DateBasedDiscreteEventActivator

      public DateBasedDiscreteEventActivator(String group, String role, String theBehaviorToActivate)
      Constructs a new DateBasedDiscreteEventActivator with the specified group, role, and behavior to activate.
      Parameters:
      group - the group of the agents
      role - the role of the agents
      theBehaviorToActivate - the behavior to activate
  • Method Details

    • getCurrentTime

      public LocalDateTime getCurrentTime()
      Returns the current simulation time.
      Returns:
      the current simulation time
    • compareTo

      public int compareTo(Activator o)
      Defines an ordering so that the scheduler can classify activators according to their date and priority.
      Specified by:
      compareTo in interface Comparable<Activator>
      Overrides:
      compareTo in class Activator
      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

      public DateBasedDiscreteEventScheduler getScheduler()
      Returns the scheduler associated with this activator.
      Overrides:
      getScheduler in class Activator
      Returns:
      the scheduler associated with this activator
    • getNextActivationDate

      public LocalDateTime getNextActivationDate()
      Returns the next date at which this activator should be triggered.
      Returns:
      the next date at which this activator should be triggered
    • setNextActivationDate

      public void setNextActivationDate(LocalDateTime nextActivationDate)
      Sets the next date at which the activator will be triggered.
      Parameters:
      nextActivationDate - a LocalDateTime which should be greater than the current simulation time
    • execute

      public void execute(Object... args)
      Executes the behavior of the activator and updates the next activation date.
      Overrides:
      execute in class MethodActivator
      Parameters:
      args - the arguments to pass to the behavior
      See Also:
    • toString

      public String toString()
      Returns a string representation of the activator, including the next activation date.
      Overrides:
      toString in class MethodActivator
      Returns:
      a string representation of the activator
    • getDefaultInterval

      public Duration getDefaultInterval()
      Returns the default interval between activations.
      Returns:
      the default interval between activations
    • setDefaultInterval

      public void setDefaultInterval(Duration defaultInterval)
      Sets the default interval between activations.
      Parameters:
      defaultInterval - the default interval between activations
    • getCommunity

      public String getCommunity()
      Gets the community to which this activator/probe is binded to.
      Returns:
      a string representing the community's name
    • getGroup

      public String getGroup()
      Gets the group to which this activator/probe is binded to.
      Returns:
      a string representing the group's name
    • getRole

      public String getRole()
      Gets the role to which this activator/probe is binded to.
      Returns:
      a string representing the role's name
    • onAdding

      protected void onAdding(Agent agent)
      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

      protected void onRemoving(Agent agent)
      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

      public <A extends Agent> List<A> getAgents()
      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
    • getName

      public String getName()
      Gets the name.
      Returns:
      the name
    • 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.