|
56 | 56 | @test all((-mpc.con.A_Ŷmin[:, end], -mpc.con.A_Ŷmax[:, end]) .≈ ([1.0,1.1], [1.2,1.3])) |
57 | 57 | end |
58 | 58 |
|
59 | | -@testset "LinMPC moves" begin |
| 59 | +@testset "LinMPC moves and getinfo" begin |
60 | 60 | mpc = LinMPC(LinModel(tf(5, [2, 1]), 3), Nwt=[0], Hp=1000, Hc=1) |
61 | 61 | r = [5] |
62 | 62 | u = moveinput!(mpc, r) |
63 | | - @test u ≈ [1] atol=1e-3 |
| 63 | + @test u ≈ [1] atol=1e-2 |
64 | 64 | u = mpc(r) |
65 | | - @test u ≈ [1] atol=1e-3 |
| 65 | + @test u ≈ [1] atol=1e-2 |
| 66 | + info, _ = getinfo(mpc) |
| 67 | + @test info[:u] ≈ u |
| 68 | + @test info[:Ŷ][end] ≈ 5 atol=1e-2 |
66 | 69 | end |
67 | 70 |
|
68 | 71 | @testset "LinMPC other methods" begin |
@@ -126,24 +129,30 @@ end |
126 | 129 | @test all((nmpc.con.c_Ŷmin, nmpc.con.c_Ŷmax) .≈ ([1.0,1.1], [1.2,1.3])) |
127 | 130 | end |
128 | 131 |
|
129 | | -@testset "NonLinMPC moves" begin |
| 132 | +@testset "NonLinMPC moves and getinfo" begin |
130 | 133 | linmodel = LinModel(tf(5, [2, 1]), 3) |
131 | 134 | nmpc_lin = NonLinMPC(linmodel, Nwt=[0], Hp=1000, Hc=1) |
132 | 135 | r = [5] |
133 | 136 | u = moveinput!(nmpc_lin, r) |
134 | 137 | @test u ≈ [1] atol=1e-3 |
135 | 138 | u = nmpc_lin(r) |
136 | 139 | @test u ≈ [1] atol=1e-3 |
| 140 | + info, _ = getinfo(nmpc_lin) |
| 141 | + @test info[:u] ≈ u |
| 142 | + @test info[:Ŷ][end] ≈ 5 atol=1e-2 |
137 | 143 |
|
138 | 144 | f(x,u,_) = linmodel.A*x + linmodel.Bu*u |
139 | 145 | h(x,_) = linmodel.C*x |
140 | 146 | nonlinmodel = NonLinModel(f, h, 3, 1, 1, 1) |
141 | 147 | nmpc_nonlin = NonLinMPC(nonlinmodel, Nwt=[0], Hp=1000, Hc=1) |
142 | 148 | r = [5] |
143 | 149 | u = moveinput!(nmpc_nonlin, r) |
144 | | - @test u ≈ [1] atol=1e-3 |
| 150 | + @test u ≈ [1] atol=1e-2 |
145 | 151 | u = nmpc_nonlin(r) |
146 | | - @test u ≈ [1] atol=1e-3 |
| 152 | + @test u ≈ [1] atol=1e-2 |
| 153 | + info, _ = getinfo(nmpc_nonlin) |
| 154 | + @test info[:u] ≈ u |
| 155 | + @test info[:Ŷ][end] ≈ 5 atol=1e-2 |
147 | 156 | end |
148 | 157 |
|
149 | 158 | @testset "NonLinMPC other methods" begin |
|
0 commit comments