Skip to content

Commit d760fad

Browse files
committed
test: new disturb. reject test with NonLinMPC and NonLinModel
It allows to test that the multiple shooting transcription work as expected, since the stochastic defect are treated separately as linear equality constraints.
1 parent 2ef27c3 commit d760fad

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎test/3_test_predictive_control.jl‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,25 @@ end
11281128
end
11291129
@test u ≈ [2] atol=1e-2
11301130
@test ym ≈ r atol=1e-2
1131+
f(x,u,_,model) = model.A*x + model.Bu*u
1132+
h(x,_,model) = model.C*x
1133+
nlmodel = NonLinModel(f, h, linmodel.Ts, 1, 1, 1, 0, p=linmodel, solver=nothing)
1134+
u, ym = let nlmodel=nlmodel, r=r, outdist=outdist
1135+
estim = UnscentedKalmanFilter(nlmodel, nint_u=[1])
1136+
nmpc_nint_ym = NonLinMPC(estim; Hp=10, transcription=MultipleShooting())
1137+
nlmodel.x0 .= 0
1138+
ym, u = nlmodel() - outdist, [0.0]
1139+
for i=1:25
1140+
ym = nlmodel() - outdist
1141+
preparestate!(nmpc_nint_ym, ym)
1142+
u = moveinput!(nmpc_nint_ym, r)
1143+
updatestate!(nmpc_nint_ym, u, ym)
1144+
updatestate!(nlmodel, u)
1145+
end
1146+
u, ym
1147+
end
1148+
@test u ≈ [2] atol=1e-2
1149+
@test ym ≈ r atol=1e-2
11311150
end
11321151

11331152
@testitem "NonLinMPC and ManualEstimator v.s. default" setup=[SetupMPCtests] begin

0 commit comments

Comments
 (0)