hasim-0.1.2: Process-Based Discrete Event Simulation library

Portabilityunportable
Stabilityexperimental
Maintainerjochem@functor.nl

Control.Hasim.DES

Contents

Description

This module defines a DES, which stands for Discrete Event Set. There are functions for creating and inserting events.

For each process, an Event may be scheduled. This event consists of a Time and a Runnable. There can be at most one Event scheduled for each Process.

Synopsis

Events

Abstract data type

data Event Source

Event. An event consists of a Time and a Runnable

Instances

Querying events

eTime :: Event -> TimeSource

The Time at which the event takes place.

eRunnable :: Event -> RunnableSource

The Runnable that should be run at this time

eProcess :: Event -> ProcessSource

The process of an Event

Discrete Event Set

ADT for Discrete Event Set

data DES Source

Discrete Event Set. A discrete event set is a data structure that supports the operations update and removeNext.

Instances

Creating Discrete Event Set

initDESSource

Arguments

:: [Process]

The list of processes

-> IO DES

IO, with result the created DES

Create a new DES. For each Process, an Event is scheduled at time 0 and with Runnable the associated Runnable of the Process.

emptyDES :: DESSource

An empty discrete event set.

Querying Discrete Event Set

isEmpty :: DES -> BoolSource

Is the Discrete Event Set empty?

Updating Discrete Event Set

removeNext :: DES -> (Event, DES)Source

Get an event with lowest time that will take place next. Returns a tuple (evt, des) where evt is the next Event and des is the new DES where this event is removed.

Calls error if the DES is empty.

updateSource

Arguments

:: Time

The time at which the event takes place

-> Runnable

The Runnable that should be run at that time

-> DES

The old discrete event set

-> DES

The discrete event set with the event added

Schedule an event in a discrete event set. Note that an old event of the same process is removed from the discrete event set.