Skip to content

Commit 6e1409e

Browse files
committed
removed: k>H_c logic for C codegen
This is no longer necessary for recent LinearMPC.jl versions
1 parent 7a0a8a0 commit 6e1409e

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

ext/LinearMPCext.jl

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,8 @@ function Base.convert(::Type{LinearMPC.MPC}, mpc::ModelPredictiveControl.LinMPC)
6868
# --- Manipulated inputs constraints ---
6969
Umin, Umax = mpc.con.U0min + mpc.Uop, mpc.con.U0max + mpc.Uop
7070
I_u = Matrix{Float64}(I, nu, nu)
71-
# add_constraint! does not support u bounds pass the control horizon Hc
72-
# so we compute the extremum bounds from k=Hc-1 to Hp, and apply them at k=Hc-1
73-
Umin_finals = reshape(Umin[nu*(Hc-1)+1:end], nu, :)
74-
Umax_finals = reshape(Umax[nu*(Hc-1)+1:end], nu, :)
75-
umin_end = mapslices(maximum, Umin_finals; dims=2)
76-
umax_end = mapslices(minimum, Umax_finals; dims=2)
77-
for k = 0:Hc-1
78-
if k < Hc - 1
79-
umin_k, umax_k = Umin[k*nu+1:(k+1)*nu], Umax[k*nu+1:(k+1)*nu]
80-
else
81-
umin_k, umax_k = umin_end, umax_end
82-
end
71+
for k = 0:Hp-1
72+
umin_k, umax_k = Umin[k*nu+1:(k+1)*nu], Umax[k*nu+1:(k+1)*nu]
8373
c_u_k = C_u[k*nu+1:(k+1)*nu]
8474
ks = [k + 1] # a `1` in ks argument corresponds to the present time step k+0
8575
for i in 1:nu

0 commit comments

Comments
 (0)