Hi, apologies for bumping an old topic, but I also had a similar question regarding the use of multiple ocp solvers.
In my case, I’m working on a multi-agent problem and would like to execute multiple instances of my controller at the same time. Using the MATLAB interface, I ran into the same issue as Anton where the compilation fails because of read/write permission conflicts. I wanted to ask if this is a limitation with the MATLAB interface only, or would I run into the same problem using e.g. the Python interface?
Besides switching languages, one workaround I thought of is to re-use the same ocp solver for each agent (since the controller itself is identical). For 1 timestep, we solve the ocp for each agent and save the solution data. Then on the next timestep, we use the kth agent’s data to warm-start the solver for the kth agent (see sketch below).
% form the ocp solver beforehand
ocp = acados_ocp(ocp_model, ocp_opts);
%
for i=1:(sim_time/dt)
for k=1:num_agents
% set references, warm-start initializations, etc. for kth agent
ocp.set('cost_y_ref', agents{k}.cost, ... );
...
ocp.set('init_x', agents{k}.init_x);
ocp.set('init_u', agents{k}.init_u);
% solve ocp
ocp.solve();
% save the warm-start data that we need for next timestep
agents{k}.init_x = ocp.get('x');
agents{k}.init_u = ocp.get('u');
...
end
end
Do you think this approach is advisable? The main part that I’m unsure of is which solution fields to save at each timestep - e.g. we definitely need to get/set init_x
and init_u
, but what about init_pi
, the sensitivities, etc. …
Thanks in advance for your thoughts!