Skip to content

Commit 01984d8

Browse files
committed
update doc related to ŷ debug
1 parent 84910fc commit 01984d8

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

docs/src/manual/nonlinmpc.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ The keyword argument `Ewt` weights the economic costs relative to the other term
191191
objective function. The term must be large enough to be significant but a too high value can
192192
lead to a static error on the angle setpoint. The second element of `Mwt` is zero since the
193193
speed ``ω`` is not requested to track a setpoint. The closed-loop response to a 180°
194-
setpoint is similar:
194+
setpoint is:
195195

196196
```@example 1
197197
unset_time_limit_sec(empc.optim) # hide
@@ -202,7 +202,7 @@ savefig(ans, "plot5_NonLinMPC.svg"); nothing # hide
202202

203203
![plot5_NonLinMPC](plot5_NonLinMPC.svg)
204204

205-
and the energy consumption is almost identical:
205+
and the energy consumption is slightly lower:
206206

207207
```@example 1
208208
function calcW(res)
@@ -212,7 +212,7 @@ end
212212
Dict(:W_nmpc => calcW(res_ry), :W_empc => calcW(res2_ry))
213213
```
214214

215-
But, for a 10° step disturbance:
215+
Also, for a 10° step disturbance:
216216

217217
```@example 1
218218
res2_yd = sim!(empc, N, [180; 0]; plant=plant2, x0=[π, 0], x̂0=[π, 0, 0], y_step=[10, 0])

src/predictive_control.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ end
552552
@doc raw"""
553553
initpred!(mpc, model::LinModel, d, ym, D̂, R̂y, R̂u)
554554
555-
Init linear model prediction matrices `F`, `q̃` and `p`.
555+
Init linear model prediction matrices `F, q̃, p` and current estimated output `ŷ`.
556556
557557
See [`init_predmat`](@ref) and [`init_quadprog`](@ref) for the definition of the matrices.
558558
"""
@@ -581,7 +581,7 @@ end
581581
@doc raw"""
582582
initpred!(mpc::PredictiveController, model::SimModel, d, ym, D̂, R̂y, R̂u)
583583
584-
Init `Ŷop`, `d0` and `D̂0` matrices when model is not a [`LinModel`](@ref).
584+
Init `ŷ, Ŷop, d0, D̂0` matrices when model is not a [`LinModel`](@ref).
585585
586586
`d0` and `D̂0` are the measured disturbances and its predictions without the operating points
587587
``\mathbf{d_{op}}``. The vector `Ŷop` is kept unchanged if `mpc.estim` is not an

test/test_predictive_control.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ end
372372
nmpc = NonLinMPC(linmodel, Mwt=[0], Nwt=[0], Cwt=Inf, Ewt=1, JE=JE, Hp=Hp, Hc=1)
373373
u = moveinput!(nmpc)
374374
@test u [1] atol=5e-2
375+
# ensure that the current estimated output is updated for correct JE values:
376+
@test nmpc. ModelPredictiveControl.evalŷ(nmpc.estim, nothing, Float64[])
375377
linmodel2 = LinModel([tf(5, [200, 1]) tf(7, [800,1])], 300.0, i_d=[2])
376378
f(x,u,d) = linmodel2.A*x + linmodel2.Bu*u + linmodel2.Bd*d
377379
h(x,d) = linmodel2.C*x + linmodel2.Dd*d

0 commit comments

Comments
 (0)