Portability | non-portable (BangPatterns) |
---|---|
Maintainer | masahiro.sakai@gmail.com |
Safe Haskell | Safe-Inferred |
A parser library for .opb file and .wbo files used by PB Competition.
References:
- Input/Output Format and Solver Requirements for the Competitions of Pseudo-Boolean Solvers http://www.cril.univ-artois.fr/PB11/format.pdf
- type Formula = (Maybe Sum, [Constraint])
- type Constraint = (Sum, Op, Integer)
- data Op
- type SoftFormula = (Maybe Integer, [SoftConstraint])
- type SoftConstraint = (Maybe Integer, Constraint)
- type Sum = [WeightedTerm]
- type WeightedTerm = (Integer, Term)
- type Term = [Lit]
- type Lit = Int
- type Var = Int
- parseOPBString :: SourceName -> String -> Either ParseError Formula
- parseOPBFile :: FilePath -> IO (Either ParseError Formula)
- parseWBOString :: SourceName -> String -> Either ParseError SoftFormula
- parseWBOFile :: FilePath -> IO (Either ParseError SoftFormula)
- showOPB :: Formula -> ShowS
- showWBO :: SoftFormula -> ShowS
- pbNumVars :: Formula -> Int
- wboNumVars :: SoftFormula -> Int
Abstract Syntax
type Formula = (Maybe Sum, [Constraint])Source
Pair of objective function and a list of constraints.
type Constraint = (Sum, Op, Integer)Source
Lhs, relational operator and rhs.
Relational operators
type SoftFormula = (Maybe Integer, [SoftConstraint])Source
A pair of top cost and a list of soft constraints.
type SoftConstraint = (Maybe Integer, Constraint)Source
A pair of weight and constraint.
type Sum = [WeightedTerm]Source
Sum of WeightedTerm
type WeightedTerm = (Integer, Term)Source
Coefficient and Term
Positive (resp. negative) literal is represented as a positive (resp. negative) integer.
Parsing .opb files
parseOPBString :: SourceName -> String -> Either ParseError FormulaSource
Parse a .opb file containing pseudo boolean problem.
parseOPBFile :: FilePath -> IO (Either ParseError Formula)Source
Parse a .opb format string containing pseudo boolean problem.
Parsing .wbo files
parseWBOString :: SourceName -> String -> Either ParseError SoftFormulaSource
Parse a .wbo file containing weighted boolean optimization problem.
parseWBOFile :: FilePath -> IO (Either ParseError SoftFormula)Source
Parse a .wbo format string containing weighted boolean optimization problem.
Show .opb files
Show .wbo files
showWBO :: SoftFormula -> ShowSSource
Utility
wboNumVars :: SoftFormula -> IntSource