Hi Prof Logberg,
I think I've found a bug in Yalmip.
I'm trying to solve SOS-relaxation problems and the following error in matlab has occured (see also attached screenshot);
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Undefined function 'findelements' for input arguments of type 'double'.
Error in solvesos (line 321)
h{constraint} = h{constraint}(findelements(sum(h{constraint},2)),:);
Error in step3_HilbertB (line 34)
[sol, u, Q]=solvesos(prog, [], ops, coeff2); % Running optimizer
Error in debug (line 14)
[s, G, res] = step3_HilbertB(n,m,v, [v0 V], 1,1/(2^1), solver);
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Since this problem is occuring with mosek and not sedumi, I think its a bug in Yalmip code.
This is done with random input data to construct the functions. I've had a look at the solvesos.m file, and my guess is that
in the mosek formulation of the problem, the constraint variables become small and sos.clean makes them 0.
Is this a known issue with some simple fix?
I'd be happy to send you the data that generates this problem if you'd like, I've copied my code for "step3_HilbertB" below;
Best Regards,
Abhishek B.
=================================================================================================
function [success, G, res] = step3_HilbertB(n,m,v,V,d,delta,solver)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
%% sdpvar's
X = sdpvar(n,1);
Y = sdpvar(m,1);
Z = kron(X,Y);
monlist = monolist([X;Y], d);
monlist = monlist(2:end);
G = sdpvar(size(monlist,1), size(monlist,1),'symmetric'); % matrix of coefficients
phi = monlist'*G*monlist; % vector of decision functions phi
%% linear and quadratic forms
f = v'*kron(Z,Z); % defining the non-sos quad form f
h = V'*Z; % The linear forms h constructed in step 1
F = delta*f + (10)*(h'*h); % non-negative but not sos form
%% sos program
prog = [sos(phi*F);trace(G)==1];
%% decision variables
coeff2 = reshape(G, [1, size(monlist,1)*size(monlist,1)]); % reshaping coefficient into vector
%% sdp solver
ops = sdpsettings('solver', solver);
ops.verbose = 0;
[sol, u, Q]=solvesos(prog, [], ops, coeff2); % Running optimizer
if size(Q)~=0
G1 = reshape(value(coeff2),[size(monlist,1),size(monlist,1)]);
res = max(coefficients((monlist'*G1*monlist)*F - u{1,1}'*Q{1,1}*u{1,1}));
if sol.problem==0 && res<=1e-4
%disp('SOS decomposition is possible.')
G = G1;
success = 1;
else
%disp('SOS decomposition not found.')
success = 0;
G = zeros(size(monlist,1), size(monlist,1));
end
else
success = 0;
G = zeros(size(monlist,1), size(monlist,1));
res = 0;
end
end