packages feed

pseudo-boolean 0.1.11.0 → 0.1.12.0

raw patch · 5 files changed

+50/−14 lines, 5 filesdep +integer-logarithmsdep ~basePVP ok

version bump matches the API change (PVP)

Dependencies added: integer-logarithms

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

CHANGELOG.markdown view
@@ -1,3 +1,8 @@+0.1.12.0+-------+* fix to to use correct hint name: `mincost=`, `maxcost=`, and `sumcost=` do not need `#`-prefix+* generate `#equal=` hint and `intsize=` hint specified for PB24 competition+ 0.1.11.0 ------- * some minor clean-up
README.md view
@@ -1,7 +1,7 @@ # pseudo-boolean Haskell library for parsing/generating OPB/WBO files used in pseudo boolean competition. -[![Build Status](https://github.com/msakai/pseudo-boolean/workflows/build/badge.svg)](https://github.com/msakai/pseudo-boolean/actions)+[![Build Status](https://github.com/msakai/pseudo-boolean/actions/workflows/build.yaml/badge.svg)](https://github.com/msakai/pseudo-boolean/actions/workflows/build.yaml) [![Coverage Status](https://coveralls.io/repos/msakai/pseudo-boolean/badge.svg)](https://coveralls.io/r/msakai/pseudo-boolean) [![Hackage](https://img.shields.io/hackage/v/pseudo-boolean.svg)](https://hackage.haskell.org/package/pseudo-boolean) [![Hackage Deps](https://img.shields.io/hackage-deps/v/pseudo-boolean.svg)](https://packdeps.haskellers.com/feed?needle=pseudo-boolean)
pseudo-boolean.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                pseudo-boolean-version:             0.1.11.0+version:             0.1.12.0 synopsis:            Reading/Writing OPB/WBO files used in pseudo boolean competition description:         Reading\/Writing OPB\/WBO files used in pseudo boolean competition homepage:            https://github.com/msakai/pseudo-boolean@@ -31,7 +31,9 @@    GHC ==9.0.2    GHC ==9.2.8    GHC ==9.4.8-   GHC ==9.6.4+   GHC ==9.6.6+   GHC ==9.8.4+   GHC ==9.10.1  source-repository head   type:     git@@ -57,7 +59,7 @@      FlexibleContexts      OverloadedStrings   build-depends:-     base >=4.6.0.1 && <4.20,+     base >=4.6.0.1 && <4.22,      containers >=0.4.2.1,      parsec >=3.1.2 && <4,      megaparsec >=4 && <10,@@ -66,7 +68,8 @@      dlist >=0.7.0 && <1.1.0,      attoparsec >=0.10.4.0,      deepseq >=1.3.0.0,-     hashable >=1.1.2.5 && <1.5.0.0,+     hashable >=1.1.2.5 && <1.6.0.0,+     integer-logarithms >=1.0.2 && <1.1,      void   hs-source-dirs:      src   default-language:    Haskell2010@@ -81,7 +84,7 @@     bytestring,     tasty >=0.10.1,     tasty-hunit >=0.9 && <0.11,-    tasty-quickcheck >=0.8 && <0.11,+    tasty-quickcheck >=0.8 && <0.12,     tasty-th,     HUnit,     QuickCheck >=2.5 && <3,
src/Data/PseudoBoolean/Builder.hs view
@@ -27,9 +27,11 @@ import qualified Data.IntSet as IntSet import qualified Data.Set as Set import Data.List (sortBy)+import Data.Maybe (maybeToList) import Data.Monoid hiding (Sum (..)) import Data.Ord import Data.String+import Math.NumberTheory.Logarithms (integerLog2) import Text.Printf import Data.PseudoBoolean.Types @@ -39,10 +41,16 @@   where     nv = pbNumVars opb     nc = pbNumConstraints opb+    neq = length [() | (_lhs, Eq, _rhs) <- pbConstraints opb]+    intsize = maximum $ 0 :+      [ if tmp == 0 then 0 else 1 + integerLog2 tmp+      | (ts, d) <- [(ts, 0) | ts <- maybeToList (pbObjectiveFunction opb)] ++ [(lhs,rhs) | (lhs,_op,rhs) <- pbConstraints opb]+      , let tmp = abs d + Prelude.sum [abs c | (c,_) <- ts]+      ]     p = pbProducts opb     np = Set.size p     sp = Prelude.sum [IntSet.size tm | tm <- Set.toList p]-    size = fromString (printf "* #variable= %d #constraint= %d" nv nc)+    size = fromString (printf "* #variable= %d #constraint= %d #equal= %d intsize= %d" nv nc neq intsize)          <> (if np >= 1 then fromString (printf " #product= %d sizeproduct= %d" np sp) else mempty)          <> fromString "\n"     part1 = @@ -57,6 +65,7 @@   where     nv = wboNumVars wbo     nc = wboNumConstraints wbo+    neq = length [() | (_, (_lhs, Eq, _rhs)) <- wboConstraints wbo]     p = wboProducts wbo     np = Set.size p     sp = Prelude.sum [IntSet.size tm | tm <- Set.toList p]@@ -66,10 +75,15 @@         cs -> minimum cs     maxcost = maximum $ 0 : [c | (Just c, _) <- wboConstraints wbo]     sumcost = Prelude.sum [c | (Just c, _) <- wboConstraints wbo]-    size = fromString (printf "* #variable= %d #constraint= %d" nv nc)+    intsize = maximum $ 0 :+      [ if tmp == 0 then 0 else 1 + integerLog2 tmp+      | (cs, d) <- ([sumcost], 0) : [(map fst lhs, rhs) | (_,(lhs,_op,rhs)) <- wboConstraints wbo]+      , let tmp = abs d + Prelude.sum [abs c | c <- cs]+      ]+    size = fromString (printf "* #variable= %d #constraint= %d #equal= %d intsize= %d" nv nc neq intsize)          <> (if np >= 1 then fromString (printf " #product= %d sizeproduct= %d" np sp) else mempty)          <> fromString (printf " #soft= %d" (wboNumSoft wbo))-         <> fromString (printf " #mincost= %d #maxcost= %d #sumcost= %d" mincost maxcost sumcost)+         <> fromString (printf " mincost= %d maxcost= %d sumcost= %d" mincost maxcost sumcost)          <> fromString "\n"     part1 =        case wboTopCost wbo of
src/Data/PseudoBoolean/ByteStringBuilder.hs view
@@ -32,10 +32,12 @@ import qualified Data.IntSet as IntSet import qualified Data.Set as Set import Data.List (sortBy)+import Data.Maybe (maybeToList) import Data.Monoid hiding (Sum (..)) import qualified Data.ByteString.Lazy as BS import Data.ByteString.Builder (Builder, intDec, integerDec, char7, string7, hPutBuilder, toLazyByteString) import Data.Ord+import Math.NumberTheory.Logarithms (integerLog2) import System.IO import Data.PseudoBoolean.Types @@ -45,10 +47,16 @@   where     nv = pbNumVars opb     nc = pbNumConstraints opb+    neq = length [() | (_lhs, Eq, _rhs) <- pbConstraints opb]+    intsize = maximum $ 0 :+      [ if tmp == 0 then 0 else 1 + integerLog2 tmp+      | (ts, d) <- [(ts, 0) | ts <- maybeToList (pbObjectiveFunction opb)] ++ [(lhs,rhs) | (lhs,_op,rhs) <- pbConstraints opb]+      , let tmp = abs d + Prelude.sum [abs c | (c,_) <- ts]+      ]     p = pbProducts opb     np = Set.size p     sp = Prelude.sum [IntSet.size tm | tm <- Set.toList p]-    size = string7 "* #variable= " <> intDec nv <> string7 " #constraint= " <> intDec nc+    size = string7 "* #variable= " <> intDec nv <> string7 " #constraint= " <> intDec nc <> string7 " #equal= " <> intDec neq <> string7 " intsize= " <> intDec intsize          <> (if np >= 1 then string7 " #product= " <> intDec np <> string7 " sizeproduct= " <> intDec sp else mempty)          <> char7 '\n'     part1 = @@ -63,6 +71,7 @@   where     nv = wboNumVars wbo     nc = wboNumConstraints wbo+    neq = length [() | (_, (_lhs, Eq, _rhs)) <- wboConstraints wbo]     p = wboProducts wbo     np = Set.size p     sp = Prelude.sum [IntSet.size tm | tm <- Set.toList p]@@ -72,12 +81,17 @@         cs -> minimum cs     maxcost = maximum $ 0 : [c | (Just c, _) <- wboConstraints wbo]     sumcost = Prelude.sum [c | (Just c, _) <- wboConstraints wbo]-    size = string7 "* #variable= " <> intDec nv <> string7 " #constraint= " <> intDec nc+    intsize = maximum $ 0 :+      [ if tmp == 0 then 0 else 1 + integerLog2 tmp+      | (cs, d) <- ([sumcost], 0) : [(map fst lhs, rhs) | (_,(lhs,_op,rhs)) <- wboConstraints wbo]+      , let tmp = abs d + Prelude.sum [abs c | c <- cs]+      ]+    size = string7 "* #variable= " <> intDec nv <> string7 " #constraint= " <> intDec nc <> string7 " #equal= " <> intDec neq <> string7 " intsize= " <> intDec intsize          <> (if np >= 1 then string7 " #product= " <> intDec np <> string7 " sizeproduct= " <> intDec sp else mempty)          <> string7 " #soft= " <> intDec (wboNumSoft wbo)-         <> string7 " #mincost= " <> integerDec mincost-         <> string7 " #maxcost= " <> integerDec maxcost-         <> string7 " #sumcost= " <> integerDec sumcost+         <> string7 " mincost= " <> integerDec mincost+         <> string7 " maxcost= " <> integerDec maxcost+         <> string7 " sumcost= " <> integerDec sumcost          <> char7 '\n'     part1 =        case wboTopCost wbo of