In [2]:
using Mosek,Mosek.Ext

t = maketask()


Out[2]:
Empty Task

We load the file 25fv47.task which is a liner optimization problem. The file includes solutions.

The show() functions can be used to format the whole problem or parts of it. 25fv47.task is too large to be shown fullly, so show() will cut off some parts. To show the entire task use showall() instead.


In [3]:
readdata(t,joinpath(Pkg.dir("Mosek"),"test","25fv47.task"))

show(t)


Task ''
    Minimize
        R0000: - 0.1 MSEXP + 0.101 MS1MP - 0.075 LDEXP + 0.076 LD1MP - 0.1 PKEXP + 0.101 PK1MP - 0.0875 RKEXP + 0.0885 RK1MP + 0.2 5C0ST + 0.25 6C0ST + 0.001 CCRFT + 2.275 CRUDE - 1.5303 AABDH + 0.9632 HABDH + 0.3687 JABDH - 1.4254 1AAGJA + 1.007 1BAGJA - 1.1387 EAGJA + 0.9839 1HAGJA + 1.0109 11AGJA  ... (707 terms omitted)
    Subject to
        F1X.0: = 0.0
        2SF145: + BNF64 + HNF64 + 1NF64 + JNF64 + YNF64 = 29.0
        2SF089: + HNF89 + 1NF89 = 60.0
        2SF129: + BNF80 + HN129 + JN129 + MN129 + YN129 - 90A930 = 73.0
        30M00: + HNM00 = 77.0
        30M94: + 1HNM94 + 2HNM94 + JNM94 = 27.0
        30M91: + HNM90 + 1NM90 + JNM90 = 44.0
        30ATK: + BNATK + HNATK + 1NATK + JNATK = 4.0
        30PGK: + BNK19 + HNK19 + 1NK19 + JNK19 = 23.0
        30G30: + ANG30 + BNG30 + HNG30 + 1NG30 = 44.0
        30G17: + ANG17 + BNG17 + HNG17 + 1NG17 + JNG17 + MNG17 - NNG17 = 164.0
        30G44: + 1HNG44 + 11NG44 = 31.0
        30G22: + ANG22 + BNG22 + HNG22 + 1NG22 + JNG22 + 1MNG22 + YNG22 - 90AS30 = 79.0
        30D22: + BND22 + HND22 + 1ND22 = 19.0
        30D30: + BND30 + HND30 + 1ND30 = 1.0
        30121: + 0.5 HNF21 + 0.9 1NF21 = 4.0
        30F52: + 0.5 HNF21 + BNF52 + HNF52 + 1NF52 = 86.0
        30F48: + BNF48 + HNF48 + 1NF48 + JNF48 + ZNF48 - 128FNN = 88.0
        30128: + 128FNN = 20.0
        RB017: + 0.511 2CB002 - CB096 - CB095 - CB084 = 0.0
        ... (801 constraints omitted)
    Variables
        MSEXP ∈ [0.0;+Inf[
        MS1MP ∈ [0.0;+Inf[
        LDEXP ∈ [0.0;+Inf[
        LD1MP ∈ [0.0;+Inf[
        PKEXP ∈ [0.0;+Inf[
        PK1MP ∈ [0.0;+Inf[
        RKEXP ∈ [0.0;+Inf[
        RK1MP ∈ [0.0;+Inf[
        1G0EXP ∈ [0.0;+Inf[
        1G01MP ∈ [0.0;+Inf[
        1F0EXP ∈ [0.0;+Inf[
        1F01MP ∈ [0.0;+Inf[
        5C0ST ∈ [0.0;+Inf[
        6C0ST ∈ [0.0;+Inf[
        CCRFT ∈ [0.0;+Inf[
        CRUDE ∈ [0.0;+Inf[
        AABDH ∈ [0.0;+Inf[
        HABDH ∈ [0.0;+Inf[
        JABDH ∈ [0.0;+Inf[
        1AAGJA ∈ [0.0;+Inf[
        ... (1551 variable bounds omitted)

In [4]:
show(t[Obj()])


Objective('R0000': - 0.1 MSEXP + 0.101 MS1MP - 0.075 LDEXP + 0.076 LD1MP - 0.1 PKEXP + 0.101 PK1MP - 0.0875 RKEXP + 0.0885 RK1MP + 0.2 5C0ST + 0.25 6C0ST + 0.001 CCRFT + 2.275 CRUDE - 1.5303 AABDH + 0.9632 HABDH + 0.3687 JABDH - 1.4254 1AAGJA + 1.007 1BAGJA - 1.1387 EAGJA + 0.9839 1HAGJA + 1.0109 11AGJA  ...(707 terms omitted))

In [6]:
show(t[Con(2)])


Out[6]:
Constraint('2SF145': 29.0 = + BNF64 + HNF64 + 1NF64 + JNF64 + YNF64 )

In [7]:
show(t[Var(1)])


Out[7]:
Variable('MSEXP' ∈ [0.0;+Inf[)

In [8]:
sol = t[Sol(MSK_SOL_ITR)]
show(sol)


Interior Solution, status = Unknown
    Objective: 5501.846030254401 | 5501.8460280611325
    Variable solution
        name                          level     dual lower     dual upper     dual conic
        MSEXP               :    5.3141e+01    -5.3777e-09     0.0000e+00     0.0000e+00
        MS1MP               :    9.0695e-05     1.0000e-03     0.0000e+00     0.0000e+00
        LDEXP               :    8.4537e-05     1.0000e-03     0.0000e+00     0.0000e+00
        LD1MP               :    3.4227e+01     2.8868e-09     0.0000e+00     0.0000e+00
        PKEXP               :    8.5445e-05     1.0000e-03     0.0000e+00     0.0000e+00
        PK1MP               :    7.3501e+00     1.1459e-08     0.0000e+00     0.0000e+00
        RKEXP               :    8.6610e-05     1.0000e-03     0.0000e+00     0.0000e+00
        RK1MP               :    1.7316e+01     3.7289e-09     0.0000e+00     0.0000e+00
        1G0EXP              :    2.9831e+02    -2.8936e-08     0.0000e+00     0.0000e+00
        1G01MP              :    3.0640e+00     2.8936e-08     0.0000e+00     0.0000e+00
        1F0EXP              :    3.5337e+02    -2.6446e-08     0.0000e+00     0.0000e+00
        1F01MP              :    2.6324e+00     2.6446e-08     0.0000e+00     0.0000e+00
        5C0ST               :    2.0818e+03    -3.9886e-08     0.0000e+00     0.0000e+00
        6C0ST               :    0.0000e+00     5.0000e-02     0.0000e+00     0.0000e+00
        CCRFT               :    6.2500e+01     0.0000e+00     0.0000e+00     0.0000e+00
        CRUDE               :    1.2942e+03     0.0000e+00     0.0000e+00     0.0000e+00
        AABDH               :    2.8170e-06     0.0000e+00     0.0000e+00     0.0000e+00
        HABDH               :    3.7382e+02     0.0000e+00     0.0000e+00     0.0000e+00
        JABDH               :    1.3218e+02     0.0000e+00     0.0000e+00     0.0000e+00
        1AAGJA              :    1.4654e+02     0.0000e+00     0.0000e+00     0.0000e+00
        ... (1551 variables omitted)
    Constraint solution
        name                          level     dual lower     dual upper              y
        F1X.0               :    0.0000e+00     0.0000e+00     0.0000e+00    -0.0000e+00
        2SF145              :    2.9000e+01     2.8297e+00     0.0000e+00     2.8297e+00
        2SF089              :    6.0000e+01     2.9002e+00     0.0000e+00     2.9002e+00
        2SF129              :    7.3000e+01     2.7619e+00     0.0000e+00     2.7619e+00
        30M00               :    7.7000e+01     9.5324e+00     0.0000e+00     9.5324e+00
        30M94               :    2.7000e+01     8.8149e+00     0.0000e+00     8.8149e+00
        30M91               :    4.4000e+01     8.3345e+00     0.0000e+00     8.3345e+00
        30ATK               :    4.0000e+00     7.3382e+00     0.0000e+00     7.3382e+00
        30PGK               :    2.3000e+01     7.0821e+00     0.0000e+00     7.0821e+00
        30G30               :    4.4000e+01     6.2145e+00     0.0000e+00     6.2145e+00
        30G17               :    1.6400e+02     6.2145e+00     0.0000e+00     6.2145e+00
        30G44               :    3.1000e+01     6.1717e+00     0.0000e+00     6.1717e+00
        30G22               :    7.9000e+01     6.0318e+00     0.0000e+00     6.0318e+00
        30D22               :    1.9000e+01     5.8042e+00     0.0000e+00     5.8042e+00
        30D30               :    1.0000e+00     6.0273e+00     0.0000e+00     6.0273e+00
        30121               :    4.0000e+00     4.0584e+00     0.0000e+00     4.0584e+00
        30F52               :    8.6000e+01     4.0584e+00     0.0000e+00     4.0584e+00
        30F48               :    8.8000e+01     2.9224e+00     0.0000e+00     2.9224e+00
        30128               :    2.0000e+01     2.9224e+00     0.0000e+00     2.9224e+00
        RB017               :    0.0000e+00     2.2373e+00     0.0000e+00     2.2373e+00
        ... (801 constraints omitted)

In [9]:
show(sol[Var(1)])


MSEXP: 53.14086064879275, dual lower: -5.37768665709315e-9, dual upper: 0.0, dual conic: 0.0

In [10]:
show(sol[Con(1)])


F1X.0: 0.0, dual lower: 0.0, dual upper: 0.0, dual conic: -0.0

Now we load another file, lj-inner.task, which is a problem with one semidefinite variable and some second order cones. The file includes solutions.


In [11]:
readdata(t,joinpath(Pkg.dir("Mosek"),"test","lj-inner.task"))
show(t)


Task 'lownerjohn_inner'
    Maximize
        #obj: + t[0] 
    Subject to
        qc0[0]: + 2.0 d[0] + 3.0 d[1] - qc0[0].coneslack = 0.0
        qc0[1]: - 2.0 C[0,0] - 3.0 C[0,1] - qc0[1].coneslack = -0.0
        qc0[2]: - 2.0 C[1,0] - 3.0 C[1,1] - qc0[2].coneslack = -0.0
        qc1[0]: + 3.0 d[0] - d[1] - qc1[0].coneslack = -0.0
        qc1[1]: - 3.0 C[0,0] + C[0,1] - qc1[1].coneslack = -0.0
        qc1[2]: - 3.0 C[1,0] + C[1,1] - qc1[2].coneslack = -0.0
        qc2[0]: + d[0] - 4.0 d[1] - qc2[0].coneslack = -11.0
        qc2[1]: - C[0,0] + 4.0 C[0,1] - qc2[1].coneslack = -0.0
        qc2[2]: - C[1,0] + 4.0 C[1,1] - qc2[2].coneslack = -0.0
        qc3[0]: - 3.0 d[0] - 2.0 d[1] - qc3[0].coneslack = -23.0
        qc3[1]: + 3.0 C[0,0] + 2.0 C[0,1] - qc3[1].coneslack = -0.0
        qc3[2]: + 3.0 C[1,0] + 2.0 C[1,1] - qc3[2].coneslack = -0.0
        qc4[0]: - 3.0 d[0] + 4.0 d[1] - qc4[0].coneslack = -17.0
        qc4[1]: + 3.0 C[0,0] - 4.0 C[0,1] - qc4[1].coneslack = -0.0
        qc4[2]: + 3.0 C[1,0] - 4.0 C[1,1] - qc4[2].coneslack = -0.0
        #c16: + #MX1 ⋅ #X̄1 = 0.0
        #c17: + #MX2 ⋅ #X̄1 = 0.0
        #c18: + #MX3 ⋅ #X̄1 = 0.0
        #c19: + #MX4 ⋅ #X̄1 = 0.0
        #c20: + C[0,0] + #MX5 ⋅ #X̄1 = 0.0
        ... (7 constraints omitted)
        qc0[0]: (qc0[0].coneslack,qc0[1].coneslack,qc0[2].coneslack) ∈ 𝒞_q(3)
        qc1[0]: (qc1[0].coneslack,qc1[1].coneslack,qc1[2].coneslack) ∈ 𝒞_q(3)
        qc2[0]: (qc2[0].coneslack,qc2[1].coneslack,qc2[2].coneslack) ∈ 𝒞_q(3)
        qc3[0]: (qc3[0].coneslack,qc3[1].coneslack,qc3[2].coneslack) ∈ 𝒞_q(3)
        qc4[0]: (qc4[0].coneslack,qc4[1].coneslack,qc4[2].coneslack) ∈ 𝒞_q(3)
        #k6: (#x23,#x24,#x25) ∈ 𝒞_qr(3)
    Variables
        d[0] ∈ ]-Inf;+Inf[
        d[1] ∈ ]-Inf;+Inf[
        C[0,0] ∈ ]-Inf;+Inf[
        C[0,1] ∈ ]-Inf;+Inf[
        C[1,0] ∈ ]-Inf;+Inf[
        C[1,1] ∈ ]-Inf;+Inf[
        qc0[0].coneslack ∈ ]-Inf;+Inf[
        qc0[1].coneslack ∈ ]-Inf;+Inf[
        qc0[2].coneslack ∈ ]-Inf;+Inf[
        qc1[0].coneslack ∈ ]-Inf;+Inf[
        qc1[1].coneslack ∈ ]-Inf;+Inf[
        qc1[2].coneslack ∈ ]-Inf;+Inf[
        qc2[0].coneslack ∈ ]-Inf;+Inf[
        qc2[1].coneslack ∈ ]-Inf;+Inf[
        qc2[2].coneslack ∈ ]-Inf;+Inf[
        qc3[0].coneslack ∈ ]-Inf;+Inf[
        qc3[1].coneslack ∈ ]-Inf;+Inf[
        qc3[2].coneslack ∈ ]-Inf;+Inf[
        qc4[0].coneslack ∈ ]-Inf;+Inf[
        qc4[1].coneslack ∈ ]-Inf;+Inf[
        ... (6 variable bounds omitted)
        #X̄1 ∈ S(4)
    Symmetric matrixes
        #MX1 (4): [ (3,1,0.5),(3,3,-1.0) ]
        #MX2 (4): [ (4,3,-0.5) ]
        #MX3 (4): [ (4,3,-0.5) ]
        #MX4 (4): [ (4,2,0.5),(4,4,-1.0) ]
        #MX5 (4): [ (1,1,-1.0) ]
        #MX6 (4): [ (2,1,-0.5) ]
        #MX7 (4): [ (2,1,-0.5) ]
        #MX8 (4): [ (2,2,-1.0) ]
        #MX9 (4): [ (3,3,1.0) ]
        #MX10 (4): [ (4,4,1.0) ]

In [12]:
show(t[Barvar(1)])


SemidefiniteVariable('#X̄1' ∈ 𝒞_S(4))

In constraint #c16 ... #c20 we have some terms of the form #MX1 ⋅ #X̄1; these are semidefinite terms, i.e. the #MX1 is a symmetric matrix and #X̄1 is a symmetric positive semidefinite matrix variable. We can check what the matrixes look like:


In [17]:
m = t[Symmat(1)]
println(typeof(m))
println(full(m))


SparseMatrixCSC{Float64,Int64}
[0.0 0.0 0.5 0.0; 0.0 0.0 0.0 0.0; 0.5 0.0 -1.0 0.0; 0.0 0.0 0.0 0.0]

In [20]:
optimize(t)
sol = t[Sol(MSK_SOL_ITR)]


Out[20]:
Interior Solution, status = Optimal
    Objective: 2.6454571279494123 | 2.645457125709574
    Variable solution
        name                          level     dual lower     dual upper     dual conic
        d[0]                :    3.2903e+00    -0.0000e+00    -0.0000e+00    -0.0000e+00
        d[1]                :    1.1774e+00    -0.0000e+00    -0.0000e+00    -0.0000e+00
        C[0,0]              :    2.9228e+00    -0.0000e+00    -0.0000e+00    -0.0000e+00
        C[0,1]              :    2.3978e-01    -0.0000e+00    -0.0000e+00    -0.0000e+00
        C[1,0]              :    2.3978e-01    -0.0000e+00    -0.0000e+00    -0.0000e+00
        C[1,1]              :    2.4043e+00    -0.0000e+00    -0.0000e+00    -0.0000e+00
        qc0[0].coneslack    :    1.0113e+01    -0.0000e+00    -0.0000e+00    -5.6478e-02
        qc0[1].coneslack    :   -6.5650e+00    -0.0000e+00    -0.0000e+00    -3.6663e-02
        qc0[2].coneslack    :   -7.6923e+00    -0.0000e+00    -0.0000e+00    -4.2960e-02
        qc1[0].coneslack    :    8.6935e+00    -0.0000e+00    -0.0000e+00    -4.6425e-02
        qc1[1].coneslack    :   -8.5287e+00    -0.0000e+00    -0.0000e+00    -4.5545e-02
        qc1[2].coneslack    :    1.6849e+00    -0.0000e+00    -0.0000e+00     8.9985e-03
        qc2[0].coneslack    :    9.5806e+00    -0.0000e+00    -0.0000e+00    -5.4059e-02
        qc2[1].coneslack    :   -1.9637e+00    -0.0000e+00    -0.0000e+00    -1.1081e-02
        qc2[2].coneslack    :    9.3772e+00    -0.0000e+00    -0.0000e+00     5.2911e-02
        qc3[0].coneslack    :    1.0774e+01    -0.0000e+00    -0.0000e+00    -5.2526e-02
        qc3[1].coneslack    :    9.2480e+00    -0.0000e+00    -0.0000e+00     4.5086e-02
        qc3[2].coneslack    :    5.5278e+00    -0.0000e+00    -0.0000e+00     2.6949e-02
        qc4[0].coneslack    :    1.1839e+01    -0.0000e+00    -0.0000e+00    -4.9570e-02
        qc4[1].coneslack    :    7.8094e+00    -0.0000e+00    -0.0000e+00     3.2699e-02
        ... (6 variables omitted)
    PSD Variable solution
        #X̄1: Symmetric 4 × 4
                |   2.92e+00   2.40e-01   2.92e+00   1.20e-01 |        |  -4.54e-01   2.27e-02   4.53e-01   2.97e-13 |
            X̄ = |              2.40e+00   1.20e-01   2.40e+00 |    S̄ = |             -5.52e-01   3.52e-13   5.51e-01 |
                |                         2.92e+00  -2.82e-15 |        |                        -4.53e-01  -2.27e-02 |
                |                                    2.40e+00 |        |                                   -5.51e-01 |
    Constraint solution
        name                          level     dual lower     dual upper              y
        qc0[0]              :    0.0000e+00    -5.6478e-02    -0.0000e+00    -5.6478e-02
        qc0[1]              :    0.0000e+00    -3.6663e-02    -0.0000e+00    -3.6663e-02
        qc0[2]              :    0.0000e+00    -4.2960e-02    -0.0000e+00    -4.2960e-02
        qc1[0]              :   -0.0000e+00    -4.6425e-02    -0.0000e+00    -4.6425e-02
        qc1[1]              :   -0.0000e+00    -4.5545e-02    -0.0000e+00    -4.5545e-02
        qc1[2]              :   -0.0000e+00    -0.0000e+00    -8.9985e-03     8.9985e-03
        qc2[0]              :   -1.1000e+01    -5.4059e-02    -0.0000e+00    -5.4059e-02
        qc2[1]              :    0.0000e+00    -1.1081e-02    -0.0000e+00    -1.1081e-02
        qc2[2]              :    0.0000e+00    -0.0000e+00    -5.2911e-02     5.2911e-02
        qc3[0]              :   -2.3000e+01    -5.2526e-02    -0.0000e+00    -5.2526e-02
        qc3[1]              :    0.0000e+00    -0.0000e+00    -4.5086e-02     4.5086e-02
        qc3[2]              :    0.0000e+00    -0.0000e+00    -2.6949e-02     2.6949e-02
        qc4[0]              :   -1.7000e+01    -4.9570e-02    -0.0000e+00    -4.9570e-02
        qc4[1]              :    0.0000e+00    -0.0000e+00    -3.2699e-02     3.2699e-02
        qc4[2]              :    0.0000e+00    -3.7256e-02    -0.0000e+00    -3.7256e-02
        #c16                :    0.0000e+00    -9.0693e-01    -0.0000e+00    -9.0693e-01
        #c17                :    0.0000e+00    -4.1990e-02    -0.0000e+00    -4.1990e-02
        #c18                :    0.0000e+00    -3.3285e-03    -0.0000e+00    -3.3285e-03
        #c19                :    0.0000e+00    -1.1026e+00    -0.0000e+00    -1.1026e+00
        #c20                :    0.0000e+00    -4.5440e-01    -0.0000e+00    -4.5440e-01
        ... (7 constraints omitted)

And we can also check the solution to a single semidefinite variable:


In [21]:
show(sol[Barvar(1)])


d[0]: Symmetric 4 × 4
      |   2.92e+00   2.40e-01   2.92e+00   1.20e-01 |        |  -4.54e-01   2.27e-02   4.53e-01   2.97e-13 |
  X̄ = |              2.40e+00   1.20e-01   2.40e+00 |    S̄ = |             -5.52e-01   3.52e-13   5.51e-01 |
      |                         2.92e+00  -2.82e-15 |        |                        -4.53e-01  -2.27e-02 |
      |                                    2.40e+00 |        |                                   -5.51e-01 |

In [ ]: