I compared JuMP and YALMIP’s performance in parsing convex problem. I noticed a difference in the problem size of the final optimization problem that is passed to Mosek. The problem from JuMP was quite large, than YALMIP.

YALMIP generated problem has 5 constraints, 0 scalar variables, 2 matrix variables

JuMP generated problem has 18 constraints, 5 scalar variables, 2 matrix variables
Both give the exact same answer. Any comments on why this is the case? Am I formulating the problem incorrectly in JuMP? Any help in this regard will be greatly appreciated. Details of the test problem are below.
Thanks.
Problem Statement
Design of LQR for a system \dot{x} = Ax + Bu, with u=Kx. This is solved using a SDP problem. I am not getting into the details of LQR theory here. The codes for YALMIP and JuMP are as following.
YALMIP (MATLAB)
clc; clear;
A = [0 1; 1 1];
B = [0;1];
Q = [1 0; 0 0.1];
R = 1;
Y = sdpvar(2,2);
W = sdpvar(1,2)
Z = zeros(2,1);
M11 = (AY + BW) + (AY + BW)’;
M = [M11 Y W’;
Y inv(Q) Z;
W Z’ inv( R );]
constr = [M <= 0, Y>=0];
optimize(constr,trace(Y));
disp(trace(value(Y)));
JuMP Code
using JuMP, MosekTools, LinearAlgebra
A = [0. 1; 1 1];
B = [0.;1];
model = Model(with_optimizer(Mosek.Optimizer));
@variable(model, Y[1:2, 1:2], Symmetric);
@variable(model, W[1:2]);
Q = [1 0; 0 0.1];
R = 1;
Z = zeros(2,1);
M11 = (AY + BW’) + (AY + BW’)’;
M = [M11 Y W;
Y inv(Q) Z;
W’ Z’ inv®;]
@SDconstraint(model,Symmetric(M) <= zeros(size(M)));
@SDconstraint(model,Symmetric(Y) >= zeros(size(Y)));
@objective(model,Max,tr(Y));
println(“Calling optimize!(…)”);
JuMP.optimize!(model);
println(tr(value.(Y)));
MOSEK Output from YALMIP
MOSEK Version 9.0.89 (Build date: 2019524 09:53:18)
Copyright © MOSEK ApS, Denmark. WWW: mosek.com
Platform: MACOSX/64X86
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 5
Cones : 0
Scalar variables : 0
Matrix variables : 2
Integer variables : 0
Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator  tries : 1 time : 0.00
Lin. dep.  tries : 1 time : 0.00
Lin. dep.  number : 0
Presolve terminated. Time: 0.01
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 5
Cones : 0
Scalar variables : 0
Matrix variables : 2
Integer variables : 0
Optimizer  threads : 8
Optimizer  solved problem : the primal
Optimizer  Constraints : 5
Optimizer  Cones : 1
Optimizer  Scalar variables : 3 conic : 3
Optimizer  Semidefinite variables: 1 scalarized : 15
Factor  setup time : 0.00 dense det. time : 0.00
Factor  ML order time : 0.00 GP order time : 0.00
Factor  nonzeros before factor : 15 after factor : 15
Factor  dense dim. : 0 flops : 6.14e+02
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 1.7e+00 9.0e+00 1.3e+01 0.00e+00 1.200000000e+01 0.000000000e+00 1.0e+00 0.02
1 3.6e01 1.9e+00 4.2e+00 7.61e01 7.493854220e+00 1.637944828e+00 2.1e01 0.06
2 9.2e02 4.9e01 6.4e01 4.11e01 5.431599917e+00 3.638549110e+00 5.4e02 0.06
3 2.0e02 1.1e01 9.4e02 2.68e01 6.802314950e+00 6.369265942e+00 1.2e02 0.06
4 2.4e04 1.3e03 1.2e04 9.08e01 6.662079753e+00 6.655739510e+00 1.4e04 0.06
5 8.9e06 4.7e05 8.0e07 1.00e+00 6.660644505e+00 6.660411659e+00 5.2e06 0.07
6 8.9e07 4.7e06 2.6e08 1.00e+00 6.660618400e+00 6.660594963e+00 5.2e07 0.07
7 8.7e08 4.6e07 7.8e10 1.00e+00 6.660615958e+00 6.660613675e+00 5.1e08 0.07
8 8.7e09 4.6e08 2.5e11 1.00e+00 6.660615311e+00 6.660615082e+00 5.1e09 0.07
9 3.6e10 4.4e09 2.1e13 1.00e+00 6.660615168e+00 6.660615158e+00 2.1e10 0.07
Optimizer terminated. Time: 0.10
Interiorpoint solution summary
Problem status : PRIMAL_AND_DUAL_FEASIBLE
Solution status : OPTIMAL
Primal. obj: 6.6606151676e+00 nrm: 4e+00 Viol. con: 4e09 barvar: 0e+00
Dual. obj: 6.6606151582e+00 nrm: 1e+01 Viol. con: 0e+00 barvar: 2e08
Optimizer summary
Optimizer  time: 0.10
Interiorpoint  iterations : 9 time: 0.07
Basis identification  time: 0.00
Primal  iterations : 0 time: 0.00
Dual  iterations : 0 time: 0.00
Clean primal  iterations : 0 time: 0.00
Clean dual  iterations : 0 time: 0.00
Simplex  time: 0.00
Primal simplex  iterations : 0 time: 0.00
Dual simplex  iterations : 0 time: 0.00
Mixed integer  relaxations: 0 time: 0.00
6.660615158242211
MOSEK Output from JuMP
Problem
Name :
Objective sense : max
Type : CONIC (conic optimization problem)
Constraints : 18
Cones : 0
Scalar variables : 5
Matrix variables : 2
Integer variables : 0
Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator  tries : 2 time : 0.00
Lin. dep.  tries : 1 time : 0.00
Lin. dep.  number : 0
Presolve terminated. Time: 0.00
Problem
Name :
Objective sense : max
Type : CONIC (conic optimization problem)
Constraints : 18
Cones : 0
Scalar variables : 5
Matrix variables : 2
Integer variables : 0
Optimizer  threads : 8
Optimizer  solved problem : the primal
Optimizer  Constraints : 18
Optimizer  Cones : 2
Optimizer  Scalar variables : 9 conic : 9
Optimizer  Semidefinite variables: 1 scalarized : 15
Factor  setup time : 0.00 dense det. time : 0.00
Factor  ML order time : 0.00 GP order time : 0.00
Factor  nonzeros before factor : 153 after factor : 153
Factor  dense dim. : 0 flops : 2.76e+03
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 9.0e+00 1.0e+00 1.0e+00 0.00e+00 0.000000000e+00 0.000000000e+00 1.0e+00 0.00
1 1.9e+00 2.1e01 3.3e01 7.58e01 1.494060954e+00 2.347484915e01 2.1e01 0.00
2 4.8e01 5.4e02 4.8e02 3.97e01 3.216540796e+00 2.621094335e+00 5.4e02 0.00
3 1.3e01 1.5e02 1.1e02 1.56e01 6.236366207e+00 5.794301541e+00 1.5e02 0.00
4 2.8e03 3.1e04 3.0e05 8.65e01 6.647109017e+00 6.639514147e+00 3.1e04 0.00
5 6.2e05 6.9e06 9.9e08 1.00e+00 6.660351189e+00 6.660190874e+00 6.9e06 0.00
6 5.8e06 6.5e07 2.8e09 1.00e+00 6.660595719e+00 6.660580869e+00 6.5e07 0.00
7 4.9e07 5.4e08 6.8e11 1.00e+00 6.660614264e+00 6.660613014e+00 5.4e08 0.00
8 4.8e08 5.3e09 2.1e12 1.00e+00 6.660615113e+00 6.660614990e+00 5.3e09 0.00
9 6.2e10 6.1e10 3.1e15 1.00e+00 6.660615160e+00 6.660615159e+00 6.9e11 0.00
Optimizer terminated. Time: 0.01
6.660615160346445