Copyright | (c) Masahiro Sakai 2011 |
---|---|
License | BSD-style |
Maintainer | masahiro.sakai@gmail.com |
Portability | non-portable (BangPatterns) |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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
- data Formula = Formula {
- pbObjectiveFunction :: Maybe Sum
- pbConstraints :: [Constraint]
- pbNumVars :: !Int
- pbNumConstraints :: !Int
- type Constraint = (Sum, Op, Integer)
- data Op
- data SoftFormula = SoftFormula {
- wboTopCost :: Maybe Integer
- wboConstraints :: [SoftConstraint]
- wboNumVars :: !Int
- wboNumConstraints :: !Int
- 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
Abstract Syntax
Pair of objective function and a list of constraints.
Formula | |
|
type Constraint = (Sum, Op, Integer) Source
Lhs, relational operator and rhs.
Relational operators
data SoftFormula Source
A pair of top cost and a list of soft constraints.
SoftFormula | |
|
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 Formula Source
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 SoftFormula Source
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 -> ShowS Source