Dear acados
Matlab & Octave users
We are excited to announce significant updates to the Matlab and Octave interface of acados
aiming to closely align it with the Python interface.
For now those changes are available on the branch acados/matlab_interface_overhaul and are planned to be released in acados
v0.4.0
.
Key updates
With the recent update in PR #1193, the problem formulation objects closely match the Python correspondents.
We hope for feedback on that from the acados community
For now those changes are available on the branch acados/matlab_interface_overhaul.
The changes are detailed and motivated below.
OCP solver creation
An acados OCP solver can now be created in different ways.
Option 1) is planned to be deprecated in a future release, option 2) is the preferred one for which new features will be added and option 3) is a way to transition to the new interface, which only requires minimal changes to existing code and will be supported longer than 1).
1) old / legacy style
Previously, an acados OCP solver in Matlab was created by calling:
% create OCP
ocp_model = acados_ocp_model();
ocp_opts = acados_ocp_opts();
% set fields of ocp_model, ocp_opts using ocp_model.set(...)
ocp_solver = acados_ocp(ocp_model, ocp_opts);
The classes acados_ocp_model
, acados_ocp_opts
and acados_ocp
are part of the legacy Matlab interface of acados.
This will still work in acados
v0.4.*
.
However, we plan on deprecating it and suggest for users to transition to the new interface 2), or the explicit translation to the new formulation object 3), both detailed below.
The differences in behavior are that:
acados_ocp
returns anAcadosOcpSolver
object, which can be interacted with similarly to the oldacados_ocp
class.- The
AcadosOcpSolver
does not have fieldsmodel_struct
andopts_struct
corresponding to the legacy interface, instead there is a fieldocp
of typeAcadosOcp
from which information about the problem and solver can be deduced.
2) new interface for OCP solver description
The new Matlab interface to describe OCP solvers for their creation can be used with the following syntax:
% OCP formulation
ocp = AcadosOcp();
% provide OCP formulation and solver options by setting properties
ocp_solver = AcadosOcpSolver(ocp);
An example for this can be found in the file new_minimal_example_ocp.m
Interactions with AcadosOcpSolver
follow the same syntax as before, .set(), .get()
, with the acados_ocp
class.
3) transition to new interface
The easiest way to update your code to change your code from
ocp_solver = acados_ocp(ocp_model, ocp_opts);
to
ocp = setup_AcadosOcp_from_legacy_ocp_description(ocp_model, ocp_opts)
ocp_solver = AcadosOcpSolver(ocp);
This makes the translation of the old formulation objects into the new one more explicit.
This also helps users who want to transition to the new interface. One can compare the AcadosOcp
objects obtained with the new interface with the one obtained by the function setup_AcadosOcp_from_legacy_ocp_description
.
Integrator / solver for initial value problems creation
The changes done to the integrator interface are pretty much analogous to the one of the OCP solver.
An example can be found in the file new_minimal_example_sim.m
Background and Motivation
The classes AcadosOcp
and subclasses AcadosModel
, AcadosOcpConstraints
, AcadosOcpCost
, AcadosOcpDims
, AcadosOcpOptions
now completely match their Python correspondents, which are extensively documented.
The mismatch between some names between the Matlab and Python interface was causing trouble for both users and developers of acados.
These classes have existed in Matlab for a long time now, but were primarily used in the background.
Internally, there has been a translation function, similar to setup_AcadosOcp_from_legacy_ocp_description
for a long time, since the existence of an acados
Simulink interface, and more prominently, since the whole Matlab interface uses the template based solver as a backend, introduced in PR #934.
Lastly, this cleanup, will enable an extension of the Matlab interface to acados OCP solvers based on multi-phase OCP formulations, which we plan for the near future.
Beta testing
Your insights are invaluable in ensuring the robustness and user-friendliness of these updates.
Please check out the branch acados/matlab_interface_overhaul, and let us know if you encounter any issues by opening a new topic in the forum.
We look forward to your feedback and contributions.
Best,
Jonathan & Katrin