aivika-branches-0.2: Nested discrete event simulation module for the Aivika library

Simulation.Aivika.Branch.Event

Contents

Description

Tested with: GHC 7.10.3

The module defines an event queue, where BR can be an instance of EventQueueing. Also it defines basic functions for branching computations.

Synopsis

# Documentation

branchEvent :: Event (BR IO) a -> Event (BR IO) a Source #

Branch a new computation and return its result leaving the current computation intact.

A new derivative branch with branchLevel increased by 1 is created at the current modeling time. Then the result of the specified computation for the derivative branch is returned.

The state of the current computation including its event queue and mutable references Ref remain intact. In some sense we copy the state of the model to the derivative branch and then proceed with the derived simulation. The copying operation is relatively cheap.

futureEvent :: Double -> Event (BR IO) a -> Event (BR IO) a Source #

Branch a new computation and return its result at the desired time in the future leaving the current computation intact.

A new derivative branch with branchLevel increased by 1 is created at the current modeling time. All pending events are processed till the specified time for that new branch. Then the result of the specified computation for the derivative branch is returned.

The state of the current computation including its event queue and mutable references Ref remain intact. In some sense we copy the state of the model to the derivative branch and then proceed with the derived simulation. The copying operation is relatively cheap.

futureEventWith :: EventProcessing -> Double -> Event (BR IO) a -> Event (BR IO) a Source #

Like futureEvent but allows specifying how the pending events must be processed.

# Orphan instances

 Source # An implementation of the EventQueueing type class. Associated Typesdata EventQueue (BR IO :: * -> *) :: * # MethodsnewEventQueue :: Specs (BR IO) -> BR IO (EventQueue (BR IO)) #enqueueEvent :: Double -> Event (BR IO) () -> Event (BR IO) () #runEvent :: Event (BR IO) a -> Dynamics (BR IO) a #runEventWith :: EventProcessing -> Event (BR IO) a -> Dynamics (BR IO) a #