Unable to convert expression into double array
조회 수: 5 (최근 30일)
이전 댓글 표시
I am using sostools toolbox. The complete error message I am getting is
Error using symengine
Unable to convert expression into double array.
Error in sym/double (line 709)
Xstr = mupadmex('symobj::double', S.s, 0);
Error in getequation (line 236)
At(:,(i-1)*dimp^2+1:i*dimp^2) = sparse(-double(jacobian(Mivec,decvartable))');
Error in sosconstr (line 81)
getequation(char(symexpr),sos.vartable,sos.decvartable,sos.varmat.vartable);
Error in sosineq (line 105)
sos = sosconstr(sos,'ineq',symexpr);
Error in sos_ex1 (line 26)
prog = sosineq(prog,exp2);
Edit: My code (I have also attached it)
clear;
clc;
syms x1 x2 x3 v1 v2 v3 e1 y real;
x = [x1 x2 x3];
v = [v1 v2 v3]';
h1 = -x1^2 -1;
h2 = x1^4 + x1^2;
I = [1 0 0;0 1 0;0 0 1];
A = [h1 h2 x1*x3;0 0 1;0 0 -1];
B = [0 0 1]';
C = [0 1 0];
solver_opt.solver = 'sedumi';
%%
prog = sosprogram([x1 x2 x3 v1 v2 v3 y]);
prog = sosdecvar(prog, e1);
[prog,e2] = sossosvar(prog, [x1 ;x2 ;x3]);
[prog,P] = sospolymatrixvar(prog, monomials(x,0), [3,3], 'symmetric'); % Assumption P is a constant matrix
[prog,F] = sospolymatrixvar(prog, monomials(y,2), [1,1]); % Assumption F is of degree 2
%%
mat2 = P*A' + A*P + P*C'*F'*B' + B*F*C*P + e2*I;
exp1 = v'*(P - e1*I)*v;
exp2 = -v'*(P*A' + A*P + P*C'*F'*B' + B*F*C*P + e2*I)*v;
prog = sosineq(prog,exp1);
prog = sosineq(prog,exp2);
prog = sosineq(prog,e1);
%%
prog = sossolve(prog,solver_opt);
댓글 수: 0
답변 (1개)
Walter Roberson
2020년 8월 22일
You have
[prog,F] = sospolymatrixvar(prog, monomials(y,2), [1,1]); % Assumption F is of degree 2
This adds a variable coeff_16 to be associated with y^2 and it puts the isolated expression coeff_16*y^2 into F
exp2 = -v'*(P*A' + A*P + P*C'*F'*B' + B*F*C*P + e2*I)*v;
This involves that term.
Later, when prog = sosineq(prog,exp2); is to be calculated, sosineq() attempts to find the numeric jacobian of parts of exp2. It gets down to trying to calculate the jacobian of -2*coeff_11*coeff_16 . But when you differentiate that with respect to coeff_11 then the result involves the symbolic variable coeff_16, and when you differentiate with respect to coeff_16 then the result involves the symbolic variable coeff_11 . Therefore the jacobian involves unresolved symbolic variables, and the numeric jacobian cannot be caclulated.
The problem is definitely when processing the coefficients associated with y^2
댓글 수: 2
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!