Skip to content

Commit

Permalink
generate '#soft=' in header line of WBO files
Browse files Browse the repository at this point in the history
  • Loading branch information
msakai committed Jun 20, 2015
1 parent a41a776 commit 36c3d2e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.markdown
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
0.1.1.0
-------
* parse* functions fails if the parser does not consume all of the inputs
* generate '#product=' and 'sizeproduct=' in header line of OPB/WBO files
* generate '#product=', 'sizeproduct=' and '#soft=' in header line of OPB/WBO files
1 change: 1 addition & 0 deletions src/Data/PseudoBoolean/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ wboBuilder wbo = size <> part1 <> part2
sp = Prelude.sum [IntSet.size tm | tm <- Set.toList p]
size = fromString (printf "* #variable= %d #constraint= %d" nv nc)
<> (if np >= 1 then fromString (printf " #product= %d sizeproduct= %d" np sp) else mempty)
<> fromString (printf " #soft= %d" (wboNumSoft wbo))
<> fromString "\n"
part1 =
case wboTopCost wbo of
Expand Down
1 change: 1 addition & 0 deletions src/Data/PseudoBoolean/ByteStringBuilder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ wboBuilder wbo = size <> part1 <> part2
sp = Prelude.sum [IntSet.size tm | tm <- Set.toList p]
size = string7 "* #variable= " <> intDec nv <> string7 " #constraint= " <> intDec nc
<> (if np >= 1 then string7 " #product= " <> intDec np <> string7 " sizeproduct= " <> intDec sp else mempty)
<> string7 " #soft= %d" <> intDec (wboNumSoft wbo)
<> char7 '\n'
part1 =
case wboTopCost wbo of
Expand Down
4 changes: 4 additions & 0 deletions src/Data/PseudoBoolean/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module Data.PseudoBoolean.Types
, pbProducts
, wboComputeNumVars
, wboProducts
, wboNumSoft
) where

import GHC.Generics (Generic)
Expand Down Expand Up @@ -140,3 +141,6 @@ wboProducts softformula = Set.fromList $ do
let tm2 = IntSet.fromList tm
guard $ IntSet.size tm2 > 1
return tm2

wboNumSoft :: SoftFormula -> Int
wboNumSoft softformula = length [() | (Just _, _) <- wboConstraints softformula]

0 comments on commit 36c3d2e

Please sign in to comment.