Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase maxm from 10 to 20 #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mknapsack/_algos.f
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion mknapsack/_multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import logging
import warnings

from typing import List, Optional

Expand Down Expand Up @@ -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 '
Expand All @@ -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)
Expand Down