jmyrberg / mknapsack

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

Fortran exceptions regarding Total sum of weights #52

Closed TadavomnisT closed 11 months ago

TadavomnisT commented 11 months ago

Hi,

Sorry if this issue seems a bit stupid, But when I try to run:

from mknapsack import solve_multiple_knapsack

res = solve_multiple_knapsack(
                profits=[25032,17185,57704,64358,11089,5354,3401,45784,9435,28668,41243,57777,9916,25841,36636,49305,37458,55364,40134,44312,3888,44793,6749,65862,67072,54439,57334,51055,49393,26305,35357,67324,64537,65625,56649,54558,28625],
                weights=[653250,965773,944737,671036,601642,1274815,1140173,996544,918682,889250,880779,775219,805400,911355,949676,1270782,687677,1049923,844992,581054,645960,517639,1211440,691625,839166,678857,1223638,564127,695884,479706,620077,709761,667338,646920,996692,729103,530888],
                capacities=[760918113,550545288,554599425,557182218,609915305,761528614,775865259,524277499,538024903,767863544,328247677,570234149,641681870,606040298,692398729,593140773,658394446,697797771,559652541,574848244]
            )

print( res )

I get:

┌──(user㉿dhcppc4)-[~/Desktop/mknapsack]
└─$ python test.py     
Traceback (most recent call last):
  File "/home/user/Desktop/mknapsack/test.py", line 3, in <module>
    res = solve_multiple_knapsack(
  File "/home/user/.local/lib/python3.10/site-packages/mknapsack/_multiple.py", line 174, in solve_multiple_knapsack
    raise FortranInputCheckError(method=method, z=z)
mknapsack._exceptions.FortranInputCheckError: Total sum of weights is smaller than largest knapsack

Now,

Total sum of weights is smaller than largest knapsack

Why? Seems to me It is ok if sum of weights is smaller than largest knapsack in some scenario...

I also tried changing the method to "mthm" but I figured its limit is set up to 10 knapsacks.


UPDATE:

Using method_kwargs={"check_inputs": 0} resolved the issue, but I'm still interested to find out that why would the total sum of weights being greater than largest knapsack is a problem?