Algorithms project on bounded knapsack, presented as a profit optimization problem
For recurrence equations and proof of correctness, see report.pdf
.
*Not recommended. Python version is for verifying correctness of algorithm and testing on small inputs.*
jeweler_profit.py
can be run from the command line as follows:
python jeweler_profit.py - 1
, this takes user input from the command linepython jeweler_profit.py filename 1
, reads input from fileAlternatively, we can also use pytest
to test if everything works.
pytest
package using pip install -U pytest
.test_data
folder. Either rename all test files to the form in*.txt
or choose test files by changing the 7th line in test_jeweler_profit.py
. For example, to test the code against a file test_data/test_sample.txt
, change the 7th line to the following:TEST_FILES = ['test_data/test_sample.txt']
Note: I took this as an opportunity to learn Cython.
TODO: Add time benchmarks for Cython, Numba and Java.