# JuMP & warmstart

**URL:** <https://discourse.julialang.org/t/jump-warmstart/2998>\
**Category:** Optimization (Mathematical)\
**Created:** [April 1, 2017, 9:13am UTC](https://discourse.julialang.org/t/jump-warmstart/2998 "2017-04-01T09:13:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abulak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abulak/32/28314_2.png) [@abulak](https://discourse.julialang.org/u/abulak)\
**Post date:** [April 1, 2017, 9:13am UTC](https://discourse.julialang.org/t/jump-warmstart/2998/1 "2017-04-01T09:13:16Z")

</div>

I’m trying to start SCS with a given solution from previous runs, see [http://jump.readthedocs.io/en/latest/refmodel.html?highlight=internalModel#accessing-the-low-level-model](http://jump.readthedocs.io/en/latest/refmodel.html?highlight=internalModel#accessing-the-low-level-model)  
I mimic [https://github.com/JuliaOpt/SCS.jl/blob/master/test/options.jl:](https://github.com/JuliaOpt/SCS.jl/blob/master/test/options.jl:)

```julia
m #JuMP model
long_solver = SCSSolver(eps=1e5, max_iters=5000)
JuMP.setsolver(m, long_solver)
JuMP.solve(m)
#... Status: Solved
  :Optimal

p_sol = m.internalModel.primal_sol
d_sol = m.internalModel.dual_sol
s = m.internalModel.slack

JuMP.getobjectivevalue(m)
   0.5857824735201506

```

Now for the warm start:

```julia
short_solver = SCSSolver(eps=1e5, max_iters=1, warm_start=true, verbose=true)
JuMP.setsolver(m, short_solver)
JuMP.build(m)
MathProgBase.SolverInterface.setwarmstart!(m.internalModel, p_sol; dual_sol = d_sol, slack=s);
JuMP.solve(m)
#... Status: Unbounded/Inaccurate
JuMP.getobjectivevalue(m)
  1.0000000000000002

```

so this is not even close; However calling `MathProgBase.optimize!(m.internalModel)` (as in `options.jl` from tests) results in warmstart:

```julia
#... Status: Solved
  -0.5857616131626189

```

Is it possible to warmstart `JuMP.solve` ?

---

<div class="post-metadata">

**Author:** ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)\
**Post date:** [April 1, 2017, 1:27pm UTC](https://discourse.julialang.org/t/jump-warmstart/2998/2 "2017-04-01T13:27:54Z")

</div>

If you have a look at [`JuMP.build`](https://github.com/JuliaOpt/JuMP.jl/blob/90fc7d4120d42dc329fceed68f44fdf5c5b3347c/src/solvers.jl#L296), which is called from `solve()` you’ll see that it discards the internal conic model before every solve. So it would take some restructuring to accomplish what you’re trying to do.

Also, it seems to me that SCS’s implementation of `setwarmstart!` is broken for duals and slacks because it doesn’t account for the transformations/permutations that are done between the MathProgBase conic format and SCS conic format, not to mention that `dual_sol` and `slack` keyword arguments are not part of the definition of [`setwarmstart!`](http://mathprogbasejl.readthedocs.io/en/latest/solverinterface.html#setwarmstart!) and shouldn’t be in a method called `MathProgBase.setwamstart!`.

The tidy path forward (i.e., to get PRs merged) would be to define a warmstarting method for duals and slacks in MathProgBase, implement it correctly in SCS, and then we can consider calling it from JuMP.

---

<div class="post-metadata">

**Author:** ![abulak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abulak/32/28314_2.png) [@abulak](https://discourse.julialang.org/u/abulak)\
**Post date:** [April 1, 2017, 2:38pm UTC](https://discourse.julialang.org/t/jump-warmstart/2998/3 "2017-04-01T14:38:38Z")

</div>

Thanks for the explanation; I tried to look-up `setwarmstart!` before, but there are just 4 sentences of explanation (as You linked);

Since SCS solution actually consists of (primal, dual, slack), maybe treat the tuple as `v`?  
Are the transformations/permutations You mention done in [`conicdata`](https://github.com/JuliaOpt/JuMP.jl/blob/90fc7d4120d42dc329fceed68f44fdf5c5b3347c/src/solvers.jl#L617)?

---

<div class="post-metadata">

**Author:** ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)\
**Post date:** [April 2, 2017, 2:07am UTC](https://discourse.julialang.org/t/jump-warmstart/2998/4 "2017-04-02T02:07:09Z")

</div>

> [@abulak](#):
>
> Are the transformations/permutations you mention done in conicdata?

No, I mean the transformations from MathProgBase conic form to SCS’s internal format done [here](https://github.com/JuliaOpt/SCS.jl/blob/0718737bc41c3444d5fd91ba70b2b50e2b873c3d/src/SCSSolverInterface.jl#L124).
