For nlp: Xfunction input arguments must be purely symbolic. Argument 0(x) is not symbolic.

689 views
Skip to first unread message

Paulina

unread,
Jun 1, 2022, 7:13:44 AM6/1/22
to CasADi
Hi,

I want to solve the nlp for 3 systems simultaneously. Each system is identical so I've defined the variables, for example the states X,  as:

X = SX.sym('x',nx,3); 

where nx is the number of states and 3 is for the three systems. 

The problem formulation is:

prob = struct('f', J, 'x', vertcat(w{:}), 'g', vertcat(g{:}), 'p', [Uk_1_0; Par_norm_mx;Z0_mx]);

solver = nlpsol('solver', 'ipopt', prob);

where prob is a struct with fields:

    f: [3x3 casadi.MX]
    x: [654×3 casadi.MX]
    g: [666×3 casadi.MX]
    p: [10×3 casadi.MX]


I discretised using orthogonal collocations, but when using the nlpsol I got this error:

For nlp: Xfunction input arguments must be purely symbolic.
Argument 0(x) is not symbolic.

Can you please advise me on this? is it possible to solve three systems at the same time or is it better to create a different variable for each of them? 

Thank you!

Paulina.

PS. I've tried the exact same problem but for a single system (instead of 3) and it did work well. 

Paulina

unread,
Jun 15, 2022, 9:13:05 AM6/15/22
to CasADi
btw, I think the problem was that the objective function f should be a scalar (1x1 casadi.MX). 

Bruno M L

unread,
Jul 15, 2022, 2:44:59 PM7/15/22
to CasADi
Are you trying to repeatedly call the solver for different parameters? Take a look at this blog post. It is possible to encapsulate a solver call in a casadi Function
Reply all
Reply to author
Forward
0 new messages