Definition:
- Given a list of profit for each items, weight if each and a bag of weight W, that is the maximum profit
Fractional Knapsack Problem:
- optimal for FKP but can be arbitrarily bad for typical Knapsack Problem
- Steps
- Sort all the items by the ratio of their profits to their weights: w1p1≥w2p2…≥wnpn
- Greedily pick items in this order as long as adding an item to our collection does not exceed the capacity
- Modify greedy:
- Sort all the items by the ratio of their profits to their weights: w1p1≥w2p2…≥wnpn
- Greedily pick items in this order as long as adding an item to our collection does not exceed the capacity
- Take the best of algorithm 1’s solution or the most profitable item