with some slight modifications, I have been able to solve an exponential cone problem following your suggestion. In your suggestion, the exponential cone variables were unbounded, but I had to bound them from below otherwise the problem seemed to be unbounded. The matrix of affine conic constraints (prob.F) is somewhat more complicated than a univariate example but it seems that permuting the rows works well to enforce those constraints. However, when I test for the optimality criteria, not all residuals are below the tolerance. In particular, I when I try to test if I have recovered an optimal solution to the original problem I posed, by checking the value of
I do not get something small as I had expected. Perhaps you can help pinpoint where I have strayed from the correct approach?
% x = [vf;vr]
% y = s;
% t = [tf;tr];
% vf vr s tf tr
A = [ N -N Om1 Omn Omn;
In -In On1 On On;
-I1n -I1n 1 O1n O1n];
prob.a = A;
prob.blc = [b;l;0];
prob.buc = [b;u;0];
if 0
prob.blx = zeros(4*nint+1,1);
else
prob.blx = -inf*ones(4*nint+1,1); %unbounded problem
prob.blx = [zeros(2*nint+1,1);-inf*ones(2*nint,1)]; %unbounded problem
prob.blx = [zeros(2*nint+1,1);-10*ones(2*nint,1)]; %unbounded problem
end
prob.bux = inf*ones(4*nint+1,1);
% Specify conic part of the problem
%
https://docs.mosek.com/9.2/toolbox/data-types.html#cones % Each cone is a primal exponential cone.
% x3 <= x2 * log(x1 /x2), x1, x2 >= 0 <=> [x1;x2;x3] \in K_{exp}
% The cones are specified using two index lists cones.subptr and cones.sub and list of cone-type identifiers cones.type.
% For affine conic constraints Fx+g \in K_exp, where K = K_1 * ... * Ks, cones is a list consisting
% of s concatenated cone descriptions.
[~, res] = mosekopt('symbcon');
if 1
prob.cones(1:2:4*nint) = res.symbcon.MSK_CT_PEXP;
prob.cones(2:2:4*nint) = 3;
else
%*** Error(1301): Wrong number of variables in the cone. Exactly 3 members are required for cones of type MSK_CT_PEXP.
prob.cones(1:2*nint,1) = res.symbcon.MSK_CT_PEXP;
prob.cones(1:2*nint,2) = 3;
end
%Conic problem with affine conic constraints
%
https://docs.mosek.com/9.2/toolbox/data-types.html#equation-doc-notation-conic %f (double[][]) – The matrix of affine conic constraints. It must be a sparse matrix.
F = [In On On1 On On;
On In On1 On On;
On On In1 On On;
On On In1 On On;
On On On1 -In On;
On On On1 On -In];
%permute the rows of F to form (y, x, -t) triples for each exponential cone
ind(1:3:(6*nint)) = (2*nint+1:4*nint)';
ind(2:3:(6*nint)) = (1:2*nint)';
ind(3:3:(6*nint)) = (4*nint+1:6*nint)';
prob.f = F(ind,:);
%g (double[]) – The constant term of affine conic constraints. If not present or g==[] it is assumed g=0
if 1
prob.g = zeros(size(prob.f,1),1);
else
%*** Error(1200): prob.g must be a dense vector with length(prob.g) == size(prob.f,1)
prob.g = [];
end
[r,res]=mosekopt('minimize',prob);
if strcmp(res.sol.itr.prosta,'PRIMAL_AND_DUAL_FEASIBLE') && strcmp(res.sol.itr.solsta,'OPTIMAL')
stat=0;
else
fprintf('%s\t%s\t%s\n','fixedPointSolverSub:', res.sol.itr.prosta,res.sol.itr.solsta);
stat=1;
end
% Primal variables
x = res.sol.itr.xx;
% Dual variables corresponding to constraints
y = res.sol.itr.y;
% Dual variables corresponding to bounds on variables.
z = res.sol.itr.slx - res.sol.itr.sux;
% Dual variables of affine conic constraints
w = res.sol.itr.doty;
fprintf('%s\n','Optimality conditions')
fprintf('%6.2g\t%s\n',norm(prob.c - prob.a'*y - z - prob.f'*w,inf), '|| c - A''*y - z - F''w ||_inf');
fprintf('%6.2g\t%s\n',norm(x(2*nint+2:4*nint+1) - x(1:2*nint).*log(x(1:2*nint)/x(2*nint+1)),inf), '|| t - x*log(x/y) ||_inf');