-
Notifications
You must be signed in to change notification settings - Fork 1
/
Plot.hs
35 lines (26 loc) · 1.19 KB
/
Plot.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module Plot where
import qualified Mixture as M
import qualified Counter as C
import qualified State as S
import qualified Env as E
import Misc
type Observations = [(E.VarId, S.NumInstances)]
type Plot = [(C.Time, C.Events, Observations)]
obs :: E.Env -> S.State -> Observations
obs env state@(S.State{ S.observables = obs }) = map numInstances obs
where numInstances :: M.Expr -> (E.VarId, S.NumInstances)
numInstances mix = (mixId, S.instanceNumber mixId state env)
where mixId = M.getId mix ? "Plot.obs: no id for observable"
create :: E.Env -> S.State -> Plot
create env initialState = [(0, 0, obs env initialState)]
add :: E.Env -> S.State -> C.Counter -> Plot -> Plot
add env state (C.Counter{ C.time = currentTime, C.events = currentEvent, C.dE = dE, C.dT = dT }) plot =
if isStep dE dT
then (currentTime, currentEvent, obs env state) : plot
else plot
where isStep Nothing Nothing = error "Plot.add: dT and dE missing"
isStep (Just dE) _ = currentEvent - lastEvent == dE -- preference is given to dE
isStep _ (Just dT) = currentTime - lastTime == dT
(lastTime, lastEvent, _) = head plot
--save :: String -> Plot -> IO ()
--save filename plot =