Python interface - nonlinear least squares and constraints on algebraic variables

Dear all,

first, thanks for the great work. I have a question regarding acados embedded.
For now only linear-least squares cost are supported:
https://docs.acados.org/interfaces/index.html#acados-embedded-python

  • Will the nonlinear case also be supported soon?
  • Also, will linear and nonlinear constraints for algebraic variables be supported soon?

Thanks for the replays.
Cheers
Armin

Hi Armin!

Thanks for your interest in acados :slight_smile: Nonlinear least-squares should be implemented ASAP (they are already implemented in the core and in the MATLAB interface). Regarding constraints including algebraic variables, they are not implemented in the core either, but we can try to allocate some time to do it in the next days.

Hi Andrea,

thanks for the fast reply! I am looking forward to it. Will also report a successful use as soon as it is ready!

Cheers
Armin

Hey Armin, both features are now implemented and available from both MATLAB and Python since some time already. I forgot to follow up on this thread :wink:

1 Like

@zanellia
Could you please detail how to put a constraint on an algebraic variable, maybe through a code snippet?
Many Thanks

Cheers
Walter

@walter
You should be able to use the algebraic variable in the definition of the nonlinear constraint h.
This file is testing it from octave: https://github.com/acados/acados/blob/master/examples/acados_matlab_octave/test/test_ocp_simple_dae.m

Let me know if that works for you.

@FreyJo
Hi Jonathan,

It works, thank you.
I am only experiencing problems when an hard constraint on the algebraic variable becomes active together with a hard constraint on a state variable at terminal time.
In this case I get an error:

Traceback (most recent call last):
File “/home/walter/acados/examples/acados_python/getting_started/HYPEMLIFE_NMPC_test/minimal_Li_SPM_closed_loop_5.py”, line 124, in
raise Exception(‘acados acados_ocp_solver returned status {}. Exiting.’.format(status))
Exception: acados acados_ocp_solver returned status 4. Exiting.
QP solver returned error status 3

Process finished with exit code 1

Do you think I should implement a soft constraint on the state variable at terminal time?
Thank you

@FreyJo
Hi,

I implemented soft constraints on state variable at terminal time. Using the SQP solver sometimes it finds a solution, sometimes it is not able to converge within max iteration numbers. I increased max_iter to 1000 but it didn’t converge.
With SQP_RTI instead it always finds a solution in every condition.

Did you print the iterates, with print_statistics().
You should see up to which tolerance it is able to solve the problem.
I would probably try using a higher tolerance.