Commit 7c5e2077 authored by AVANZINI Martin's avatar AVANZINI Martin
Browse files

check for constant GExps completed

parent f98b45a3
......@@ -7,7 +7,7 @@ def trader():
price = price + 1
else:
price = price - 1
nShares = unif(0,20)
nShares = unif(0,1)
while nShares > 0:
nShares = nShares - 1
tick price
......@@ -157,7 +157,9 @@ runAny m = listToMaybe <$> run Any m
ramp :: (Eq c, Num c) => E.Exp -> C.CExp c
ramp e = C.guarded (e .>= 0) (C.fromExp e)
isConstGExp (C.GExp g _ e) = null (E.variables e) && S.null (B.variables g)
isConstGExp (C.GExp _ _ 0) = True
isConstGExp (C.GExp Bot _ _) = True
isConstGExp (C.GExp g _ e) = null (E.variables e) && S.null (B.variables g)
varGExps :: (Eq c, Num c) => C.CExp c -> [C.GExp c]
varGExps = filter (not . isConstGExp) . C.gExps
......@@ -368,7 +370,7 @@ et t (NonDet e1 e2) f = C.sup <$> etM t e1 f <*> etM t e2 f
et t (Choice ls) f = discreteExpectation ls (\ c -> etM t c f)
et t (Cond _ i b c1 c2) f = C.guarded i <$> (C.cond b <$> etM t c1 f <*> etM t c2 f)
et Ect (Seq c1 c2) f
| isSimple c1 = ect c1 =<< ect c2 f
| isSimple c1 = et Ect c1 =<< et Ect c2 f
| otherwise = C.plus <$> ect c1 C.zero <*> (evt c1 =<< ect c2 f)
et t (Seq c1 c2) f = etM t c1 =<< etM t c2 f
et t (While _ i b c) f =
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment