Class DateBasedDiscreteEventScheduler
This class defines a scheduler for discrete event simulation. It is based on the
DateBasedTimer
class which is used to manage the simulation time. The scheduler
uses a priority queue to manage the activation list of the activators.-
Nested Class Summary
Nested classes/interfaces inherited from class madkit.kernel.Scheduler
Scheduler.SimulationState
Nested classes/interfaces inherited from class madkit.kernel.Agent
Agent.ReturnCode
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
addActivator
(Activator activator) Adds an activator to the scheduler.void
Defines a simulation step.Returns the activation list.Returns the current simulation time.void
Logs the activation list.void
removeActivator
(Activator activator) Removes an activator from the simulation engine.void
Should be used when an activator changes its next event date so that the new one is earlier.Methods inherited from class madkit.kernel.Scheduler
addEnvironmentActivator, addViewersActivator, executeAndLog, getActions, getActivators, getPause, getPauseSlider, getShedulerActions, getSimuTimer, getTimeLabel, getToolBar, logCurrrentTime, onActivation, onEnd, onLive, onSimulationStart, removeAllActivators, setPause, setSimulationTime
Methods inherited from class madkit.simulation.SimuAgent
createSimuGroup, getCommunity, getEngineGroup, getEnvironment, getLauncher, getModel, getModelGroup, getNextEventDate, getScheduler, getViewers, launchAgent, leaveRole, leaveSimuGroup, leaveSimuRole, playRole, prng, requestSimuRole
Methods inherited from class madkit.kernel.Agent
activate, broadcast, broadcastWithRole, broadcastWithRoleWaitForReplies, checkAgentAddress, createGroup, createGroup, createGroup, end, equals, executeThisAgent, executeThisAgent, exitOnKill, getAgentsWithRole, getAgentWithRole, getKernelAddress, getKernelConfig, getLogger, getMailbox, getName, getNetworkID, getOrganization, getReplyTo, handleRequestActionMessage, hashCode, isAlive, killAgent, killAgent, launchAgent, launchAgent, leaveGroup, leaveRole, live, nextMessage, pause, receiveMessage, reload, reply, replyWithRole, requestRole, requestRole, send, send, sendWaitReply, sendWaitReply, sendWithRole, sendWithRole, sendWithRoleWaitReply, sendWithRoleWaitReply, setupDefaultGUI, toString, waitAnswer, waitAnswer, waitNextMessage, waitNextMessage
-
Constructor Details
-
DateBasedDiscreteEventScheduler
public DateBasedDiscreteEventScheduler()Constructs a new scheduler with aDateBasedTimer
as simulation time.
-
-
Method Details
-
doSimulationStep
public void doSimulationStep()Description copied from class:Scheduler
Defines a simulation step. This method should be overridden to define a customized scheduling policy.- Specified by:
doSimulationStep
in classScheduler<DateBasedTimer>
-
getCurrentTime
Returns the current simulation time.- Returns:
- the current simulation time
-
logActivationList
public void logActivationList()Logs the activation list. -
addActivator
Adds an activator to the scheduler. If the activator is aDateBasedDiscreteEventActivator
it is also added to the activation list.- Overrides:
addActivator
in classScheduler<DateBasedTimer>
- Parameters:
activator
- an activator to add to the simulation engine.- Returns:
true
if the activator has been added,false
if it was already added
-
updateActivatorRanking
Should be used when an activator changes its next event date so that the new one is earlier. So, this method triggers the reordering of this activator.- Parameters:
a
-
-
removeActivator
Description copied from class:Scheduler
Removes an activator from the simulation engine.- Overrides:
removeActivator
in classScheduler<DateBasedTimer>
- Parameters:
activator
- an activator.
-
getActivationList
Returns the activation list.- Returns:
- the activation list
-