Commit af1a19bf authored by AVANZINI Martin's avatar AVANZINI Martin
Browse files

mixed template added

parent 0e7fba83
......@@ -293,14 +293,17 @@ template name = logBlkIdM (name++"-template")
extractRanking :: C -> BExp -> BExp -> CExp -> CExp -> SolveM [C.Norm]
extractRanking body i c g f = fmap toNormList $ do
lin <- linearTemplate
let gNorm = normFromCExp g
fNorm = normFromCExp f
grdNorm = normFromBExp i + normFromBExp c
df <- substituteM delta fNorm
let lin = normFromExp 1 + grdNorm + fNorm + gNorm + sum [ normFromBExp c * df ]
template "linear" (pure lin)
<|> template "shift-avg" (refine shiftAvg lin)
<|> template "conditions" (refine conds lin)
<|> template "shift-max" (refine shiftMax lin)
<|> do
let sq = lin * lin
template "square" (pure sq)
<|> template "mixed" (pure (grdNorm * grdNorm + lin))
<|> template "square" (pure (lin * lin + lin))
where
toNormList p = filter (not . zeroN) [ C.prodN [ C.expN n k | (n,k) <- P.toPowers m ]
| (_,m) <- P.toMonos p]
......@@ -310,17 +313,6 @@ extractRanking body i c g f = fmap toNormList $ do
r' <- m r
if r' `normTemplateEq` r then empty else pure r'
linearTemplate = do
let gNorm = normFromCExp g
fNorm = normFromCExp f
grdNorm = normFromBExp i + normFromBExp c
df <- substituteM delta fNorm
logMsg2 "gNorm" gNorm
logMsg2 "fNorm" fNorm
logMsg2 "grdNorm" grdNorm
logMsg2 "fDiff" df
pure (normFromExp 1 + grdNorm + fNorm + gNorm + sum [ normFromBExp c * df ])
shiftAvg = substituteM s where
s n@(C.Norm _ e) = do
evn <- etM Evt body (C.nm 1 n)
......
Markdown is supported
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