Skip to content

Commit

Permalink
Merge pull request #91 from r-barnes/patch-1
Browse files Browse the repository at this point in the history
Update README examples to work with JuMP v0.19.0
  • Loading branch information
blegat committed May 24, 2019
2 parents 71ef885 + b0d7ab0 commit 79384ef
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ To use these settings you can either pass them as keyword arguments to `setup` (
# Direct
my_prob = ECOS.setup(n, m, ..., c, h, b; maxit=10, feastol=1e-5)
# MathProgBase (with JuMP)
m = Model(solver=ECOS.ECOSSolver(maxit=10, feastol=1e-5))
model = Model(with_optimizer(ECOS.Optimizer, maxit=10, feastol=1e-5))
```

### JuMP example
Expand All @@ -65,11 +65,11 @@ items = [:Gold, :Silver, :Bronze]
values = Dict(:Gold => 5.0, :Silver => 3.0, :Bronze => 1.0)
weight = Dict(:Gold => 2.0, :Silver => 1.5, :Bronze => 0.3)

m = Model(solver=ECOSSolver())
@variable(m, 0 <= take[items] <= 1) # Define a variable for each item
@objective(m, Max, sum(values[item] * take[item] for item in items))
@constraint(m, sum(weight[item] * take[item] for item in items) <= 3)
solve(m)
model = Model(with_optimizer(ECOS.Optimizer))
@variable(model, 0 <= take[items] <= 1) # Define a variable for each item
@objective(model, Max, sum(values[item] * take[item] for item in items))
@constraint(model, sum(weight[item] * take[item] for item in items) <= 3)
solve(model)

println(getvalue(take))
# take
Expand Down

0 comments on commit 79384ef

Please sign in to comment.