Skip to content

Commit

Permalink
Update design_patterns_for_larger_models.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Nov 28, 2021
1 parent 31046c3 commit cd3e929
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ end
function add_knapsack_variables(
model::Model,
data::KnapsackData,
::BinaryKnapsack,
::BinaryKnapsackConfig,
)
return @variable(model, x[keys(data.objects)], Bin)
end
Expand Down Expand Up @@ -394,11 +394,8 @@ function solve_knapsack_6(
return solve_knapsack_6(optimizer, read_data(data), config)
end

solution = solve_knapsack_6(
GLPK.Optimizer,
data_filename,
BinaryKnapsackConfig(),
)
solution =
solve_knapsack_6(GLPK.Optimizer, data_filename, BinaryKnapsackConfig())

# ## Create a module

Expand Down Expand Up @@ -539,7 +536,7 @@ Solve the knapsack problem and return the optimal primal solution
* `config` : an object to control the type of knapsack model constructed.
Valid options are:
* `BinaryKnapsackConfig()`
* `IntegerKnapsack()`
* `IntegerKnapsackConfig()`
## Returns
Expand Down Expand Up @@ -621,7 +618,7 @@ using Test
x = KnapsackModel.solve_knapsack(
GLPK.Optimizer,
joinpath(@__DIR__, "data", "knapsack.json"),
KnapsackModel.IntegerKnapsackConfigConfig(),
KnapsackModel.IntegerKnapsackConfig(),
)
@test isapprox(x["apple"], 0, atol = 1e-5)
@test isapprox(x["banana"], 0, atol = 1e-5)
Expand Down

0 comments on commit cd3e929

Please sign in to comment.