J.T. Timpanaro
Parallel Functional Programming
Fall 2019
Parallelized Dynamic Programming Solution for the 0-1 Knapsack Problem

--------------------------------------------------------------------------
BUILDING

`ghc -O2 -Wall -threaded -rtsopts .\knapsack.hs`

Note: Can also add the flag -eventlog if parallel profiling wanted.

--------------------------------------------------------------------------
RUNNING

`knapsack <testfile> <#chunks> +RTS -N4 -s`

<testfile>: Path to test file. Default tests are located in the tests
            directory. Suggested value is tests/test8.txt.

<#chunks>:  Number of chunks to run parallel computation on. Suggested
            value is 1024.

Note: Can also add the flag -ls if interested in writing logfile.
      Can change number in flag -N4 to desired number of cores.

--------------------------------------------------------------------------
TEST FILES

Test files must be consist of three lines. The first line contains one
value representing the capacity of the knapsack. The second contains
whitespace separated values representing the weights of the available
items. The third contains whitespace separated values representing the
values of the available items. The default tests are located in the tests
directory and are named: test1.txt, test2.txt, ..., test8.txt.

Example:
11
3 5 9
8 8 3

In the above example the knapsack has a capacity of 11, and three items.
Item 1 has weight 3 and value 8, 2 has weight 5 and value 8, 3 has weight
9 and value 3.

--------------------------------------------------------------------------
INTERPRETING OUTPUT

Program output is of the form:
Solution: [1,4,5,6]
Total Value: 40

The numbers in solution represent the 1-indexed items to take, and the
the total value is the sum of the values of these items.

--------------------------------------------------------------------------
REFERENCES

Tests:
https://people.sc.fsu.edu/~jburkardt/datasets/knapsack_01/knapsack_01.html

Reference algorithm:
https://en.wikipedia.org/wiki/Knapsack_problem#0/1_knapsack_problem

Package references:
https://hackage.haskell.org/
