-
Notifications
You must be signed in to change notification settings - Fork 0
/
Heuristics.hs
33 lines (26 loc) · 1009 Bytes
/
Heuristics.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 : <File name or $Header$ to be replaced automatically>
Description : An implementation of DPLL in Haskell.
Copyright : (c) Joshua T. Guerin, Ph.D.
License : <license>
Maintainer : [email protected]
Stability : experimental
Portability : portable
<module description starting at first column>
-}
module Heuristics where
import Common
moms :: (Ord a, Num a) => [[a]] -> a
-- ^ Maximum occurrences of minimal size (MOMS) heuristic.
moms cnf = addSign moms_value cnf
where moms_value = moms' cnf
moms' :: (Ord c, Num c) => [[c]] -> c
-- ^ Helper generates positive MOMS value.
moms' cnf = mostFrequent $ map abs $ flatten $
filter (\c -> length c == min) cnf
where min = minimum $ map length cnf
addSign :: (Num a, Eq a) => a -> [[a]] -> a
-- ^ Helper for MOMS heuristic, selects sign for MOMS value.
addSign literal cnf = if count (negate literal) flat < count literal flat
then literal else (negate literal)
where flat = flatten cnf