The knapsack problem is indeed a fundamental problem in optimization and constraint programming. It serves as a classic example to illustrate various techniques, including greedy algorithms, dynamic programming, and constraint programming.
Let n be the number of items.
Let W be the maximum capacity of the knapsack.
Let w[i] be the weight of item i.
Let p[i] be the profit/value of item i.
The sum of the weights of the selected items must not exceed the capacity of the backpack.
Maximize the total value of the selected objects, by adding the values of the objects based on the binary variables.