# Bounding Correlation Coefficients for Multiple Problems with JuMP

**URL:** https://discourse.julialang.org/t/bounding-correlation-coefficients-for-multiple-problems-with-jump/59690
**Category:** Optimization (Mathematical)
**Tags:** jump, optimization
**Created:** [April 20, 2021, 7:05pm UTC](https://discourse.julialang.org/t/bounding-correlation-coefficients-for-multiple-problems-with-jump/59690 "2021-04-20T19:05:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![phantom](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@phantom](https://discourse.julialang.org/u/phantom)
#### Post date: [April 20, 2021, 7:05pm UTC](https://discourse.julialang.org/t/bounding-correlation-coefficients-for-multiple-problems-with-jump/59690/1 "2021-04-20T19:05:44Z")

</div>

Hi this is a very elementary questions but I’m still trying to understand the code from [this example](https://jump.dev/JuMP.jl/stable/tutorials/Semidefinite%20programs/corr_sdp/) for the correlation problem.

The example I am using is the bounding correlation coefficients problem from “Convex Optimization” by Boyd. (See Convex Optimization p.408 Ex. 8.3). Given the Correlation Coefficients of (1,2) , (1,3), (2,4) and (3,4) I am trying to solve for the min/max values of Correlation(1,4) and Correlation(2,3) in R4.

Because I am now solving 4 SDP’s instead of two SDP’s I modified the code from the Jump example. To do this I simply added an objective and ran optimize! two additional times in the following manner:

```julia
function example4_corr_sdp()
    model = Model(SCS.Optimizer)
    set_silent(model)
    @variable(model, X[1:4, 1:4], PSD)
    # Diagonal is 1s
    @constraint(model, X[1, 1] == 1)
    @constraint(model, X[2, 2] == 1)
    @constraint(model, X[3, 3] == 1)
    @constraint(model, X[4, 4] == 1)
    # Bounds on the known correlations
    @constraint(model, X[1, 2] >= 0.6)
    @constraint(model, X[1, 2] <= 0.9)
    @constraint(model, X[1, 3] >= 0.8)
    @constraint(model, X[1, 3] <= 0.9)
    @constraint(model, X[2, 4] >= 0.5)
    @constraint(model, X[2, 4] <= 0.7)
    @constraint(model, X[3, 4] >= -0.8)
    @constraint(model, X[3, 4] <= -0.4)
    # Find upper bound
    @objective(model, Max, X[1, 4])
    optimize!(model)
    println("An upper bound for X[1, 4] is $(value(X[1, 4]))")
    # added additional SDP 
    @objective(model, Max, X[2, 3])
    optimize!(model)
    println("An upper bound for X[2, 3] is $(value(X[2, 3]))")
    # Find lower bound
    @objective(model, Min, X[1, 4])
    optimize!(model)
    println("A lower bound for X[1, 4] is $(value(X[1, 4]))")
    #added additional SDP 
    @objective(model, Min, X[2, 3])
    optimize!(model)
    println("A lower bound for X[2, 3] is $(value(X[2, 3]))")
    return
end

```

I receive the following output which is the correct answer for X[1,4] and what I assume to be the correct answer for X[2,3], although X[2,3] has not been verified.

```julia
 julia> example4_corr_sdp()
An upper bound for X[1, 4] is 0.22990770904303592
An upper bound for X[2, 3] is 0.5937251240363608
A lower bound for X[1, 4] is -0.39281984069804604
A lower bound for X[2, 3] is 7.756695268806519e-11

```

I am just wondering if this is the correct approach to solving multiple SDP’s with the same constraints? Is there is a more efficient way to go about it? Also if there are any other elementary misunderstandings here I’d appreciate it if anyone could point me in the right direction thanks!

---

<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: [April 20, 2021, 7:57pm UTC](https://discourse.julialang.org/t/bounding-correlation-coefficients-for-multiple-problems-with-jump/59690/2 "2021-04-20T19:57:56Z")

</div>

I don’t know what you mean by “added additional SDP,” but if all you are doing is changing the objective and re-solving, then yes, this is the right way to do it.
