jmyrberg / mknapsack

Algorithms for solving knapsack problems with Python
MIT License
45 stars 14 forks source link

ValueError: Solution not valid #13

Closed yutozh closed 4 years ago

yutozh commented 4 years ago

When I test a case, it raise a "ValueError: Solution not valid". It seems like a bug when doing "Ensure solution validity".

from mknapsack.algorithms import mtm
profits = [1,1]
weights = [1,1]
capacities = [2,2]

z, x, bt, glopt = mtm(profits, weights, capacities)
print('Total profit: %d' % z)
print('Solution: %s' % x)
print('Number of backtracks performed: %d' % bt)
print('Global optimum: %s' % glopt)

The error is: ValueError: Solution not valid: p w c valid i
0 2 2.0 2 1

How to solve this problem?

jmyrberg commented 4 years ago

Resolved.