package proter
- Alphabetic
- Public
- All
Type Members
-
case class
Arrival(time: Long, rate: Distribution, simulationGenerator: SimulationRefGenerator, limit: Option[Int] = None, count: Int = 0) extends DiscreteEvent with Product with Serializable
Event used to model a repeating process.
Event used to model a repeating process.
An arrival rate is used to indicate when new instances of a simulation should be added to the coordinator.
- time
The timestamp of the event
- rate
The arrival rate of the simulation
- simulationGenerator
The simulation generator for getting new instances of a simulation
- count
A counter of the next simulation instance that will be generated
-
trait
AsyncSimulation extends Simulation
Asynchronous Simulation implementation with callback functions.
Asynchronous Simulation implementation with callback functions.
Each task needs to be accompanied by a callback function that implements the simulation logic to be followed when the task completes.
-
case class
Constant(value: Double) extends Distribution with Product with Serializable
A constant value generator.
A constant value generator.
Always generates the same value.
- value
The value to generate.
-
class
Coordinator extends Manager with HashMapPublisher
Provides coordination for discrete event simulation of multiple asynchronous simulations.
Provides coordination for discrete event simulation of multiple asynchronous simulations.
Default implementation of Manager.
It can run in a single thread or multi-threaded depending on the
singleThread
constructor parameter. In the multi-threaded setting, task completions are reported to the simulations asynchronously through a new thread (Future
) each time. This allows simulations to run things concurrently, with the added overhead of thread spawning. -
sealed
trait
DiscreteEvent extends Ordered[DiscreteEvent]
Discrete Events that need to be handled by the Coordinator..
-
trait
Distribution extends AnyRef
A random function sampling some probability distribution.
A random function sampling some probability distribution.
It can be used to generate a value for some simulation parameters (typically duration and cost). It can be a Constant which always provides the same value or any probability distribution.
Distributions must also provide an estimate of the generated values such that can be used in an environment of imperfect knowledge. For example, the Scheduler does not know the actual durations of tasks, which can vary from the expected estimate for various reasons.
- case class Exponential(mean: Double) extends Distribution with Product with Serializable
-
case class
FinishingTask(time: Long, task: TaskInstance) extends DiscreteEvent with Product with Serializable
Event fired when a Task has finished.
-
trait
FutureTasks extends AnyRef
Extends AsyncSimulation with callbacks that fulfil a
Promise
/Future
.Extends AsyncSimulation with callbacks that fulfil a
Promise
/Future
.This can be helpful for simulation implementations that use
Future
s to capture their asynchronous logic. -
trait
Lookahead extends AnyRef
A Lookahead contains information about the order in which tasks run.
A Lookahead contains information about the order in which tasks run.
The structure is immutable. It is built by the simulation and passed to the scheduler where it is used for scheduling by revealing information about future tasks so that look-ahead can be achieved.
-
case class
LookaheadSet(lookaheadSet: Set[((Map[UUID, Long]) ⇒ Option[Long], List[Task])] = Set()) extends Lookahead with Product with Serializable
A Lookahead that uses a set in the implementation
-
case class
Lookaheads(lookaheads: Queue[Lookahead]) extends Lookahead with Product with Serializable
A Structure used for combining multiple Lookaheads into one.
-
trait
LookingAhead extends Simulation
A trait that adds Lookahead capabilities to a simulation.
A trait that adds Lookahead capabilities to a simulation.
Works in conjunction with LookaheadScheduler.
Provides a lookahead structure that can be built up by the simulation and then sent to the scheduler for use in making schedules which look into the future to consider upcoming tasks in scheduling.
-
trait
Manager extends AnyRef
Abstract simulation manager.
-
case class
SimDone(simulation: String, result: Try[Any]) extends SimResponse with Product with Serializable
Response issued when the simulation has completed.
Response issued when the simulation has completed.
- simulation
The name of the SimulationRef.
- result
The (successful or failed) result of the simulation.
-
case class
SimReady(simulation: String, tasks: Seq[Task], abort: Seq[UUID] = Seq(), lookahead: Lookahead = NoLookahead) extends SimResponse with Product with Serializable
Response issued when the simulation is still running and waiting for virtual time to pass.
Response issued when the simulation is still running and waiting for virtual time to pass.
- simulation
The name of the SimulationRef.
- tasks
A sequence of new tasks to be added for scheduling.
- abort
A sequence of IDs of existing tasks that need to be aborted.
- lookahead
An updated Lookahead structure.
-
sealed
trait
SimResponse extends AnyRef
Captures the potential responses of a simulation case to an event.
Captures the potential responses of a simulation case to an event.
A simulation is notified by its Manager when relevant events have taken place, such as one of its tasks completing. The simulation can use subclasses of this trait to respond to such notification. The Manager will wait for such a response before it resumes the virtual time.
-
trait
Simulation extends SimulationRef
A manager for a single simulation case.
A manager for a single simulation case.
We view a simulation as a case or workflow of simulated tasks. This class is responsible for keeping track of all the tasks for the corresponding simulation, informing the Coordinator of new tasks to be added and informing the simulation processes when a task is completed.
Basic Interaction Flow
The interaction flow with the Coordinator is expected as follows:
- The simulation logic starts executing via run.
- Tasks are added via task.
- When the simulation logic finishes producing tasks, it should call ready.
- Eventually, one of the tasks completes and complete is called. The simulation logic resumes execution.
- The simulation may now produce further tasks in reaction to the completed one(s). It can either handle and acknowledge each completed task individually using ack or use ready in one go as above.
- When the simulation logic completes, it can use succeed (instead of ack or ready) to notify the Coordinator of its result.
Additional Functions
The simulation may also:
- React to things happening to other simulations. It can send a
request to
using simWait. The Coordinator will then wait for the Simulation to send new tasks or to complete, as if a task just completed. This needs to happen while the Coordinator is still waiting for the other simulation(s) we are reacting to.wait
- Abort previously added tasks using abort.
- Report completion due to failure using fail.
- Optionally maintain a Lookahead structure of future tasks, returning it through getLookahead.
-
trait
SimulationGenerator extends SimulationRefGenerator
A generator of simulation instances.
A generator of simulation instances.
This is used to model repeating processes, for instance with a given arrival rate.
It generates copies of a SimulationRef. It must ensure that each copy has a unique name and is independent from all other copies. An integer counter is provided as an argument for that purpose, though it is not necessary to use that.
-
trait
SimulationRef extends AnyRef
An abstract reference to simulation logic.
An abstract reference to simulation logic.
Includes the basic interface that we expect from a simulation case:
- Starting the simulation.
- Notifying when tasks complete.
- Stopping/aborting the simulation.
-
trait
SimulationRefGenerator extends AnyRef
A generator of simulation instances.
A generator of simulation instances.
This is used to model repeating processes, for instance with a given arrival rate.
It generates copies of a SimulationRef. It must ensure that each copy has a unique name and is independent from all other copies. An integer counter is provided as an argument for that purpose, though it is not necessary to use that.
-
class
SingleTaskSimulation extends Simulation
A Simulation that simulates a single Task.
-
class
SingleTaskSimulationGenerator extends SimulationGenerator
A SimulationGenerator for SingleTaskSimulation instances.
-
case class
StartingSim(time: Long, simulation: SimulationRef) extends DiscreteEvent with Product with Serializable
Event fired when a simulation needs to start.
Event fired when a simulation needs to start.
- time
The timestamp of the event
- simulation
The Simulation that needs to start.
-
case class
Task(name: String, id: Option[UUID], duration: Distribution, cost: Distribution = Constant(0L), minStartTime: Long = 0L, resources: Seq[String] = Seq(), interrupt: Int = -1, priority: Int = 0, createTime: Long = -1) extends Product with Serializable
A generator/factory of tasks (specifically TaskInstances).
A generator/factory of tasks (specifically TaskInstances).
As a case class, it can be easily manipulated dynamically to alter its values.
Uses Distributions for the duration and cost. These may be based on random variables. The actual values are sampled at task creation time.
Although typically only 1 task is generated, in principle it can generate multiple task instances with the same properties. However, each task generated will have different samples of the Distributions.
- name
The name of the task.
- id
An optional unique id of the task. Otherwise a random ID will be used.
- duration
The generator of the duration.
- cost
The generator of the cost.
- minStartTime
The earliest possible starting time of the task.
- resources
The resources of this task
- interrupt
The TaskInstance.interrupt property of the task.
- priority
The explicit priority of the task.
- createTime
A custom creation time. Negative values correspond to the current time.
-
class
TaskInstance extends Ordered[TaskInstance]
An instance of a task to be performed in virtual time.
An instance of a task to be performed in virtual time.
- Note
We expect that task instances are only generated through a Task. The samples of the parameters are generated by the Coordinator. The duration can be specified through random sampling in a Distribution. We store the estimated value as well as the actual sampled value.
-
class
TaskResource extends AnyRef
A persistent resource to be used by Tasks/TaskInstances.
A persistent resource to be used by Tasks/TaskInstances.
A TaskResource, or simply "resource", corresponds to a persistent resource. Typical examples are human actors or persistent machinery.
Each Task may require a different combination of resources.
Each TaskResource is assumed to have a unique name and a
costPerTick
, i.e. the cost (if any) of using the resource per unit of time.We say a TaskResource is attached to a TaskInstance when the task that uses this resource is being performed. The
currentTask
variable holds the task that is currently attached to the resource (if any) coupled with the virtual timestamp of when it started. A TaskResource is idle' when it has no tasks attached to it.The Coordinator calls upon startTask to attach a task to the resource and finishTask to detach it. The Coordinator has full control over the resource and makes all necessary checks to ensure consistent behaviour (e.g. not starting a TaskInstance when another TaskInstance is already attached).
-
case class
TimeLimit(time: Long) extends DiscreteEvent with Product with Serializable
Event fired when a global time limit has been reached.
Event fired when a global time limit has been reached.
- time
The timestamp of the event
-
case class
Uniform(min: Double, max: Double) extends Distribution with Product with Serializable
A uniform distribution.
Value Members
- object Lookaheads extends Serializable
-
object
NoLookahead extends Lookahead with Product with Serializable
An empty Lookahead that does nothing.
- object Simulation
- object Task extends Serializable