Dear all,
During the recent course on optimal control that we organized in Freiburg, based on the feedback from users, we decided to do one more syntax change for the (upcoming) CasADi 3.0. This concerns how functions are being called. The new calling syntax was introduced in CasADi 3.0 RC3 and concerns both MATLAB and Python (but not C++).
Until now, the principle for calling a CasADi Function has been that the Python user passes ether a list or a dictionary in and gets the same type back. Or in MATLAB, the same but with cell arrays and structs:
# Old syntax, Python
[r] = F([a,b])
[s,t] = G([a,b,c])
q = G({'a':a, 'b':b, 'c':c})
% Old syntax, MATLAB
v = F({a,b});
r = v{1};
v = G({a,b,c});
s = v{1};
t = v{2};
q = G(struct('a', a, 'b', b, 'c', c));
This syntax is has now been deprecated and replaced with a more natural calling syntax, using variable number of inputs and outputs:
# New syntax, Python
r = F(a,b)
s,t = G(a,b,c)
q = G(a=a, b=b, c=c)
% New syntax, MATLAB
r = F(a,b);
[s,t] = G(a,b,c);
q = G('a', a, 'b', b, 'c', c);
Since it's not always practical to work with variable number of inputs/outputs, the old calling syntax is still available, but has been renamed "call":
# New alternative syntax, Python
[r] = F.call([a,b])
[s,t] = G.call([a,b,c])
q = G.call({'a':a, 'b':b, 'c':c})
% New alternative syntax, MATLAB
v = F.call({a,b});
r = v{1};
v = G.call({a,b,c});
s = v{1};
t = v{2};
q = G.call(struct('a', a, 'b', b, 'c', c));
The alternative syntax is also required if you e.g. wants to force a function call to be inlined.
Best regards,
Joel