Commit 84cd7664 authored by AVANZINI Martin's avatar AVANZINI Martin
Browse files

squash

parent e6e359f6
......@@ -172,6 +172,13 @@ templateToNorms p = nub $
| (_,m) <- P.toMonos p]
where zeroN (C.Norm _ e) = e == 0
squash :: [C.Norm] -> [C.Norm]
squash = foldl ins [] where
ins [] n = [n]
ins (C.Norm gm (E.AddConst m' cm):ns) (C.Norm _ (E.AddConst n' cn))
| n' == m' = ins ns (C.Norm gm (n' + E.constant (max cn cm)))
ins (m:ns) n = m : ins ns n
normTemplateEq :: NormTemplate -> NormTemplate -> Bool
p1 `normTemplateEq` p2 = and $ P.coefficients $
P.zipCoefficientsWith (const False) (const False) (\ _ _ -> True) p1 p2
......@@ -322,7 +329,7 @@ extractRanking body i c g f = fmap templateToNorms $ do
<|> template "conditions" (refine conds lin)
<|> template "shift-max" (refine shiftMax lin)
<|> template "mixed-lin" (pure (grdNorm * lin + lin))
<|> template "mixed-square" (pure (grdNorm * grdNorm + lin))
-- <|> template "mixed-square" (pure (grdNorm * grdNorm + lin))
<|> template "square-shift-max" ((\a -> lin * lin + a) <$> refine shiftMax lin)
where
refine m r = do
......
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