Modifying solver tolerance after solver creation

Hi !

I’m using the Python interface. I’m currently implementing a NMPC with Acados and I would like the tolerance of the solver to depend on my problem’s iterations. However when setting:

ocp_solver = AcadosOcpSolver(acados_ocp, json_file="acados_ocp.json")
ocp_solver.acados_ocp.solver_options.nlp_solver_tol_whatever = my_tol

after the solver is created, it looks like this new tolerance is not taken into account but the one originally defined in acado_ocp is.

Is this an intended behaviour ? If not, could it be considered as future feature of the python interface ?
Thanks,
François

Hi François,

in general, it is not possible to interact with the AcadosOcpSolver by setting things in AcadosOcpSolver.AcadosOcp.
AcadosOcp is just an object for the formulation, probably one should even forbid changing stuff inside AcadosOcpSolver.AcadosOcp by making it private.

Modifying the tolerance after creation should be done via the options_set() routine.
I will add this soon and write here again.

Best,
Jonathan

1 Like

I already pushed it to the master, see this commit: https://github.com/acados/acados/commit/da58ccce733f03e6cd6b2447899c57a0abfc9db0

Cheers,
Jonathan

Thanks Jonathan for the quick fix !

Hi jonathan,

In the same spirit, would it be possible to change nlp_max_iter after solver creation also ?

Best,

François

Yes, one would have to add this option for Python.
The only thing it can only store iteration information for the max_iter it was created with.
So if you increase it afterwards you might not get the statistics of the last iterations.