Skip to content

Commit dc00048

Browse files
authored
[docs] more updates to the Knapsack tutorial (#3217)
1 parent cd96cd4 commit dc00048

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

docs/src/tutorials/linear/knapsack.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,17 @@ import Test
4949

5050
# where there is a choice between ``n`` items, with item ``i`` having weight ``w_i``,
5151
# profit ``c_i`` and a decision variable ``x_i`` equal to 1 if the item is chosen
52-
# and 0 if not.
52+
# and 0 if not.
53+
# The capacity is a single real number ``C`` of the same number type as the
54+
# individual weights.
5355

5456
# ## Data
5557

56-
# The data for the problem is two vectors (one for the profits
58+
# The data for the problem consists of two vectors (one for the profits
5759
# and one for the weights) along with a capacity.
5860
# For our example, we use a capacity of 10 units
5961
capacity = 10;
60-
# and vector data
62+
# and the vector data
6163
profit = [5, 3, 2, 7, 4];
6264
weight = [2, 8, 4, 2, 5];
6365

@@ -69,7 +71,7 @@ weight = [2, 8, 4, 2, 5];
6971
# ultimately be called to solve the model, once it's constructed.
7072
model = Model(HiGHS.Optimizer)
7173

72-
# Next we need the decision variables for which items are chosen.
74+
# Next we need the decision variables representing which items are chosen.
7375
@variable(model, x[1:5], Bin)
7476

7577
# We now want to constrain those variables so that their combined
@@ -137,4 +139,4 @@ end
137139
solve_knapsack_problem(; profit = profit, weight = weight, capacity = capacity)
138140

139141
# We observe that the chosen items (1, 4 and 5) have the best
140-
# profit to weight ratio for in this particular example.
142+
# profit to weight ratio in this particular example.

0 commit comments

Comments
 (0)