Knapsack Optimization with Python

preview_player
Показать описание
The purpose of the knapsack problem is to select which items to fit into the bag without exceeding a weight limit of what can be carried. We solve the problem with an integer programming solver (APOPT) by setting up each item as a binary variable (0 or 1).

Objective: Maximize the value of items that can fit into a knapsack without exceeding a maximum weight constraint.

There are 4 items available to be placed in a knapsack: a towel, hammer, wrench, and screwdriver. The value and weight of the items are listed in the table below.

Towel Hammer Wrench Screwdriver
Item Value (vi) 11 8 3 6
Item Weight (wi) 3 5 7 4
Рекомендации по теме
Комментарии
Автор

Very good classroom, thanks Professor

scvne
Автор

Helped me a lot! Thanks for sharing this amazing content :)

lucasbernardoni
Автор

proff, is this mixed integer solution taking linear time for selecting the items needed?
the greedy one takes n logn as we have to sort and then take the ones needed

supriyamanna
Автор

Professor do you see that I’m in necessity to learn MATLAB as I used to use python

hassanlaqrabti