Skip to content

Commit d1a0691

Browse files
committed
debug tests terminal constraints LinMPC
1 parent 512544c commit d1a0691

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

test/test_predictive_control.jl

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,44 +154,50 @@ end
154154
setconstraint!(mpc2, c_umin=[0], c_umax=[0], c_Δumin=[0], c_Δumax=[0], c_ymin=[1], c_ymax=[1])
155155

156156

157+
158+
159+
setconstraint!(mpc2, x̂min=[-1e3,-Inf], x̂max=[1e3,+Inf])
160+
161+
162+
163+
157164
setconstraint!(mpc2, umin=[-3], umax=[3])
158165
setconstraint!(mpc2, Δumin=[-1.5], Δumax=[1.5])
159166
setconstraint!(mpc2, ymin=[-100], ymax=[100])
160167
moveinput!(mpc2, [-10])
161168
info = getinfo(mpc2)
162-
@test info[:ΔU][begin] -1.5 atol=1e-2
163-
@test info[:U][end] -3 atol=1e-2
169+
@test info[:ΔU][begin] -1.5 atol=1e-1
170+
@test info[:U][end] -3 atol=1e-1
164171

165172

166173
setconstraint!(mpc2, umin=[-10], umax=[10])
167174
setconstraint!(mpc2, Δumin=[-15], Δumax=[15])
168175
setconstraint!(mpc2, ymin=[-0.5], ymax=[0.5])
169176
moveinput!(mpc2, [-10])
170177
info = getinfo(mpc2)
171-
@test info[:Ŷ][end] -0.5 atol=1e-2
178+
@test info[:Ŷ][end] -0.5 atol=1e-1
172179

173180

174181
setconstraint!(mpc2, umin=[-10], umax=[10])
175182
setconstraint!(mpc2, Δumin=[-15], Δumax=[15])
176183
setconstraint!(mpc2, Ymin=[-0.5; fill(-100, 49)], Ymax=[0.5; fill(+100, 49)])
177184
moveinput!(mpc2, [-10])
178185
info = getinfo(mpc2)
179-
@test info[:Ŷ][end] -10 atol=1e-2
180-
@test info[:Ŷ][begin] -0.5 atol=1e-2
186+
@test info[:Ŷ][end] -10 atol=1e-1
187+
@test info[:Ŷ][begin] -0.5 atol=1e-1
181188

182189

183190

184191

185192

186193

187-
setconstraint!(mpc2, umin=[-Inf], umax=[+Inf])
188-
setconstriant!(mpc2, Δumin=[-Inf], Δumax=[+Inf])
189-
setconstraint!(mpc2, ymin=[-Inf], ymax=[+Inf])
190-
setconstraint!(mpc2, x̂min=[-1e-6], x̂max=[+1e-6])
191-
moveinput!(mpc2, [+1000])
194+
setconstraint!(mpc2, umin=[-1e3], umax=[+1e3])
195+
setconstraint!(mpc2, Δumin=[-1e3], Δumax=[+1e3])
196+
setconstraint!(mpc2, ymin=[-1e3], ymax=[+1e3])
197+
setconstraint!(mpc2, x̂min=[-1e-6,-Inf], x̂max=[+1e-6,+Inf])
198+
moveinput!(mpc2, [-10])
192199
info = getinfo(mpc2)
193-
@test info[:x̂end] 0 atol=1e-5
194-
200+
@test info[:x̂end][1] 0 atol=1e-1
195201

196202

197203

@@ -223,7 +229,6 @@ end
223229
@test_throws ArgumentError setconstraint!(mpc3, c_ymax=[1, 1])
224230
end
225231

226-
#=
227232
@testset "ExplicitMPC construction" begin
228233
model = LinModel(sys, Ts, i_d=[3])
229234
mpc1 = ExplicitMPC(model, Hp=15)
@@ -517,4 +522,3 @@ end
517522
@test info[:Ŷ][begin] -0.5 atol=1e-2
518523

519524
end
520-
=#

0 commit comments

Comments
 (0)