Fifty items and a capacity of 850 form a real knapsack instance, parsed from the same model file the external solver reads. No solving happens yet; the data includes four items that weigh nothing at all.

highlighted = computed this step

A bigger instance

The instance has 50 items and capacity 850. Why: chapters one through three fill a table for four items; this instance is real data from the same model family the external solver reads, parsed from that model file rather than typed in.

n=50, W=850n=50,\ W=850
Fifty-item knapsackRows I1 through I50, each cell showing weight and value.50 items, capacity 850I1w7v360I2w0v83I3w30v59I4w22v130I5w80v431I6w94v67I7w11v230I8w81v52I9w70v93I10w64v125I11w59v670I12w18v892I13w0v600I14w36v38I15w3v48I16w8v147I17w15v78I18w42v256I19w9v63I20w0v17I21w42v120I22w47v164I23w52v432I24w32v35I25w26v92I26w48v110I27w55v22I28w6v42I29w29v50I30w84v323I31w2v514I32w4v28I33w18v87I34w56v73I35w7v78I36w29v15I37w93v26I38w44v78I39w71v210I40w3v36I41w86v85I42w66v189I43w31v274I44w65v43I45w0v33I46w79v10I47w20v19I48w65v389I49w52v276I50w13v312items 50capacity 850DP optimum 7534

No computation yet

No item has been chosen. Why: this lesson only states the data — fifty exact weight and value pairs and one capacity — before any solving happens, the same separation chapter one draws between stating the problem and filling the table.

data only, no solve yet\text{data only, no solve yet}
Fifty-item knapsackRows I1 through I50, each cell showing weight and value.50 items, capacity 850I1w7v360I2w0v83I3w30v59I4w22v130I5w80v431I6w94v67I7w11v230I8w81v52I9w70v93I10w64v125I11w59v670I12w18v892I13w0v600I14w36v38I15w3v48I16w8v147I17w15v78I18w42v256I19w9v63I20w0v17I21w42v120I22w47v164I23w52v432I24w32v35I25w26v92I26w48v110I27w55v22I28w6v42I29w29v50I30w84v323I31w2v514I32w4v28I33w18v87I34w56v73I35w7v78I36w29v15I37w93v26I38w44v78I39w71v210I40w3v36I41w86v85I42w66v189I43w31v274I44w65v43I45w0v33I46w79v10I47w20v19I48w65v389I49w52v276I50w13v312items 50capacity 850DP optimum 7534

A wrinkle in the data

Four items weigh nothing at all. Why: real data is not always convenient — a zero-weight, positive-value item costs no capacity, so any optimal packing takes it for free; the DP table and the external solver both have to handle that edge case correctly, not just the typical case.

4 zero-weight items4\text{ zero-weight items}
Fifty-item knapsackRows I1 through I50, each cell showing weight and value.50 items, capacity 850I1w7v360I2w0v83I3w30v59I4w22v130I5w80v431I6w94v67I7w11v230I8w81v52I9w70v93I10w64v125I11w59v670I12w18v892I13w0v600I14w36v38I15w3v48I16w8v147I17w15v78I18w42v256I19w9v63I20w0v17I21w42v120I22w47v164I23w52v432I24w32v35I25w26v92I26w48v110I27w55v22I28w6v42I29w29v50I30w84v323I31w2v514I32w4v28I33w18v87I34w56v73I35w7v78I36w29v15I37w93v26I38w44v78I39w71v210I40w3v36I41w86v85I42w66v189I43w31v274I44w65v43I45w0v33I46w79v10I47w20v19I48w65v389I49w52v276I50w13v312items 50capacity 850DP optimum 7534

Diagram note

Every cell shows the item's own weight and value, parsed from the real model file. No cell is highlighted yet — selection happens once the instance is actually solved. Pixel positions are rounded for layout; every number shown is exact.

fifty items, no selection yet\text{fifty items, no selection yet}
Fifty-item knapsackRows I1 through I50, each cell showing weight and value.50 items, capacity 850I1w7v360I2w0v83I3w30v59I4w22v130I5w80v431I6w94v67I7w11v230I8w81v52I9w70v93I10w64v125I11w59v670I12w18v892I13w0v600I14w36v38I15w3v48I16w8v147I17w15v78I18w42v256I19w9v63I20w0v17I21w42v120I22w47v164I23w52v432I24w32v35I25w26v92I26w48v110I27w55v22I28w6v42I29w29v50I30w84v323I31w2v514I32w4v28I33w18v87I34w56v73I35w7v78I36w29v15I37w93v26I38w44v78I39w71v210I40w3v36I41w86v85I42w66v189I43w31v274I44w65v43I45w0v33I46w79v10I47w20v19I48w65v389I49w52v276I50w13v312items 50capacity 850DP optimum 7534