Unable to convert expression into double array

5 Ansichten (letzte 30 Tage)
Param Budhraja
Param Budhraja am 20 Aug. 2020
Kommentiert: Walter Roberson am 22 Aug. 2020
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);

Antworten (1)

Walter Roberson
Walter Roberson am 22 Aug. 2020
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 Kommentare
Param Budhraja
Param Budhraja am 22 Aug. 2020
I understand where the problem is. But I don't understand how to solve it?
Walter Roberson
Walter Roberson am 22 Aug. 2020
Sorry I am not familiar with those tools.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by