After reading that a non-linear cost formulation is added to the python interface, I wanted to try out that option. For that I have a few questions:
Which non-linear cost formulations are allowed?
How can they be implemented in python interface? Up to now, the only variables to be specified are the numerical matrix values for Vx, Vu and Vz and the numerical y_ref values
I haven’t looked at that example prior to asking the question, since I assumed there would not be any documentation or examples for the python interface yet. After looking at the example, I think that I understand how the costs are implemented. However I have two points which need to be clear. I would appreciate if you can confirm or correct them:
The Vx, Vu and Vz costs do not serve a purpose in Nonlinear Least Squares, since everything can now be expressed as W and the cost_r terms
The Nonlinear Least Squares allows for costs expressed as sum of weighted squares of residual functions r(), which can only depend on state x and control u and time t, e.g. r(x,u,t). This formulations does not allow for negative or linear cost terms and trying to implement a linear cost c(x,u,t) by defining the residuals as square root of c() would cause numerical problems
As for the second question, I am just trying to understand the exact limitations of the Nonlinear Cost Functions. I am interested in Economic Costs or Arbitrary Cost formulations and I inquired about a “hack” that would make linear costs possible to implement with NLS limitations and what the downside of such a “hack” would be.
just an addition:
If you want to penalize something in a linear way using the NLS module, the best way is probably to do this with a slack variable reformulation.