module ToySolver.Converter.PBSetObj
( ObjType (..)
, setObj
) where
import qualified ToySolver.Text.PBFile as PBFile
import ToySolver.Converter.ObjType
setObj :: ObjType -> PBFile.Formula -> PBFile.Formula
setObj objType formula = formula{ PBFile.pbObjectiveFunction = Just obj2 }
where
obj2 = genObj objType formula
genObj :: ObjType -> PBFile.Formula -> PBFile.Sum
genObj objType formula =
case objType of
ObjNone -> []
ObjMaxOne -> [(1,[v]) | v <- [1 .. PBFile.pbNumVars formula]]
ObjMaxZero -> [(1,[ v]) | v <- [1 .. PBFile.pbNumVars formula]]