Skip to content

Commit 1ddf323

Browse files
committed
test: NonLinMPC construction with TrapezoidalCollocation
1 parent 9bd412a commit 1ddf323

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/3_test_predictive_control.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,12 @@ end
699699
@test length(nmpc16.Z̃) == nonlinmodel.nu*nmpc16.Hc + nmpc16.estim.nx̂*nmpc16.Hp + nmpc16.
700700
@test nmpc16.con.neq == nmpc16.estim.nx̂*nmpc16.Hp
701701
@test nmpc16.con.nc == 10
702+
nonlinmodel_c = NonLinModel((ẋ,x,u,_,_)->ẋ .= -0.1x .+ u, (y,x,_,_)->y.=x, 1, 1, 1, 1)
703+
nmpc16 = NonLinMPC(nonlinmodel_c, Hp=10, transcription=TrapezoidalCollocation(), nc=10, gc=gc!)
704+
@test nmpc16.transcription == TrapezoidalCollocation()
705+
@test length(nmpc16.Z̃) == nonlinmodel_c.nu*nmpc16.Hc + nmpc16.estim.nx̂*nmpc16.Hp + nmpc16.
706+
@test nmpc16.con.neq == nmpc16.estim.nx̂*nmpc16.Hp
707+
@test nmpc16.con.nc == 10
702708
nmpc17 = NonLinMPC(linmodel1, Hp=10, transcription=MultipleShooting())
703709
@test nmpc17.transcription == MultipleShooting()
704710
@test length(nmpc17.Z̃) == linmodel1.nu*nmpc17.Hc + nmpc17.estim.nx̂*nmpc17.Hp + nmpc17.
@@ -721,6 +727,7 @@ end
721727
@test_throws ErrorException NonLinMPC(nonlinmodel, Hp=15, JE = (_,_,_)->0.0)
722728
@test_throws ErrorException NonLinMPC(nonlinmodel, Hp=15, gc = (_,_,_,_)->[0.0], nc=1)
723729
@test_throws ErrorException NonLinMPC(nonlinmodel, Hp=15, gc! = (_,_,_,_)->[0.0], nc=1)
730+
@test_throws ArgumentError NonLinMPC(nonlinmodel, transcription=TrapezoidalCollocation())
724731

725732
@test_logs (:warn, Regex(".*")) NonLinMPC(nonlinmodel, Hp=15, JE=(Ue,_,_,_)->Ue)
726733
@test_logs (:warn, Regex(".*")) NonLinMPC(nonlinmodel, Hp=15, gc=(Ue,_,_,_,_)->Ue, nc=0)

0 commit comments

Comments
 (0)