In this PR, we make the collection of residuals automatic, so the users no longer have to pipe residuals from leaf node submodels all the way manually to top level model.
How does it work under the hood?
What has been done is very similar to con_outputs. We leverage the mechanism that automatically collects outputs, and the user have to define what subsets of the outputs constitute a 'residual'.
Why is it different to how we treat con_outputs?
con_outputs allow the user to set equality and inequality bounds on the variables, while residuals are always constrained to 0
con_outputs are added to decision variables, and residuals are not.
con_outputs are a property of the problem, and set up with the definition of an optimal control problem (OCP).
residuals are a property of the model, it defines a DAE. Imagine when we can use different tire sumodels in a vehicle model, while some tire models contain residuals as they are formulated as DAEs, and some other tire models don't, we want the top-level model to be able to automatically decide what residuals it have with different submodel compositions! As such, residuals are a model property
How should I change my model?
At the model where residuals exist (see this diff as an example)
add some names to the outputs that we would later use as residuals, eg, "res_ax", "res_ay". These simply add some outputs to the model, they don't automatically become residuals yet.
define the residual names, which must be a subset of the outputs.
populate the residual outputs just like any other ordinary outputs
At parent models (see this diff as an example), simply remove all the operations that pipe residuals from child models
Summary
In this PR, we make the collection of residuals automatic, so the users no longer have to pipe residuals from leaf node submodels all the way manually to top level model.
How does it work under the hood?
What has been done is very similar to
con_outputs
. We leverage the mechanism that automatically collects outputs, and the user have to define what subsets of the outputs constitute a 'residual'.Why is it different to how we treat
con_outputs
?How should I change my model?
At the model where residuals exist (see this diff as an example)
At parent models (see this diff as an example), simply remove all the operations that pipe residuals from child models