quickcheck-state-machine-0.7.0: Test monadic programs using state machine based models

Copyright(C) 2019 Stevan Andjelkovic
LicenseBSD-style (see the file LICENSE)
MaintainerStevan Andjelkovic <stevan.andjelkovic@strath.ac.uk>
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Test.StateMachine.Markov

Description

This module contains helper functions for testing using Markov chains.

Synopsis

Documentation

data Markov state cmd_ prob Source #

Markov chain.

makeMarkov :: Ord state => [Map state [Transition state cmd_ prob]] -> Markov state cmd_ prob Source #

Constructor for Markov chains.

toAdjacencyMap :: Ord state => Markov state cmd_ prob -> Map state (Map state (cmd_, prob)) Source #

Expose inner graph structure of markov chain

(-<) :: Fractional prob => state -> [Either (cmd_, state) ((cmd_, prob), state)] -> Map state [Transition state cmd_ prob] infixl 5 Source #

Infix operator for starting to creating a transition in the Markov chain, finish the transition with one of '(>-)' or '(/-)' depending on whether the transition has a specific or a uniform probability.

(>-) :: (cmd_, prob) -> state -> Either (cmd_, state) ((cmd_, prob), state) infixl 5 Source #

Finish making a transition with a specified probability distribution.

(/-) :: cmd_ -> state -> Either (cmd_, state) ((cmd_, prob), state) infixl 5 Source #

Finish making a transition with an uniform probability distribution.

markovGenerator :: forall state cmd_ cmd model. (Show state, Show cmd_) => (Ord state, Ord cmd_) => Markov state cmd_ Double -> Map cmd_ (model Symbolic -> Gen (cmd Symbolic)) -> (model Symbolic -> state) -> (state -> Bool) -> model Symbolic -> Maybe (Gen (cmd Symbolic)) Source #

Create a generator from a Markov chain.

coverMarkov :: (Show state, Show cmd_, Testable prop) => Markov state cmd_ Double -> prop -> Property Source #

Variant of QuickCheck's coverTable which works on Markov chains.

tabulateMarkov :: forall model state cmd cmd_ m resp prop. Testable prop => (Show state, Show cmd_) => StateMachine model cmd m resp -> (model Symbolic -> state) -> (cmd Symbolic -> cmd_) -> Commands cmd resp -> prop -> Property Source #

Variant of QuickCheck's tabulate which works for Markov chains.

transitionMatrix :: forall state cmd_. Ord state => (Generic state, GEnum FiniteEnum (Rep state), GBounded (Rep state)) => Markov state cmd_ Double -> Matrix Double Source #

stimulusMatrix :: forall state cmd. (Ord state, Ord cmd) => (Generic state, GEnum FiniteEnum (Rep state), GBounded (Rep state)) => (Generic cmd, GEnum FiniteEnum (Rep cmd), GBounded (Rep cmd)) => Markov state cmd Double -> Matrix Double Source #

historyObservations :: forall model cmd m resp state cmd_ prob. Ord state => Ord cmd_ => (Generic state, GEnum FiniteEnum (Rep state), GBounded (Rep state)) => StateMachine model cmd m resp -> Markov state cmd_ prob -> (model Concrete -> state) -> (cmd Concrete -> cmd_) -> History cmd resp -> (Matrix Double, Matrix Double) Source #

markovToDot :: (Show state, Show cmd_, Show prob) => state -> state -> Markov state cmd_ prob -> String Source #

markovToPs :: (Show state, Show cmd_, Show prob) => state -> state -> Markov state cmd_ prob -> FilePath -> IO () Source #

data StatsDb m Source #

Constructors

StatsDb 

Fields

testChainToDot :: forall state cmd_ prob m. (Show state, Ord state, Monad m) => (Generic state, GEnum FiniteEnum (Rep state)) => StatsDb m -> state -> state -> Markov state cmd_ prob -> m String Source #