%% Examine coneprog Solution Process
% Create a second-order cone programming problem. To save time and memory, create the highest-index constraint first.

A = diag([1,2,0]);
b = zeros(3,1);
d = [0;0;1];
gamma = -1;
socConstraints(3) = secondordercone(A,b,d,gamma);
A = diag([3,0,1]);
d = [0;1;0];
socConstraints(2) = secondordercone(A,b,d,gamma);
A = diag([0;1/2;1/2]);
d = [1;0;0];
socConstraints(1) = secondordercone(A,b,d,gamma);
f = [-1;-2;-4];
options = optimoptions('coneprog','Display','iter');
A = [];
b = [];
Aeq = [];
beq = [];
lb = [];
ub = [];

% Solve the problem, requesting information about the solution process.

[x,fval,exitflag,output] = coneprog(f,socConstraints,A,b,Aeq,beq,lb,ub,options)

% Both the iterative display and the output structure show that coneprog used 12 iterations to arrive at the solution.
% The exit flag value 1 and the output.message value 'Optimal solution found.' indicate that the solution is reliable.
% The output structure shows that the infeasibilities tend to decrease through the solution process, as does the duality gap.
% You can reproduce the fval output by multiplying f'*x.

f'*x

% Copyright 2020 The MathWorks, Inc.