Skip to content

Commit 5f4a05b

Browse files
committed
debug tests
1 parent 9d90d70 commit 5f4a05b

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

src/controller/execute.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,11 @@ function linconstraint!(mpc::PredictiveController, model::LinModel)
278278
mpc.con.b[(n+1):(n+nx̂)] .= @. -mpc.con.x̂min + fx̂
279279
n += nx̂
280280
mpc.con.b[(n+1):(n+nx̂)] .= @. +mpc.con.x̂max - fx̂
281-
lincon = mpc.optim[:linconstraint]
282-
set_normalized_rhs(lincon, mpc.con.b[mpc.con.i_b])
281+
if any(mpc.con.i_b)
282+
lincon = mpc.optim[:linconstraint]
283+
set_normalized_rhs(lincon, mpc.con.b[mpc.con.i_b])
284+
end
285+
return nothing
283286
end
284287

285288
"Set `b` excluding predicted output constraints when `model` is not a [`LinModel`](@ref)."
@@ -293,8 +296,11 @@ function linconstraint!(mpc::PredictiveController, ::SimModel)
293296
mpc.con.b[(n+1):(n+nΔŨ)] .= @. -mpc.con.ΔŨmin
294297
n += nΔŨ
295298
mpc.con.b[(n+1):(n+nΔŨ)] .= @. +mpc.con.ΔŨmax
296-
lincon = mpc.optim[:linconstraint]
297-
set_normalized_rhs.(lincon, mpc.con.b[mpc.con.i_b])
299+
if any(mpc.con.i_b)
300+
lincon = mpc.optim[:linconstraint]
301+
set_normalized_rhs(lincon, mpc.con.b[mpc.con.i_b])
302+
end
303+
return nothing
298304
end
299305

300306
@doc raw"""

src/estimator/mhe/execute.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,11 @@ function linconstraint!(estim::MovingHorizonEstimator, model::LinModel)
285285
estim.con.b[(n+1):(n+nV̂)] .= @. -V̂min + estim.F
286286
n += nV̂
287287
estim.con.b[(n+1):(n+nV̂)] .= @. +V̂max - estim.F
288-
lincon = estim.optim[:linconstraint]
289-
set_normalized_rhs.(lincon, estim.con.b[estim.con.i_b])
288+
if any(estim.con.i_b)
289+
lincon = estim.optim[:linconstraint]
290+
set_normalized_rhs(lincon, estim.con.b[estim.con.i_b])
291+
end
292+
return nothing
290293
end
291294

292295
"Set `b` excluding state and sensor noise bounds if `model` is not a [`LinModel`](@ref)."
@@ -301,8 +304,11 @@ function linconstraint!(estim::MovingHorizonEstimator, ::SimModel)
301304
estim.con.b[(n+1):(n+nŴ)] .= @. -Ŵmin
302305
n += nŴ
303306
estim.con.b[(n+1):(n+nŴ)] .= @. +Ŵmax
304-
lincon = estim.optim[:linconstraint]
305-
set_normalized_rhs.(lincon, estim.con.b[estim.con.i_b])
307+
if any(estim.con.i_b)
308+
lincon = estim.optim[:linconstraint]
309+
set_normalized_rhs(lincon, estim.con.b[estim.con.i_b])
310+
end
311+
return nothing
306312
end
307313

308314
"Truncate the bounds `Bmin` and `Bmax` to the window size `Nk` if `Nk < He`."

0 commit comments

Comments
 (0)