# COSMO.jl & Convex.jl: setting intial values

**URL:** https://discourse.julialang.org/t/cosmo-jl-convex-jl-setting-intial-values/61381
**Category:** Optimization (Mathematical)
**Created:** [May 18, 2021, 6:03pm UTC](https://discourse.julialang.org/t/cosmo-jl-convex-jl-setting-intial-values/61381 "2021-05-18T18:03:09Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)
#### Post date: [May 18, 2021, 6:03pm UTC](https://discourse.julialang.org/t/cosmo-jl-convex-jl-setting-intial-values/61381/1 "2021-05-18T18:03:09Z")

</div>

Hi,

I’m using COSMO.jl as a solver from Convex.jl. I’m solving tseveral ‘related problems’ over and over again, which correspond to more precise versions of each others.

I’d like to use the COSMO.jl warm starting features (see [there](https://oxfordcontrol.github.io/COSMO.jl/stable/getting_started/#Warm-starting)):

```julia
warm_start_primal!(model, x_0)
warm_start_dual!(model, y_0)

```

How can i do the equivalent thing from Convex.jl interface // Through MOI ?  
I tried `set_value!(x,x_0)` but without any luck.

---

<div class="post-metadata">

### Author: ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)
#### Post date: [May 18, 2021, 7:24pm UTC](https://discourse.julialang.org/t/cosmo-jl-convex-jl-setting-intial-values/61381/2 "2021-05-18T19:24:22Z")

</div>

Convex so far only supports warmstarting primal variables, unfortunately. Try passing `warmstart=true` to `solve!`. The values are set automatically after the previous solve, or you can set them by hand with `set_value!`. I have not tried with COSMO, let us know how it goes 🙂

---

<div class="post-metadata">

### Author: ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)
#### Post date: [May 18, 2021, 8:29pm UTC](https://discourse.julialang.org/t/cosmo-jl-convex-jl-setting-intial-values/61381/3 "2021-05-18T20:29:41Z")

</div>

I tried setting them with `set_value!` and setting warm start to true, it did not work. I’ll write a MWE tomorrow (European time).

---

<div class="post-metadata">

### Author: ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)
#### Post date: [May 19, 2021, 7:46am UTC](https://discourse.julialang.org/t/cosmo-jl-convex-jl-setting-intial-values/61381/4 "2021-05-19T07:46:38Z")

</div>

Ok This MWE seems to show the problem:

```julia
using Convex, COSMO

function solve_from_(y0=nothing)
    y = Variable(3)
    x = [1,2,3]
    if !isnothing(y0)
        set_value!(y,y0)
    end
    p = minimize(Convex.norm(y - x,2) + Convex.norm(y,1))
    solve!(p, () -> COSMO.Optimizer(verbose=true),warmstart=true)
    return vec(Convex.evaluate(y))
end

y0 = solve_from_()
solve_from_(y0)

```

I setted the verbose parameter so we see that COSMO started from the same point both times.

---

<div class="post-metadata">

### Author: ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)
#### Post date: [May 25, 2021, 7:49pm UTC](https://discourse.julialang.org/t/cosmo-jl-convex-jl-setting-intial-values/61381/5 "2021-05-25T19:49:44Z")

</div>

I see the same thing, maybe file an issue with COSMO.jl? Feel free to tag me (`@ericphanson`) in case there is something going wrong with Convex.
