Skip to content

Commit

Permalink
Fix cost type detection for casadi versions >= 3.6 (acados#1099)
Browse files Browse the repository at this point in the history
Newer casadi versions do not allow free variables when creating casadi
functions.
  • Loading branch information
sandmaennchen committed May 6, 2024
1 parent 0a46540 commit 703090a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions interfaces/acados_matlab_octave/detect_cost_type.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@
nx = length(x);
nu = length(u);
nz = length(z);
% np = length(p);

% z = model.sym_z;
disp('--------------------------------------------------------------');
if strcmp(stage_type, 'terminal')
expr_cost = model.cost_expr_ext_cost_e;
Expand All @@ -74,7 +72,6 @@
expr_cost = model.cost_expr_ext_cost_0;
disp('Structure detection for initial cost term');
end
cost_fun = Function('cost_fun', {x, u, z}, {expr_cost});

if expr_cost.is_quadratic(x) && expr_cost.is_quadratic(u) && expr_cost.is_quadratic(z) ...
&& ~any(expr_cost.which_depends(p))
Expand All @@ -85,6 +82,7 @@
ny = 0;
Vx = []; Vu = []; Vz = []; W = []; y_ref = []; sym_y = [];
else
cost_fun = Function('cost_fun', {x, u, z}, {expr_cost});
dummy = SX.sym('dummy', 1, 1);

fprintf('Cost function is quadratic -> Reformulating as linear_ls cost.\n');
Expand Down

0 comments on commit 703090a

Please sign in to comment.