tcunis / bisosprob

Toolbox for bilinear sum-of-squares problems.
4 stars 3 forks source link

[s-polynomials degree] Strange output - degree mismatch #15

Closed renatoloureiro closed 2 years ago

renatoloureiro commented 2 years ago

The following is occurring: Given a specific s-polynomial with a given degree, in this case 2

[prob,s2] = sosdecvar(prob,'s2',monomials(x,1:2));

The output in one of the steps gives me an s-polynomial of degree 4 and due to this in one of my demos it's corrupting the next bisection because of size mismatch. (it's actually my guess on why it's not working) Even in the simple demo it occurs for the s2 polynomial, this is the output

sol.s2 = 0.16133x_1^4 - 0.012329x_1^3x_2 - 0.097327x_1^2x_2^2 + 0.067963x_1x_2^3 + 0.32481x_2^4 + 7.8919e-08x_1^3 - 3.1912e-07x_1^2x_2 - 1.2148e-08x_1x_2^2 + 5.2537e-07x_2^3 + 0.10503x_1^2 + 0.092552x_1x_2 + 0.56751x_2^2

renatoloureiro commented 2 years ago

Would you mind give me a hint on why this is happening or if it's truly a bug somewhere unknown to you

tcunis commented 2 years ago

This is due to the definition of a sum-of-squares decision variable in Gram matrix form:

s(x) = z(x)' Q z(x)

where z is the vector of monomials as provided, in your case, z = monomials(x, 1:2).