reset password
Author Message
rabbott
Posts: 1649
Posted 22:55 Sep 25, 2019 |

It's taken longer than I expected to get a framework for the knapsack problem in shape to give you. Since there are only a couple of days until Saturday, I will give you running code. You may either use it or write your own. If you use this code, you must be able to explain how it works. 

There are two files:

solver.py -- an edited version of the file that comes with the Coursera Knapsack download. This version lets you run multiple solvers and multiple files in one run. (You will have to adjust the code to run a solver with submit.py.) This file also includes various greedy solvers, including a dynamic programming solver, similar to what is described in the video. The dynamic programming algorithm runs very slowly on large datasets.

bb_solver.py --  contains a branch-and-bound solver, similar to what is described in the video. (It's pretty fast. Can you beat its time.)

The GitHub repo mentioned below is more up-to-date.

Last edited by rabbott at 10:03 Sep 26, 2019.
rabbott
Posts: 1649
Posted 10:02 Sep 26, 2019 |

I have created a GitHub repository for this problem. It contains stable versions of the files. The links to files in the message above have been removed. Those copies of the files may be in the process of being edited.

Last edited by rabbott at 10:05 Sep 26, 2019.