-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Reading/Writing OPB/WBO files used in pseudo boolean competition -- @package pseudo-boolean @version 0.1.2.0 module Data.PseudoBoolean.Internal.TextUtil -- | read allocate too many intermediate Integer. Therefore -- we use this optimized implementation instead. Many intermediate values -- in this implementation will be optimized away by worker-wrapper -- transformation and unboxing. readUnsignedInteger :: String -> Integer module Data.PseudoBoolean.Builder -- | A builder which renders a OPB format in any String-like Monoid. opbBuilder :: (Monoid a, IsString a) => Formula -> a -- | A builder which renders a WBO format in any String-like Monoid. wboBuilder :: (Monoid a, IsString a) => SoftFormula -> a -- | Generate a OPB format string containing pseudo boolean problem. toOPBString :: Formula -> String -- | Generate a WBO format string containing weighted boolean optimization -- problem. toWBOString :: SoftFormula -> String module Data.PseudoBoolean.ByteStringBuilder -- | A ByteString Builder which renders a OPB format byte-string containing -- pseudo boolean problem. opbBuilder :: Formula -> Builder -- | A ByteString Builder which renders a WBO format byte-string containing -- weighted boolean optimization problem. wboBuilder :: SoftFormula -> Builder -- | Generate a OPB format byte-string containing pseudo boolean problem. toOPBByteString :: Formula -> ByteString -- | Generate a WBO format byte-string containing weighted boolean -- optimization problem. toWBOByteString :: SoftFormula -> ByteString -- | Output a OPB file containing pseudo boolean problem. writeOPBFile :: FilePath -> Formula -> IO () -- | Output a WBO file containing weighted boolean optimization problem. writeWBOFile :: FilePath -> SoftFormula -> IO () -- | Output a OPB file to a Handle using hPutBuilder. -- -- It is recommended that the Handle is set to binary and -- BlockBuffering mode. See hSetBinaryMode and -- hSetBuffering. -- -- This function is more efficient than hPut . -- toOPBByteString because in many cases no buffer allocation has -- to be done. hPutOPB :: Handle -> Formula -> IO () -- | Output a WBO file to a Handle using hPutBuilder. -- -- It is recommended that the Handle is set to binary and -- BlockBuffering mode. See hSetBinaryMode and -- hSetBuffering. -- -- This function is more efficient than hPut . -- toWBOByteString because in many cases no buffer allocation has -- to be done. hPutWBO :: Handle -> SoftFormula -> IO () -- | A parser library for OPB/WBO files used in pseudo boolean competition. -- -- References: -- -- module Data.PseudoBoolean.Attoparsec -- | Parser for OPB files opbParser :: Parser Formula -- | Parse a OPB format string containing pseudo boolean problem. parseOPBByteString :: ByteString -> Either String Formula -- | Parse a OPB file containing pseudo boolean problem. parseOPBFile :: FilePath -> IO (Either String Formula) -- | Parser for WBO files wboParser :: Parser SoftFormula -- | Parse a WBO format string containing weighted boolean optimization -- problem. parseWBOByteString :: ByteString -> Either String SoftFormula -- | Parse a WBO file containing weighted boolean optimization problem. parseWBOFile :: FilePath -> IO (Either String SoftFormula) -- | A parser library for OPB file and WBO files used in pseudo boolean -- competition. -- -- References: -- -- module Data.PseudoBoolean.Parsec -- | Parser for OPB files opbParser :: Stream s m Char => ParsecT s u m Formula -- | Parse a OPB format string containing pseudo boolean problem. parseOPBString :: SourceName -> String -> Either ParseError Formula -- | Parse a OPB format lazy bytestring containing pseudo boolean problem. parseOPBByteString :: SourceName -> ByteString -> Either ParseError Formula -- | Parse a OPB file containing pseudo boolean problem. parseOPBFile :: FilePath -> IO (Either ParseError Formula) -- | Parser for WBO files wboParser :: Stream s m Char => ParsecT s u m SoftFormula -- | Parse a WBO format string containing weighted boolean optimization -- problem. parseWBOString :: SourceName -> String -> Either ParseError SoftFormula -- | Parse a WBO format lazy bytestring containing pseudo boolean problem. parseWBOByteString :: SourceName -> ByteString -> Either ParseError SoftFormula -- | Parse a WBO file containing weighted boolean optimization problem. parseWBOFile :: FilePath -> IO (Either ParseError SoftFormula) -- | A library for parsing/generating OPB/WBO files used in pseudo boolean -- competition. -- -- References: -- -- module Data.PseudoBoolean -- | Pair of objective function and a list of constraints. data Formula Formula :: Maybe Sum -> [Constraint] -> !Int -> !Int -> Formula pbObjectiveFunction :: Formula -> Maybe Sum pbConstraints :: Formula -> [Constraint] pbNumVars :: Formula -> !Int pbNumConstraints :: Formula -> !Int -- | Lhs, relational operator and rhs. type Constraint = (Sum, Op, Integer) -- | Relational operators data Op -- | greater than or equal Ge :: Op -- | equal Eq :: Op -- | A pair of top cost and a list of soft constraints. data SoftFormula SoftFormula :: Maybe Integer -> [SoftConstraint] -> !Int -> !Int -> SoftFormula wboTopCost :: SoftFormula -> Maybe Integer wboConstraints :: SoftFormula -> [SoftConstraint] wboNumVars :: SoftFormula -> !Int wboNumConstraints :: SoftFormula -> !Int -- | A pair of weight and constraint. type SoftConstraint = (Maybe Integer, Constraint) -- | Sum of WeightedTerm type Sum = [WeightedTerm] -- | Coefficient and Term type WeightedTerm = (Integer, Term) -- | List of variables interpreted as products type Term = [Lit] -- | Positive (resp. negative) literals are represented as positive (resp. -- negative) integers. type Lit = Int -- | Variable are repserented as positive integers. type Var = Int -- | Parse a OPB format string containing pseudo boolean problem. parseOPBString :: SourceName -> String -> Either ParseError Formula -- | Parse a OPB format lazy bytestring containing pseudo boolean problem. parseOPBByteString :: SourceName -> ByteString -> Either ParseError Formula -- | Parse a OPB file containing pseudo boolean problem. parseOPBFile :: FilePath -> IO (Either ParseError Formula) -- | Parse a WBO format string containing weighted boolean optimization -- problem. parseWBOString :: SourceName -> String -> Either ParseError SoftFormula -- | Parse a WBO format lazy bytestring containing pseudo boolean problem. parseWBOByteString :: SourceName -> ByteString -> Either ParseError SoftFormula -- | Parse a WBO file containing weighted boolean optimization problem. parseWBOFile :: FilePath -> IO (Either ParseError SoftFormula) -- | Generate a OPB format string containing pseudo boolean problem. toOPBString :: Formula -> String -- | Generate a OPB format byte-string containing pseudo boolean problem. toOPBByteString :: Formula -> ByteString -- | Output a OPB file containing pseudo boolean problem. writeOPBFile :: FilePath -> Formula -> IO () -- | Output a OPB file to a Handle using hPutBuilder. -- -- It is recommended that the Handle is set to binary and -- BlockBuffering mode. See hSetBinaryMode and -- hSetBuffering. -- -- This function is more efficient than hPut . -- toOPBByteString because in many cases no buffer allocation has -- to be done. hPutOPB :: Handle -> Formula -> IO () -- | Generate a WBO format string containing weighted boolean optimization -- problem. toWBOString :: SoftFormula -> String -- | Generate a WBO format byte-string containing weighted boolean -- optimization problem. toWBOByteString :: SoftFormula -> ByteString -- | Output a WBO file containing weighted boolean optimization problem. writeWBOFile :: FilePath -> SoftFormula -> IO () -- | Output a WBO file to a Handle using hPutBuilder. -- -- It is recommended that the Handle is set to binary and -- BlockBuffering mode. See hSetBinaryMode and -- hSetBuffering. -- -- This function is more efficient than hPut . -- toWBOByteString because in many cases no buffer allocation has -- to be done. hPutWBO :: Handle -> SoftFormula -> IO ()