module ToySolver.Converter.MaxSAT2WBO
( convert
) where
import qualified Data.PseudoBoolean as PBFile
import qualified ToySolver.Text.MaxSAT as MaxSAT
convert :: MaxSAT.WCNF -> PBFile.SoftFormula
convert
MaxSAT.WCNF
{ MaxSAT.topCost = top
, MaxSAT.clauses = cs
, MaxSAT.numVars = nv
, MaxSAT.numClauses = nc
} =
PBFile.SoftFormula
{ PBFile.wboTopCost = Nothing
, PBFile.wboConstraints = map f cs
, PBFile.wboNumVars = nv
, PBFile.wboNumConstraints = nc
}
where
f (w,ls)
| w>=top = (Nothing, p)
| otherwise = (Just w, p)
where
p = ([(1,[l]) | l <- ls], PBFile.Ge, 1)