Skip to content

Commit 71c9246

Browse files
committed
test: new simple tests with hessian=true
1 parent 37d4e31 commit 71c9246

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/3_test_predictive_control.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,10 +724,12 @@ end
724724
@test size(nmpc17.con.Aeq, 1) == nmpc17.estim.nx̂*nmpc17.Hp
725725
nmpc18 = NonLinMPC(nonlinmodel, Hp=10,
726726
gradient=AutoFiniteDiff(),
727-
jacobian=AutoFiniteDiff()
727+
jacobian=AutoFiniteDiff(),
728+
hessian=AutoFiniteDiff()
728729
)
729730
@test nmpc18.gradient == AutoFiniteDiff()
730731
@test nmpc18.jacobian == AutoFiniteDiff()
732+
@test nmpc18.hessian == AutoFiniteDiff()
731733

732734
nonlinmodel2 = NonLinModel{Float32}(f, h, Ts, 2, 4, 2, 1, solver=nothing)
733735
nmpc15 = NonLinMPC(nonlinmodel2, Hp=15)
@@ -742,6 +744,7 @@ end
742744
@test_throws ErrorException NonLinMPC(nonlinmodel, Hp=15, gc! = (_,_,_,_)->[0.0], nc=1)
743745
@test_throws ArgumentError NonLinMPC(nonlinmodel, transcription=TrapezoidalCollocation())
744746
@test_throws ArgumentError NonLinMPC(nonlinmodel, transcription=TrapezoidalCollocation(2))
747+
@test_throws ErrorException NonLinMPC(linmodel1, oracle=false, hessian=AutoFiniteDiff())
745748

746749
@test_logs (:warn, Regex(".*")) NonLinMPC(nonlinmodel, Hp=15, JE=(Ue,_,_,_)->Ue)
747750
@test_logs (:warn, Regex(".*")) NonLinMPC(nonlinmodel, Hp=15, gc=(Ue,_,_,_,_)->Ue, nc=0)
@@ -856,7 +859,8 @@ end
856859
nmpc10 = setconstraint!(NonLinMPC(
857860
nonlinmodel, Nwt=[0], Hp=100, Hc=1,
858861
gradient=AutoFiniteDiff(),
859-
jacobian=AutoFiniteDiff()),
862+
jacobian=AutoFiniteDiff(),
863+
hessian=true),
860864
ymax=[100], ymin=[-100]
861865
)
862866
preparestate!(nmpc10, [0], [0])

0 commit comments

Comments
 (0)