toysolver-0.7.0: Assorted decision procedures for SAT, SMT, Max-SAT, PB, MIP, etc
Copyright(c) Masahiro Sakai 2015
LicenseBSD-style
Maintainermasahiro.sakai@gmail.com
Stabilityprovisional
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010
Extensions
  • ScopedTypeVariables
  • BangPatterns
  • FlexibleContexts
  • ExplicitForAll

ToySolver.Combinatorial.SubsetSum

Description

References

Synopsis

Documentation

subsetSum Source #

Arguments

:: Vector v Weight 
=> v Weight

weights [w1, w2 .. wn]

-> Weight
l
-> Maybe (Vector Bool)

the assignment [x1, x2 .. xn], identifying 0 (resp. 1) with False (resp. True).

Solve Σ_{i=1}^n wi x = c and xi ∈ {0,1}.

Note that this is different from usual definition of the subset sum problem, as this definition allows all xi to be zero.

Note: 0 (resp. 1) is identified with False (resp. True) in the assignment.

maxSubsetSum Source #

Arguments

:: Vector v Weight 
=> v Weight

weights [w1, w2 .. wn]

-> Weight

capacity c

-> Maybe (Weight, Vector Bool)
  • the objective value Σ_{i=1}^n wi xi, and
  • the assignment [x1, x2 .. xn], identifying 0 (resp. 1) with False (resp. True).

Maximize Σ_{i=1}^n wi xi subject to Σ_{i=1}^n wi xi ≤ c and xi ∈ {0,1}.

Note: 0 (resp. 1) is identified with False (resp. True) in the assignment.

minSubsetSum Source #

Arguments

:: Vector v Weight 
=> v Weight

weights [w1, w2 .. wn]

-> Weight
l
-> Maybe (Weight, Vector Bool)
  • the objective value Σ_{i=1}^n wi xi, and
  • the assignment [x1, x2 .. xn], identifying 0 (resp. 1) with False (resp. True).

Minimize Σ_{i=1}^n wi xi subject to Σ_{i=1}^n wi x≥ l and xi ∈ {0,1}.

Note: 0 (resp. 1) is identified with False (resp. True) in the assignment.