I wrote an algorithm to find a solution to the subset sum problem in Haskell. The signature is
subsetSum :: (Ord a, Num a) => [a] -> a -> Maybe [a]
QuickCheck seems to be a good fit to test that. For example I here is one of the properties that I could check:
prop_sumEqualsS l s = case subsetSum l s of
Just solution -> (sum solution) == s
Nothing -> True
The problem is that the algorithm is quite computationally intensive and running 100 tests with big input lists takes ages to run.
I tried with QuickCheck 1 and it did run quickly, but the data sets used for testing were very small. After moving to QuickCheck 2 it seems to be the opposite problem. There is a manual for QC but it seems to be old (there is no date information) and I don't know how much still applies to QC2. A Tutorial is available on the Haskell Wiki but there is not much details, just a few words on instantiating Arbitrary
.
So I have two questions:
- What changes in QuickCheck 2 make it become so much slower than QuickCheck?
- What is the best way to control data sets creation to make them useful for a given test?
Edit: To be more specific, I would like to test my solution with a list size from 0 to 100, containing integers between -10000 and 10000.