Closed baggepinnen closed 3 months ago
Is structural_simplify
called with the inputs specified, or are these inputs only specified to build_explicit_observed_function
?
Yeah, we call
(f_oop, f_ip), dvs, psym, io_sys = ModelingToolkit.generate_control_function(car_model, inputs, split=false)
f_obs = ModelingToolkit.build_explicit_observed_function(io_sys, outputs; inputs = inputs)
where generate_control_function
internally calls structural_simplify
with inputs specified
When
sys
has been processed byio_preprocessing
andinputs
are passed tobuild_explicit_observed_function
, these inputs are sorted out of the parameter vector by the codeHowever, the following code does not account for this
so the generated code still expects a parameter vector that is the length of
length(ps) + length(inputs)
rather than justlength(ps)
. This causes the generated code to be incorrect, accessing parameter values at the wrong indices.I tried
which makes the parameter array in the generated code of the correct length, but the order is still wrong. @AayushSabharwal I don't understand what
reorder_parameters
is supposed to do, can you have a look?It appears possible for us to work around the issue by using
split=false
tostructural_simplify
CC @shobhitvoleti