The GA Playground: A Single 0/1 Knapsack Problem

 

A single knapsack problem with 50 objects

Description

A thief has a knapsack of a certain capacity. He looks around and sees different items of different weights and values. He would like the items he chooses for his knapsack to have the greatest value possible yet still fit in his knapsack. The problem is called the 0-1 Knapsack Problem because the thief can either take (1) or leave (0) each item.

Formal Description

Given a set of items, each with a cost and a value, determine the number of each item to include in a collection so that the total cost is less than some given cost and the total value is as large as possible.

The 0/1 knapsack problem restricts the number of each items to zero or one.

Formulation:

Maximize sum(x(i)*p(i))

Subject to sum(x(i)*w(i)) <= C

x(i) = 0 or 1

Problem Specific Notes:

Instructions:

You either do not have Java support or it is disabled in your browser


Ariel Dolan
aridolan@netvision.net.il