Skip to content

Commit

Permalink
[docs] more updates to the Knapsack tutorial (#3217)
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-foster committed Feb 14, 2023
1 parent cd96cd4 commit dc00048
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions docs/src/tutorials/linear/knapsack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ import Test

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

# ## Data

# The data for the problem is two vectors (one for the profits
# The data for the problem consists of two vectors (one for the profits
# and one for the weights) along with a capacity.
# For our example, we use a capacity of 10 units
capacity = 10;
# and vector data
# and the vector data
profit = [5, 3, 2, 7, 4];
weight = [2, 8, 4, 2, 5];

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

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

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

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

0 comments on commit dc00048

Please sign in to comment.