Let’s solve some continuous and discrete linear optimization problems.

Exercise 1: Fractional knapsack

The fractional knapsack is the continuous version of the knapsack problem. In this version, we can get a fraction of the item. The value would be the same fraction of the item’s value and weight of the same fraction of the weight. For example, consider an item of value 66 and a weight of 99kg. If we decide to take one-third of the item, then we get value 136=2\frac{1}{3} * 6 = 2 from the object, and the weight added to the load will be 139=3\frac{1}{3} * 9 = 3kg. As in the knapsack problem, the constraint is not to load more than the maximum weight allowed and the goal is to get as much value as possible.

In this exercise, we have to solve the fractional version of the knapsack problem.

Get hands-on with 1400+ tech skills courses.