{-# OPTIONS_GHC -Wall #-}
module ToySolver.Converter.PBSetObj
( ObjType (..)
, setObj
) where
import qualified Data.PseudoBoolean as PBFile
import ToySolver.Converter.ObjType
setObj :: ObjType -> PBFile.Formula -> PBFile.Formula
setObj :: ObjType -> Formula -> Formula
setObj ObjType
objType Formula
formula = Formula
formula{ pbObjectiveFunction :: Maybe Sum
PBFile.pbObjectiveFunction = Sum -> Maybe Sum
forall a. a -> Maybe a
Just Sum
obj2 }
where
obj2 :: Sum
obj2 = ObjType -> Formula -> Sum
genObj ObjType
objType Formula
formula
genObj :: ObjType -> PBFile.Formula -> PBFile.Sum
genObj :: ObjType -> Formula -> Sum
genObj ObjType
objType Formula
formula =
case ObjType
objType of
ObjType
ObjNone -> []
ObjType
ObjMaxOne -> [(Integer
1,[-Lit
v]) | Lit
v <- [Lit
1 .. Formula -> Lit
PBFile.pbNumVars Formula
formula]]
ObjType
ObjMaxZero -> [(Integer
1,[ Lit
v]) | Lit
v <- [Lit
1 .. Formula -> Lit
PBFile.pbNumVars Formula
formula]]