I use the Matlab interface and have some questions
I want to change some parameters between the calls of “ocp.solve()”. This works fine with e.g. “ocp.set(‘constr_lbu’, lbu)”, but when I try “ocp.set(‘constr_lbx’, 123)” (the same happens with ‘constr_ubx’) I get the following error:
Error using ocp_set
ocp_set: error setting constr_lbx, wrong dimension, got 1, need 4
I have 4 states and 1 inequality constraint, so setting ‘constr_lbx’ to scalar values should be fine (the scalar constraint I set during code generation works). Strangely enough, if I try “ocp.set(‘constr_lbx’, [1; 1; 1; 1])” the error changes to
Error using ocp_set
ocp_set: error setting constr_lbx, wrong dimension, got 4, need 1
My second issue is that calling “ocp.set(‘cost_zu’, zu)” at runtime crashes Matlab. I get the following error on the terminal:
error: ocp_nlp_dims_get_from_attr: field ns not available
I set the fields “dim_ns” and “cost_zu” during code generation without any errors. Do you have an idea what the problem is?
The setter can be called in two ways, for all fields, where I use ‘p’ as an example:
ocp.set('p', p_val );
This will try to set the parameters p to p_val for all stages of the ocp.
ocp.set('p', p_val, stage);
This will try to set the parameters p to p_val just for the stage with index stage (0 based indexing) of the ocp.
I tried to document this in the example here:
Probably you have an initial condition for x0, which is implemented through lbx, ubx at stage 0 internally. If you want to set the value for the other stages, do something like:
for i:1:N % or N-1
ocp.set(‘constr_lbx’, value, i)
end