Skip to content

Commit 21a6350

Browse files
committed
NonLinModel: default_nintreturns 0 with nint_u
1 parent 71da21e commit 21a6350

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

docs/src/manual/linmpc.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ model = setop!(LinModel(sys, Ts), uop=[20, 20], yop=[50, 30])
5454
```
5555

5656
The `model` object will be used for two purposes : to construct our controller, and as a
57-
plant simulator to test the design.
57+
plant simulator to test the design. Its sampling time is 2 s thus the control period will be
58+
2 s as well.
5859

5960
## Linear Model Predictive Controller
6061

6162
A linear model predictive controller (MPC) will control both the water level ``y_L`` and
62-
temperature ``y_T`` in the tank, at a sampling time of 2 s. The tank level should also never
63-
fall below 45:
63+
temperature ``y_T`` in the tank. The tank level should also never fall below 45:
6464

6565
```math
6666
y_L ≥ 45

src/controller/linmpc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ arguments.
108108
- `optim=JuMP.Model(OSQP.MathOptInterfaceOSQP.Optimizer)` : quadratic optimizer used in
109109
the predictive controller, provided as a [`JuMP.Model`](https://jump.dev/JuMP.jl/stable/api/JuMP/#JuMP.Model)
110110
(default to [`OSQP.jl`](https://osqp.org/docs/parsers/jump.html) optimizer).
111-
- additionnal keyword arguments are passed to [`SteadyKalmanFilter`](@ref) constructor.
111+
- additional keyword arguments are passed to [`SteadyKalmanFilter`](@ref) constructor.
112112
113113
# Examples
114114
```jldoctest

src/state_estim.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,14 @@ end
250250
default_nint(model::SimModel, i_ym=1:model.ny, nint_u=0)
251251
252252
One integrator on each measured output by default if `model` is not a [`LinModel`](@ref).
253+
254+
If the integrator quantity per manipulated input `nint_u ≠ 0`, the method returns zero
255+
integrator on each measured output.
253256
"""
254257
function default_nint(model::SimModel, i_ym=1:model.ny, nint_u=0)
255258
validate_ym(model, i_ym)
256-
return fill(1, length(i_ym))
259+
nint_ym = iszero(nint_u) ? fill(1, length(i_ym)) : fill(0, length(i_ym))
260+
return nint_ym
257261
end
258262

259263
@doc raw"""

0 commit comments

Comments
 (0)