Add a constraint on cost value

Hi :wave:

I’m using python with external cost and IRK integrator.
I would like to define a constraint on the whole solution cost value rather than on a horizon step.
Based on the Problem Formulation PDF it doesn’t seem to be possible. But it is needed for some formulations.

One of my ideas was to set it as a terminal constraint, by accumulating the costs on the path to get the same value as get_cost(). But I didn’t manage to setup a variable to store and update the accumulated cost value along the path.
I’ve tried to put it in the state, but realized that it will be integrated, and so I wouldn’t get Jk+1 = h * l(x,u) + Jk.

Any help would be appreciated,
Rémi

Hi :waving_hand:

you can use discrete dynamics, i.e. you provide a function x_{k+1} = f(x_k, u_k). This allows you to add the cost terms. But you will then need to define the integrator for the other states yourself.

Hope this helps,
Katrin

1 Like

Thank you for your answer,

I’ve implemented a rk4 for the other states. I haven’t compared the accuracy with IRK integrator yet, but it seems to work well.

1 Like