Copyright | Copyright (c) 2009-2017 David Sorokin <david.sorokin@gmail.com> |
---|---|

License | BSD3 |

Maintainer | David Sorokin <david.sorokin@gmail.com> |

Stability | experimental |

Safe Haskell | None |

Language | Haskell2010 |

Tested with: GHC 8.0.1

The module defines useful result transformations that can be used in simulation experiments.

## Synopsis

- class ResultTransformer t m where
- tr :: t m -> ResultTransform m

- newtype SamplingStats m = SamplingStats (ResultTransform m)
- samplingStatsCount :: MonadDES m => SamplingStats m -> ResultTransform m
- samplingStatsMin :: MonadDES m => SamplingStats m -> ResultTransform m
- samplingStatsMax :: MonadDES m => SamplingStats m -> ResultTransform m
- samplingStatsMean :: MonadDES m => SamplingStats m -> ResultTransform m
- samplingStatsMean2 :: MonadDES m => SamplingStats m -> ResultTransform m
- samplingStatsVariance :: MonadDES m => SamplingStats m -> ResultTransform m
- samplingStatsDeviation :: MonadDES m => SamplingStats m -> ResultTransform m
- newtype TimingStats m = TimingStats (ResultTransform m)
- timingStatsCount :: MonadDES m => TimingStats m -> ResultTransform m
- timingStatsMin :: MonadDES m => TimingStats m -> ResultTransform m
- timingStatsMax :: MonadDES m => TimingStats m -> ResultTransform m
- timingStatsMean :: MonadDES m => TimingStats m -> ResultTransform m
- timingStatsVariance :: MonadDES m => TimingStats m -> ResultTransform m
- timingStatsDeviation :: MonadDES m => TimingStats m -> ResultTransform m
- timingStatsMinTime :: MonadDES m => TimingStats m -> ResultTransform m
- timingStatsMaxTime :: MonadDES m => TimingStats m -> ResultTransform m
- timingStatsStartTime :: MonadDES m => TimingStats m -> ResultTransform m
- timingStatsLastTime :: MonadDES m => TimingStats m -> ResultTransform m
- timingStatsSum :: MonadDES m => TimingStats m -> ResultTransform m
- timingStatsSum2 :: MonadDES m => TimingStats m -> ResultTransform m
- newtype SamplingCounter m = SamplingCounter (ResultTransform m)
- samplingCounterValue :: SamplingCounter m -> ResultTransform m
- samplingCounterStats :: SamplingCounter m -> SamplingStats m
- newtype TimingCounter m = TimingCounter (ResultTransform m)
- timingCounterValue :: TimingCounter m -> ResultTransform m
- timingCounterStats :: TimingCounter m -> TimingStats m
- newtype Queue m = Queue (ResultTransform m)
- enqueueStrategy :: Queue m -> ResultTransform m
- enqueueStoringStrategy :: Queue m -> ResultTransform m
- dequeueStrategy :: Queue m -> ResultTransform m
- queueNull :: Queue m -> ResultTransform m
- queueFull :: Queue m -> ResultTransform m
- queueMaxCount :: Queue m -> ResultTransform m
- queueCount :: Queue m -> ResultTransform m
- queueCountStats :: Queue m -> TimingStats m
- enqueueCount :: Queue m -> ResultTransform m
- enqueueLostCount :: Queue m -> ResultTransform m
- enqueueStoreCount :: Queue m -> ResultTransform m
- dequeueCount :: Queue m -> ResultTransform m
- dequeueExtractCount :: Queue m -> ResultTransform m
- queueLoadFactor :: Queue m -> ResultTransform m
- enqueueRate :: Queue m -> ResultTransform m
- enqueueStoreRate :: Queue m -> ResultTransform m
- dequeueRate :: Queue m -> ResultTransform m
- dequeueExtractRate :: Queue m -> ResultTransform m
- queueWaitTime :: Queue m -> SamplingStats m
- queueTotalWaitTime :: Queue m -> SamplingStats m
- enqueueWaitTime :: Queue m -> SamplingStats m
- dequeueWaitTime :: Queue m -> SamplingStats m
- queueRate :: Queue m -> ResultTransform m
- newtype ArrivalTimer m = ArrivalTimer (ResultTransform m)
- arrivalProcessingTime :: ArrivalTimer m -> SamplingStats m
- newtype Server m = Server (ResultTransform m)
- serverInitState :: Server m -> ResultTransform m
- serverState :: Server m -> ResultTransform m
- serverTotalInputWaitTime :: Server m -> ResultTransform m
- serverTotalProcessingTime :: Server m -> ResultTransform m
- serverTotalOutputWaitTime :: Server m -> ResultTransform m
- serverTotalPreemptionTime :: Server m -> ResultTransform m
- serverInputWaitTime :: Server m -> SamplingStats m
- serverProcessingTime :: Server m -> SamplingStats m
- serverOutputWaitTime :: Server m -> SamplingStats m
- serverPreemptionTime :: Server m -> SamplingStats m
- serverInputWaitFactor :: Server m -> ResultTransform m
- serverProcessingFactor :: Server m -> ResultTransform m
- serverOutputWaitFactor :: Server m -> ResultTransform m
- serverPreemptionFactor :: Server m -> ResultTransform m
- newtype Activity m = Activity (ResultTransform m)
- activityInitState :: Activity m -> ResultTransform m
- activityState :: Activity m -> ResultTransform m
- activityTotalUtilisationTime :: Activity m -> ResultTransform m
- activityTotalIdleTime :: Activity m -> ResultTransform m
- activityTotalPreemptionTime :: Activity m -> ResultTransform m
- activityUtilisationTime :: Activity m -> SamplingStats m
- activityIdleTime :: Activity m -> SamplingStats m
- activityPreemptionTime :: Activity m -> SamplingStats m
- activityUtilisationFactor :: Activity m -> ResultTransform m
- activityIdleFactor :: Activity m -> ResultTransform m
- activityPreemptionFactor :: Activity m -> ResultTransform m
- newtype Resource m = Resource (ResultTransform m)
- resourceCount :: Resource m -> ResultTransform m
- resourceCountStats :: Resource m -> TimingStats m
- resourceUtilisationCount :: Resource m -> ResultTransform m
- resourceUtilisationCountStats :: Resource m -> TimingStats m
- resourceQueueCount :: Resource m -> ResultTransform m
- resourceQueueCountStats :: Resource m -> TimingStats m
- resourceTotalWaitTime :: Resource m -> ResultTransform m
- resourceWaitTime :: Resource m -> SamplingStats m
- newtype Operation m = Operation (ResultTransform m)
- operationTotalUtilisationTime :: Operation m -> ResultTransform m
- operationTotalPreemptionTime :: Operation m -> ResultTransform m
- operationUtilisationTime :: Operation m -> SamplingStats m
- operationPreemptionTime :: Operation m -> SamplingStats m
- operationUtilisationFactor :: Operation m -> ResultTransform m
- operationPreemptionFactor :: Operation m -> ResultTransform m

# Basic Class Type

class ResultTransformer t m where Source #

Something that can transform the results.

tr :: t m -> ResultTransform m Source #

Return the result transform.

## Instances

# Sampling Statistics

newtype SamplingStats m Source #

Represents a statistics based upon observations.

## Instances

ResultTransformer SamplingStats m Source # | |

Defined in Simulation.Aivika.Trans.Results.Transform tr :: SamplingStats m -> ResultTransform m Source # |

samplingStatsCount :: MonadDES m => SamplingStats m -> ResultTransform m Source #

The total number of samples.

samplingStatsMin :: MonadDES m => SamplingStats m -> ResultTransform m Source #

The minimum value among the samples.

samplingStatsMax :: MonadDES m => SamplingStats m -> ResultTransform m Source #

The maximum value among the samples.

samplingStatsMean :: MonadDES m => SamplingStats m -> ResultTransform m Source #

The average value.

samplingStatsMean2 :: MonadDES m => SamplingStats m -> ResultTransform m Source #

The average square value.

samplingStatsVariance :: MonadDES m => SamplingStats m -> ResultTransform m Source #

Return tha variance.

samplingStatsDeviation :: MonadDES m => SamplingStats m -> ResultTransform m Source #

Return the deviation.

# Time-dependent Statistics

newtype TimingStats m Source #

The time-dependent statistics.

## Instances

ResultTransformer TimingStats m Source # | |

Defined in Simulation.Aivika.Trans.Results.Transform tr :: TimingStats m -> ResultTransform m Source # |

timingStatsCount :: MonadDES m => TimingStats m -> ResultTransform m Source #

Return the number of samples.

timingStatsMin :: MonadDES m => TimingStats m -> ResultTransform m Source #

Return the minimum value.

timingStatsMax :: MonadDES m => TimingStats m -> ResultTransform m Source #

Return the maximum value.

timingStatsMean :: MonadDES m => TimingStats m -> ResultTransform m Source #

Return the average value.

timingStatsVariance :: MonadDES m => TimingStats m -> ResultTransform m Source #

Return the variance.

timingStatsDeviation :: MonadDES m => TimingStats m -> ResultTransform m Source #

Return the deviation.

timingStatsMinTime :: MonadDES m => TimingStats m -> ResultTransform m Source #

Return the time at which the minimum is attained.

timingStatsMaxTime :: MonadDES m => TimingStats m -> ResultTransform m Source #

Return the time at which the maximum is attained.

timingStatsStartTime :: MonadDES m => TimingStats m -> ResultTransform m Source #

Return the start time of sampling.

timingStatsLastTime :: MonadDES m => TimingStats m -> ResultTransform m Source #

Return the last time of sampling.

timingStatsSum :: MonadDES m => TimingStats m -> ResultTransform m Source #

Return the sum of values.

timingStatsSum2 :: MonadDES m => TimingStats m -> ResultTransform m Source #

Return the sum of square values.

# Sampling-based Counter

newtype SamplingCounter m Source #

A counter for which the statistics is collected too.

## Instances

ResultTransformer SamplingCounter m Source # | |

Defined in Simulation.Aivika.Trans.Results.Transform tr :: SamplingCounter m -> ResultTransform m Source # |

samplingCounterValue :: SamplingCounter m -> ResultTransform m Source #

The counter value.

samplingCounterStats :: SamplingCounter m -> SamplingStats m Source #

The counter statistics.

# Time-dependent Counter

newtype TimingCounter m Source #

A time-dependent counter that collects the statistics too.

## Instances

ResultTransformer TimingCounter m Source # | |

Defined in Simulation.Aivika.Trans.Results.Transform tr :: TimingCounter m -> ResultTransform m Source # |

timingCounterValue :: TimingCounter m -> ResultTransform m Source #

The counter value.

timingCounterStats :: TimingCounter m -> TimingStats m Source #

The counter statistics.

# Queue

Represents either finite or infinite queue.

Queue (ResultTransform m) |

## Instances

ResultTransformer Queue m Source # | |

Defined in Simulation.Aivika.Trans.Results.Transform tr :: Queue m -> ResultTransform m Source # |

enqueueStrategy :: Queue m -> ResultTransform m Source #

The strategy applied to the enqueueing (input) processes when the finite queue is full.

enqueueStoringStrategy :: Queue m -> ResultTransform m Source #

The strategy applied when storing (in memory) items in the queue.

dequeueStrategy :: Queue m -> ResultTransform m Source #

The strategy applied to the dequeueing (output) processes when the queue is empty.

queueNull :: Queue m -> ResultTransform m Source #

Test whether the queue is empty.

queueFull :: Queue m -> ResultTransform m Source #

Test whether the finite queue is full.

queueMaxCount :: Queue m -> ResultTransform m Source #

The finite queue capacity.

queueCount :: Queue m -> ResultTransform m Source #

Return the current queue size.

queueCountStats :: Queue m -> TimingStats m Source #

Return the queue size statistics.

enqueueCount :: Queue m -> ResultTransform m Source #

Return the total number of input items that were enqueued in the finite queue.

enqueueLostCount :: Queue m -> ResultTransform m Source #

Return the number of lost items for the finite queue.

enqueueStoreCount :: Queue m -> ResultTransform m Source #

Return the total number of input items that were stored.

dequeueCount :: Queue m -> ResultTransform m Source #

Return the total number of requests for dequeueing the items, not taking into account the failed attempts to dequeue immediately without suspension.

dequeueExtractCount :: Queue m -> ResultTransform m Source #

Return the total number of output items that were actually dequeued.

queueLoadFactor :: Queue m -> ResultTransform m Source #

Return the load factor: the finite queue size divided by its capacity.

enqueueRate :: Queue m -> ResultTransform m Source #

Return the rate of the input items that were enqueued in the finite queue: how many items per time.

enqueueStoreRate :: Queue m -> ResultTransform m Source #

Return the rate of the items that were stored: how many items per time.

dequeueRate :: Queue m -> ResultTransform m Source #

Return the rate of the requests for dequeueing the items: how many requests per time. It does not include the failed attempts to dequeue immediately without suspension.

dequeueExtractRate :: Queue m -> ResultTransform m Source #

Return the rate of the output items that were dequeued: how many items per time.

queueWaitTime :: Queue m -> SamplingStats m Source #

Return the wait time from the time at which the item was stored in the queue to the time at which it was dequeued.

queueTotalWaitTime :: Queue m -> SamplingStats m Source #

Return the total wait time for the finite queue from the time at which the enqueueing operation was initiated to the time at which the item was dequeued.

enqueueWaitTime :: Queue m -> SamplingStats m Source #

Return the wait time from the time at which the item was stored in the queue to the time at which it was dequeued.

dequeueWaitTime :: Queue m -> SamplingStats m Source #

Return the dequeue wait time from the time at which the item was requested for dequeueing to the time at which it was actually dequeued.

queueRate :: Queue m -> ResultTransform m Source #

Return a long-term average queue rate calculated as the average queue size divided by the average wait time.

# Arrival Timer

newtype ArrivalTimer m Source #

Accumulates the statistics about that how long the arrived events are processed.

## Instances

ResultTransformer ArrivalTimer m Source # | |

Defined in Simulation.Aivika.Trans.Results.Transform tr :: ArrivalTimer m -> ResultTransform m Source # |

arrivalProcessingTime :: ArrivalTimer m -> SamplingStats m Source #

Return the statistics about that how long the arrived events were processed.

# Server

It models the server that prodives a service.

## Instances

ResultTransformer Server m Source # | |

Defined in Simulation.Aivika.Trans.Results.Transform tr :: Server m -> ResultTransform m Source # |

serverInitState :: Server m -> ResultTransform m Source #

The initial state of the server.

serverState :: Server m -> ResultTransform m Source #

Return the current state of the server.

serverTotalInputWaitTime :: Server m -> ResultTransform m Source #

Return the counted total time when the server was locked while awaiting the input.

serverTotalProcessingTime :: Server m -> ResultTransform m Source #

Return the counted total time spent by the server while processing the tasks.

serverTotalOutputWaitTime :: Server m -> ResultTransform m Source #

Return the counted total time when the server was locked while trying to deliver the output.

serverTotalPreemptionTime :: Server m -> ResultTransform m Source #

Return the counted total time spent by the server while it was preempted waiting for the further proceeding.

serverInputWaitTime :: Server m -> SamplingStats m Source #

Return the statistics of the time when the server was locked while awaiting the input.

serverProcessingTime :: Server m -> SamplingStats m Source #

Return the statistics of the time spent by the server while processing the tasks.

serverOutputWaitTime :: Server m -> SamplingStats m Source #

Return the statistics of the time when the server was locked while trying to deliver the output.

serverPreemptionTime :: Server m -> SamplingStats m Source #

Return the statistics of the time spent by the server while it was preempted waiting for the further proceeding.

serverInputWaitFactor :: Server m -> ResultTransform m Source #

It returns the factor changing from 0 to 1, which estimates how often the server was awaiting for the next input task.

serverProcessingFactor :: Server m -> ResultTransform m Source #

It returns the factor changing from 0 to 1, which estimates how often the server was busy with direct processing its tasks.

serverOutputWaitFactor :: Server m -> ResultTransform m Source #

It returns the factor changing from 0 to 1, which estimates how often the server was locked trying to deliver the output after the task is finished.

serverPreemptionFactor :: Server m -> ResultTransform m Source #

It returns the factor changing from 0 to 1, which estimates how often the server was preempted waiting for the further proceeding.

# Activity

It models an activity that can be utilised.

## Instances

ResultTransformer Activity m Source # | |

Defined in Simulation.Aivika.Trans.Results.Transform tr :: Activity m -> ResultTransform m Source # |

activityInitState :: Activity m -> ResultTransform m Source #

The initial state of the activity.

activityState :: Activity m -> ResultTransform m Source #

Return the current state of the activity.

activityTotalUtilisationTime :: Activity m -> ResultTransform m Source #

Return the counted total time when the activity was utilised.

activityTotalIdleTime :: Activity m -> ResultTransform m Source #

Return the counted total time when the activity was idle.

activityTotalPreemptionTime :: Activity m -> ResultTransform m Source #

Return the counted total time when the activity was preemted waiting for the further proceeding.

activityUtilisationTime :: Activity m -> SamplingStats m Source #

Return the statistics for the time when the activity was utilised.

activityIdleTime :: Activity m -> SamplingStats m Source #

Return the statistics for the time when the activity was idle.

activityPreemptionTime :: Activity m -> SamplingStats m Source #

Return the statistics for the time when the activity was preempted waiting for the further proceeding.

activityUtilisationFactor :: Activity m -> ResultTransform m Source #

It returns the factor changing from 0 to 1, which estimates how often the activity was utilised.

activityIdleFactor :: Activity m -> ResultTransform m Source #

It returns the factor changing from 0 to 1, which estimates how often the activity was idle.

activityPreemptionFactor :: Activity m -> ResultTransform m Source #

It returns the factor changing from 0 to 1, which estimates how often the activity was preempted waiting for the further proceeding.

# Resource

The resource which can be acquired and then released.

## Instances

ResultTransformer Resource m Source # | |

Defined in Simulation.Aivika.Trans.Results.Transform tr :: Resource m -> ResultTransform m Source # |

resourceCount :: Resource m -> ResultTransform m Source #

Return the current available count of the resource.

resourceCountStats :: Resource m -> TimingStats m Source #

Return the statistics for the available count of the resource.

resourceUtilisationCount :: Resource m -> ResultTransform m Source #

Return the current utilisation count of the resource.

resourceUtilisationCountStats :: Resource m -> TimingStats m Source #

Return the statistics for the utilisation count of the resource.

resourceQueueCount :: Resource m -> ResultTransform m Source #

Return the current queue length of the resource.

resourceQueueCountStats :: Resource m -> TimingStats m Source #

Return the statistics for the queue length of the resource.

resourceTotalWaitTime :: Resource m -> ResultTransform m Source #

Return the total wait time of the resource.

resourceWaitTime :: Resource m -> SamplingStats m Source #

Return the statistics for the wait time of the resource.

# Operation

It models an opreation which actvity can be utilised.

## Instances

ResultTransformer Operation m Source # | |

Defined in Simulation.Aivika.Trans.Results.Transform tr :: Operation m -> ResultTransform m Source # |

operationTotalUtilisationTime :: Operation m -> ResultTransform m Source #

Return the counted total time when the operation activity was utilised.

operationTotalPreemptionTime :: Operation m -> ResultTransform m Source #

Return the counted total time when the operation activity was preemted waiting for the further proceeding.

operationUtilisationTime :: Operation m -> SamplingStats m Source #

Return the statistics for the time when the operation activity was utilised.

operationPreemptionTime :: Operation m -> SamplingStats m Source #

Return the statistics for the time when the operation activity was preempted waiting for the further proceeding.

operationUtilisationFactor :: Operation m -> ResultTransform m Source #

It returns the factor changing from 0 to 1, which estimates how often the operation activity was utilised.

operationPreemptionFactor :: Operation m -> ResultTransform m Source #

It returns the factor changing from 0 to 1, which estimates how often the operation activity was preempted waiting for the further proceeding.