• Post Reply Bookmark Topic Watch Topic
  • New Topic

Knapsack problem simple solution  RSS feed

 
s ravi chandran
Ranch Hand
Posts: 579
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to solve Knapsack problem with a simple working solution. I have thought of how I would like to solve it. There is an issue, this solution is not fulfilling proper evaluation. My solution is evaluating the best approach is finding the items for the knapsack. But I am not iteratively calculating best possible combination of item here.

Also, I have not calculated correct ratio of value in case I have split the weight of an item to fill the knapsack to it's capacity.



How should I make this solution more proper?
 
Stefan Evans
Bartender
Posts: 1837
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does one calculate max value per weight?
I don't see anywhere in the program where you calculate this.
Right now you appear to be picking up the item with the highest value - which may not be optimal if it is also massively heavy.


 
s ravi chandran
Ranch Hand
Posts: 579
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:How does one calculate max value per weight?
I don't see anywhere in the program where you calculate this.
Right now you appear to be picking up the item with the highest value - which may not be optimal if it is also massively heavy.




That is a mistake from my side. Each item will have some weight and some value. I have to find the next item which has the best value among the remaining items.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!