Skip to content

Commit eea27a0

Browse files
committed
test: multithreading with MultipleShooting and TrapezoidalCollocation
1 parent df283a5 commit eea27a0

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

test/3_test_predictive_control.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,11 +814,13 @@ end
814814
f! = (ẋ,x,u,_,_) -> ẋ .= -0.001x .+ u
815815
h! = (y,x,_,_) -> y .= x
816816
nonlinmodel_c = NonLinModel(f!, h!, 500, 1, 1, 1)
817-
nmpc5 = NonLinMPC(nonlinmodel_c, Nwt=[0], Hp=100, Hc=1, transcription=TrapezoidalCollocation())
817+
transcription = TrapezoidalCollocation(0, f_threads=true, h_threads=true)
818+
nmpc5 = NonLinMPC(nonlinmodel_c; Nwt=[0], Hp=100, Hc=1, transcription)
818819
preparestate!(nmpc5, [0.0])
819820
u = moveinput!(nmpc5, [1/0.001])
820821
@test u [1.0] atol=5e-2
821-
nmpc5_1 = NonLinMPC(nonlinmodel_c, Nwt=[0], Hp=100, Hc=1, transcription=TrapezoidalCollocation(1))
822+
transcription = TrapezoidalCollocation(1)
823+
nmpc5_1 = NonLinMPC(nonlinmodel_c; Nwt=[0], Hp=100, Hc=1, transcription)
822824
preparestate!(nmpc5_1, [0.0])
823825
u = moveinput!(nmpc5_1, [1/0.001])
824826
@test u [1.0] atol=5e-2
@@ -831,13 +833,22 @@ end
831833
ModelPredictiveControl.h!(y, nonlinmodel2, Float32[0,0], Float32[0], nonlinmodel2.p)
832834
preparestate!(nmpc7, [0], [0])
833835
@test moveinput!(nmpc7, [0], [0]) [0.0] atol=5e-2
834-
nmpc8 = NonLinMPC(nonlinmodel, Nwt=[0], Hp=100, Hc=1, transcription=MultipleShooting())
836+
transcription = MultipleShooting()
837+
nmpc8 = NonLinMPC(nonlinmodel; Nwt=[0], Hp=100, Hc=1, transcription)
835838
preparestate!(nmpc8, [0], [0])
836839
u = moveinput!(nmpc8, [10], [0])
837840
@test u [2] atol=5e-2
838841
info = getinfo(nmpc8)
839842
@test info[:u] u
840843
@test info[:Ŷ][end] 10 atol=5e-2
844+
transcription = MultipleShooting(f_threads=true, h_treads=true)
845+
nmpc8t = NonLinMPC(nonlinmodel; Nwt=[0], Hp=100, Hc=1, transcription)
846+
preparestate!(nmpc8t, [0], [0])
847+
u = moveinput!(nmpc8t, [10], [0])
848+
@test u [2] atol=5e-2
849+
info = getinfo(nmpc8t)
850+
@test info[:u] u
851+
@test info[:Ŷ][end] 10 atol=5e-2
841852
nmpc9 = NonLinMPC(linmodel, Nwt=[0], Hp=100, Hc=1, transcription=MultipleShooting())
842853
preparestate!(nmpc9, [10])
843854
u = moveinput!(nmpc9, [20])

0 commit comments

Comments
 (0)