@@ -49,15 +49,17 @@ import Test
49
49
50
50
# where there is a choice between ``n`` items, with item ``i`` having weight ``w_i``,
51
51
# 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.
53
55
54
56
# ## Data
55
57
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
57
59
# and one for the weights) along with a capacity.
58
60
# For our example, we use a capacity of 10 units
59
61
capacity = 10 ;
60
- # and vector data
62
+ # and the vector data
61
63
profit = [5 , 3 , 2 , 7 , 4 ];
62
64
weight = [2 , 8 , 4 , 2 , 5 ];
63
65
@@ -69,7 +71,7 @@ weight = [2, 8, 4, 2, 5];
69
71
# ultimately be called to solve the model, once it's constructed.
70
72
model = Model (HiGHS. Optimizer)
71
73
72
- # Next we need the decision variables for which items are chosen.
74
+ # Next we need the decision variables representing which items are chosen.
73
75
@variable (model, x[1 : 5 ], Bin)
74
76
75
77
# We now want to constrain those variables so that their combined
137
139
solve_knapsack_problem (; profit = profit, weight = weight, capacity = capacity)
138
140
139
141
# 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