Search⌘ K
AI Features

Exercises

Explore practical exercises to solve various linear constrained optimization problems using Python. Learn to handle fractional and integer constraints in knapsack and product mix problems, and optimize investment portfolios with real restrictions. This lesson enhances your skills by applying theory to real-world challenges using Python tools.

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 ...