from casadi import *
x = MX.sym('x')
y = MX.sym('y')
f = x**2+y**2
V = vertcat([x,y])
nlp = MXFunction(nlpIn(x=V),nlpOut(f=f))I get the following error
XFunctionInternal::XFunctionInternal: Xfunction input arguments must be purely symbolic.
Argument #0 is not symbolic.
I guess this means my V should be defined as an MX.sym, and then splitted into x and y.
Now the problem is, I cannot do this because of the way V is defined in our code (by adding more and more variables along the way), and I also cannot use SX instead of MX as the variables V are to be used as input to an integrator and it seems to me these inputs should always be MX (is this correct?).
Do you think there is any way of solving this within the constraints specified by the previous paragraph?
Kind regards,
Dominique
from casadi import *
V = MX.sym('V',2)
x, y = vertsplit(V)
f = x**2+y**2
nlp = MXFunction(nlpIn(x=V),nlpOut(f=f))
Check the documentation for vertsplit for more details.
Best regards,Joel