# JuMP re-solving Model after equivalently reformulating objective gives different results

**URL:** <https://discourse.julialang.org/t/jump-re-solving-model-after-equivalently-reformulating-objective-gives-different-results/125210>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, mosek\
**Created:** [January 25, 2025, 10:47pm UTC](https://discourse.julialang.org/t/jump-re-solving-model-after-equivalently-reformulating-objective-gives-different-results/125210 "2025-01-25T22:47:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phK3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phk3/32/45646_2.png) [@phK3](https://discourse.julialang.org/u/phK3)\
**Post date:** [January 25, 2025, 10:47pm UTC](https://discourse.julialang.org/t/jump-re-solving-model-after-equivalently-reformulating-objective-gives-different-results/125210/1 "2025-01-25T22:47:34Z")

</div>

Disclaimer: This is a repost/extension of [this github issue](https://github.com/jump-dev/MosekTools.jl/issues/142).

The “output variables” of my problem are the entries in some specific place of a SDP matrix (`P[1,4:5])` in the code below).  
When I directly optimize an objective function over these indices of the matrix, I get the correct result.

However, when I then introduce new variables `y[1:2] .== P[1,4:5]` and re-solve the same objective, `Mosek` returns a different result.

To reproduce the error:

```julia
using JuMP, MosekTools, SCS
# setup the model and constraints 
model = Model(Mosek.Optimizer) 
@variable(model, P[1:5,1:5], PSD) 
@constraint(model, diag(P[2:3, 2:3]) .- (-1. .+ 1) .* P[1,2:3] .+ (-1.) .* 1. .<= 0)
@constraint(model, P[1,1] .== 1.) W = [1. 1; 1 -1] 
@constraint(model, P[1,4:5] .>= 0.0) 
@constraint(model, P[1,4:5] .>= W*P[1,2:3]) 
@constraint(model, diag(P[4:5,4:5] .- W*P[2:3,4:5]) .== 0); 

# solve the original objective 
c = [1.14, -4.5] 
@objective(model, Max, c'*P[1,4:5]) 
optimize!(model) 
objective_value(model) # returns ~2.28 

# reformulate objective 
@variable(model, y[1:2]) 
@constraint(model, y .== P[1,4:5]) 
@objective(model, Max, c'*y) 
optimize!(model) 
objective_value(model) # returns ~4.55 !!!

```

When using `model = Model(SCS.Optimizer)` instead, the objective value is `~2.28` both times.

I’m using `Julia 1.11.1`, `JuMP v1.23.6`, `MosekTools v0.15.4` and `SCS v2.0.2`.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [January 25, 2025, 11:01pm UTC](https://discourse.julialang.org/t/jump-re-solving-model-after-equivalently-reformulating-objective-gives-different-results/125210/2 "2025-01-25T23:01:55Z")

</div>

I dont have a Mosek license so i can’t check this. But lets keep to the GitHub issue. @blegat can take a look.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [March 20, 2025, 11:11pm UTC](https://discourse.julialang.org/t/jump-re-solving-model-after-equivalently-reformulating-objective-gives-different-results/125210/3 "2025-03-20T23:11:38Z")

</div>

Just following up on this: this bug was fixed in MosekTools.jl v0.15.5.

I’ve also just released MosekTools.jl v0.15.7, which contains a number of other fixes. Hopefully MosekTools.jl is a lot more robust now! Thanks for reporting this issue.
