posted 1 year ago

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?

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

posted 1 year ago

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.

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.