Skip to content

Commit f66c105

Browse files
committed
debug
1 parent c3e19f8 commit f66c105

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

ext/LinearMPCext.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ function Base.convert(::Type{LinearMPC.MPC}, mpc::ModelPredictiveControl.LinMPC)
2020
xo = estim.x̂op
2121
uo = model.uop
2222
yo = model.yop
23-
!iszero(yo) && error("LinearMPC does not support non-zero output operating points yop.")
2423
if !iszero(model.dop)
2524
@warn "LinearMPC does not support measured disturbance operating points dop.\n" *
2625
"Ensure to subtract the operating point from the measurement at each time "*
2726
"step before solving the MPC problem."
2827
end
29-
LinearMPC.set_operating_point!(newmpc; xo, uo, relinearize=false)
3028
# --- State observer parameters ---
3129
Q, R = estim.cov.Q̂, estim.cov.
3230
set_state_observer!(newmpc; C=estim.Ĉm, Q, R)
@@ -69,10 +67,10 @@ function Base.convert(::Type{LinearMPC.MPC}, mpc::ModelPredictiveControl.LinMPC)
6967
end
7068
end
7169
# --- Output constraints ---
72-
Ymin, Ymax = mpc.con.Y0min + mpc.Yop, mpc.con.Y0max + mpc.Yop
70+
Y0min, Y0max = mpc.con.Y0min, mpc.con.Y0max
7371
C_y = -mpc.con.A_Ymin[:, end]
7472
for k in 1:Hp
75-
ymin_k, ymax_k = Ymin[(k-1)*ny+1:k*ny], Ymax[(k-1)*ny+1:k*ny]
73+
ymin_k, ymax_k = Y0min[(k-1)*ny+1:k*ny], Y0max[(k-1)*ny+1:k*ny]
7674
c_y_k = C_y[(k-1)*ny+1:k*ny]
7775
ks = [k + 1] # a `1` in ks argument corresponds to the present time step k+0
7876
for i in 1:ny
@@ -84,13 +82,13 @@ function Base.convert(::Type{LinearMPC.MPC}, mpc::ModelPredictiveControl.LinMPC)
8482
end
8583
end
8684
# --- Terminal constraints ---
87-
x̂min, x̂max = mpc.con.x̂0min + estim.x̂op, mpc.con.x̂0max + estim.x̂op
85+
x̂0min, x̂0max = mpc.con.x̂0min, mpc.con.x̂0max
8886
c_x̂ = -mpc.con.A_x̂min[:, end]
8987
I_x̂ = Matrix{Float64}(I, nx̂, nx̂)
9088
ks = [Hp + 1] # a `1` in ks argument corresponds to the present time step k+0
9189
for i in 1:nx̂
92-
lb = isfinite(x̂min[i]) ? [x̂min[i]] : zeros(0)
93-
ub = isfinite(x̂max[i]) ? [x̂max[i]] : zeros(0)
90+
lb = isfinite(x̂0min[i]) ? [x̂0min[i]] : zeros(0)
91+
ub = isfinite(x̂0max[i]) ? [x̂0max[i]] : zeros(0)
9492
soft = (c_x̂[i] > 0)
9593
Ax = I_x̂[i:i, :]
9694
add_constraint!(newmpc; Ax, lb, ub, ks, soft)

0 commit comments

Comments
 (0)