diff --git a/mknapsack/_algos.f b/mknapsack/_algos.f index 5098d5a..1fb0f52 100644 --- a/mknapsack/_algos.f +++ b/mknapsack/_algos.f @@ -673,7 +673,7 @@ subroutine chmtm(n,m,p,w,c,maxn,maxm,z) c ISBN: 0-471-92420-2, c LC: QA267.7.M37. c - integer p(1000),w(1000),c(10),z + integer p(1000),w(1000),c(20),z if ( n .le. 1 ) z = - 1 if ( n .gt. maxn ) z = - 1 @@ -8243,7 +8243,7 @@ subroutine mtm ( n, m, p, w, c, z, x, back, jck, jub ) cf2py intent(in) n, m, p, w, c, jck, back cf2py intent(hide) jub cf2py intent(out) z, x, back - integer p(1000),w(1000),c(10),x(1000),back,z + integer p(1000),w(1000),c(20),x(1000),back,z integer bb(10,1000),bl(10,1001),xc(10,1000),xl(10,1000) integer b(1001),ubb(1000) integer f(10),pbl(10),q(10),v(10),s,u,ub,vb @@ -8253,7 +8253,7 @@ subroutine mtm ( n, m, p, w, c, z, x, back, jck, jub ) common /pub/ lx(1000),lxi(1000),lr,lri,lubi maxn = 1000 - maxm = 10 + maxm = 20 z = 0 if ( jck .eq. 1 ) then diff --git a/mknapsack/_multiple.py b/mknapsack/_multiple.py index 5f11ee9..cbb3e05 100644 --- a/mknapsack/_multiple.py +++ b/mknapsack/_multiple.py @@ -2,6 +2,7 @@ import logging +import warnings from typing import List, Optional @@ -123,7 +124,8 @@ def solve_multiple_knapsack( if method == 'mtm': # These are checked Fortran side as well, but would fail at padding maxn = 1000 - maxm = 10 + maxm = 20 + warnm = 10 if n > maxn: raise ValueError( f'Number of items ({n}) cannot be greater than {maxn} for ' @@ -132,6 +134,10 @@ def solve_multiple_knapsack( raise ValueError( f'Number of knapsacks ({m}) cannot be greater than {maxm} for ' f'method="{method}", please try for example method="mthm"') + elif verbose and m > warnm: + warnings.warn( + 'Using more than 10 knapsacks may cause the problem ' + 'to take too long! Consider using fewer knapsacks.') p = pad_array(profits, maxn) w = pad_array(weights, maxn)