Dears,

I have this optimization problem:

I am trying to write code for thr dual part. However I have minus G value: I dont understand why.

Could you please kindly look at and let me know?

```
function [G,W,S] = TD_P_inv_Dual(P_exp,B,A_ax,B_by)
d = size(P_exp,1); %dimentions
m = size(P_exp,3); %number of operators
%d = size(B_by,1);
%m = size(B_by,3);
cvx_begin
expression S
W_hat=zeros(d^2,d^2);
for a=1:d
for b=1:d
for x=1:m
for y=1:m
W_hat=W_hat+B(a,b,x,y).*(kron(A_ax(:,:,x,a),B_by(:,:,y,b)));
end
end
end
end
W=sum(sum(sum(sum(B.*P_exp)))); %This is W
J=cvx(0);
for a=1:d
for b =1:d
for x=1:m
for y =1:m
if a ~= b
S = sum(B(a,b,x,y));
J=S*W;
end
end
end
end
end
J=real(J)
minimize(J)
subject to
for e=1:d
(S.*W_hat-kron(squeeze(A_ax(:,:,1,e)),eye(d)))==semidefinite(d^2,d^2); %this part is the following part of eq. 19
end
cvx_end
G=double(S.*W);
```