Skip to content

Commit b7e4a20

Browse files
committed
Tweak example
1 parent 457f623 commit b7e4a20

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@ This example shows how we can model a simple knapsack problem with JuMP and use
3030
```julia
3131
using JuMP
3232
import ECOS
33-
m = Model(solver=ECOS.ECOSSolver())
3433

3534
items = [:Gold, :Silver, :Bronze]
3635
values = [:Gold => 5.0, :Silver => 3.0, :Bronze => 1.0]
3736
weight = [:Gold => 2.0, :Silver => 1.5, :Bronze => 0.3]
3837

38+
m = Model(solver=ECOS.ECOSSolver())
3939
@defVar(m, 0 <= take[items] <= 1) # Define a variable for each item
4040
@setObjective(m, Max, sum{ values[item] * take[item], item in items})
4141
@addConstraint(m, sum{ weight[item] * take[item], item in items} <= 3)
4242
solve(m)
43+
4344
println(getValue(take))
4445
# take
4546
# [ Gold] = 0.9999999680446406

0 commit comments

Comments
 (0)