Thanks for the great hint. I’ve had a closer look at the problem formulation and I came also to the conclusion, that it’s worth a try. I’m somehow struggling how to get this formulation to acados correctly. I’ve tried the follwing code:
%% Model
model.nx = 273;
model.nu = 0;
model.sym_x = SX.sym('x',273);
model.expr_f_expl = zeros(273,1);
model.expr_h = ceq; % in ceq are the 260 non-linear equality constraints
model.expr_ext_cost = 0;
%% discretization
N = 1;
T = 1; % time horizon length
x_0 = zeros(273,1);
nlp_solver = 'sqp';
qp_solver = 'full_condensing_hpipm';
qp_solver_cond_N = 1;
sim_method = 'erk';
nx = model.nx;
nu = model.nu;
%% model to create the solver
ocp_model = acados_ocp_model();
model_name = 'mod';
% acados ocp model
ocp_model.set('name', model_name);
ocp_model.set('T', T);
% symbolics
ocp_model.set('sym_x', model.sym_x);
Vxe = zeros(length(x_0));
Vxe(1:10,1:10) = eye(10);
% cost
ocp_model.set('cost_type', 'linear_ls');
ocp_model.set('cost_Vx', zeros(1,273));
ocp_model.set('cost_Vu', 1:0);
ocp_model.set('cost_Vz', 1:0);
ocp_model.set('cost_W', 1);
ocp_model.set('cost_y_ref', 0);
ocp_model.set('cost_type_e', 'linear_ls');
ocp_model.set('cost_Vx_e', Vxe);
ocp_model.set('cost_W_e', 2*eye(nx));
ocp_model.set('cost_y_ref_e', zeros(273,1));
ocp_model.set('dyn_type', 'explicit');
ocp_model.set('dyn_expr_f', model.expr_f_expl);
% constraints
ocp_model.set('constr_expr_h', model.expr_h);
ocp_model.set('constr_lh', zeros(260,1)); % lower bound on h
ocp_model.set('constr_uh', zeros(260,1)); % upper bound on h
ocp_model.set('constr_x0', zeros(273,1));
%% acados ocp set opts
ocp_opts = acados_ocp_opts();
ocp_opts.set('param_scheme_N', N);
ocp_opts.set('nlp_solver', nlp_solver);
ocp_opts.set('sim_method', sim_method);
ocp_opts.set('qp_solver', qp_solver);
ocp_opts.set('qp_solver_cond_N', qp_solver_cond_N);
%% create ocp solver
ocp = acados_ocp(ocp_model, ocp_opts);
x_traj_init = zeros(nx, N+1);
u_traj_init = zeros(nu, N);
% set trajectory initialization
ocp.set('init_x', x_traj_init);
ocp.set('init_u', u_traj_init);
% solve
ocp.solve();
If I execute the code, Windows says that cc1.exe stopped working and MATLAB crashes with the following error:
Error using mbuild (line 166)
Unable to complete successfully.
The command 'C:\ProgramData\MATLAB\SupportPackages\R2020a\3P.instrset\mingw_w64.instrset\bin\gcc' exited with a return value '1'
Error in ocp_generate_casadi_ext_fun (line 185)
mbuild(c_files_path{:}, '-output', lib_name, 'CFLAGS="$CFLAGS"', 'LDTYPE="-shared"', ['LDEXT=', ldext]);
Error in acados_ocp (line 152)
ocp_generate_casadi_ext_fun(obj.model_struct, obj.opts_struct);
Error in main(line 187)
ocp = acados_ocp(ocp_model, ocp_opts);
which means, that already the acados_ocp-command fails. The last ouptut before the error is
acados MEX interface compiled successfully
Note: The cost function I was trying to implement is 1/2*(x(1:10)'*(x(1:10))
, hence, the first 10 elements of the decision variables squared ( f(x) = \frac{1}{2}(x_1^2 + x_2^2 + \ldots + x_{10}^2))
I would be very grateful for any hint how to resolve this problem.