Skip to content

Commit

Permalink
kwargs translate to NamedTuple
Browse files Browse the repository at this point in the history
Model.options has become an iterator over pairs: (:kwrd=>val)
  • Loading branch information
kalmarek committed May 4, 2018
1 parent 31e39c1 commit 9e7bd4e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/MPBWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ end
# warmstart
# kwargs can be `primal_sol`, `dual_sol`, and `slack`
function setwarmstart!(m::SCSMathProgModel, primal_sol; kwargs...)
push!(m.options, (:warm_start, true))
m.options = pairs(merge(m.options.data, (warm_start=>true,)))
m.primal_sol = primal_sol
for (k,v) in kwargs
setfield!(m, k, v)
Expand Down
2 changes: 1 addition & 1 deletion src/c_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function SCS_solve(T::Union{Type{Direct}, Type{Indirect}},
cone = Ref(SCSCone(f, l, q, s, ep, ed, p))
info = Ref(SCSInfo())

if (:warm_start, true) in options && length(primal_sol) == n && length(dual_sol) == m && length(slack) == m
if (:warm_start=>true) in options && length(primal_sol) == n && length(dual_sol) == m && length(slack) == m
x = primal_sol
y = dual_sol
s = slack
Expand Down
3 changes: 1 addition & 2 deletions test/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ MathProgBase.optimize!(m)
@test isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-5)

# With a warmstart from the eps = 1e-8 solution, solution should be extremely accurate even after 1 iteration
push!(m.options, (:warm_start, true))
push!(m.options, (:max_iters, 1))
m.options = pairs(merge(m.options.data, (warm_start=true, max_iters=1)))
MathProgBase.optimize!(m)
@test isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-5)

Expand Down

0 comments on commit 9e7bd4e

Please sign in to comment.