• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exhaustive Search/Brute Force Algorithm for 0-1 Knapsack Problem

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

I've been tasked with creating a brute force program to solve the 0-1 knapsack problem. I have already set up my program to read data from the input file and to output and store that into variables for the weight, value, knapsack limit, and number of items. I am running into an issue with figuring out how to obtain all subsets of the given set and analyzing it. The following is the input data and my current code:

3

4
5
2 1 3 2
12 10 20 15

5
6
3 2 1 4 5
25 20 15 40 50

6
10
3 2 1 5 5 6
10 10 12 10 12 12




As you can see my solveInstance function is empty. The solveInstance function is meant to discover the amount of feasible subsets, the optimal value and subset, and how many optimal subsets there are.

Any tips to point me in the right direction would be much appreciated.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic