Skip to content

Commit 91d7742

Browse files
committed
debug unit tests
1 parent 11bd888 commit 91d7742

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

test/test_predictive_control.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,7 @@ end
415415
@test isa(nmpc15.optim, JuMP.GenericModel{Float64}) # Ipopt does not support Float32
416416

417417
@test_throws ArgumentError NonLinMPC(nonlinmodel, Hp=15, Ewt=[1, 1])
418-
# TODO: to uncomment when deprecated constructor is removed:
419-
# @test_throws ArgumentError NonLinMPC(nonlinmodel, Hp=nothing)
418+
@test_throws ArgumentError NonLinMPC(nonlinmodel)
420419
end
421420

422421
@testset "NonLinMPC moves and getinfo" begin

test/test_state_estim.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,9 @@ end
610610
@test mhe9. I(6)
611611
@test mhe9. I(2)
612612

613-
mhe10 = MovingHorizonEstimator(nonlinmodel, He=5, optim=Model(OSQP.Optimizer))
614-
@test solver_name(mhe10.optim) == "OSQP"
613+
optim = JuMP.Model(optimizer_with_attributes(Ipopt.Optimizer, "nlp_scaling_max_gradient"=>1.0))
614+
mhe10 = MovingHorizonEstimator(nonlinmodel, He=5, optim=optim)
615+
@test solver_name(mhe10.optim) == "Ipopt"
615616

616617
mhe11 = MovingHorizonEstimator(nonlinmodel, He=5, Cwt=1e3)
617618
@test size(mhe11.Ẽ, 2) == 6*mhe11.nx̂ + 1
@@ -673,12 +674,14 @@ end
673674
= updatestate!(mhe3, [0], [0])
674675
@test [0, 0] atol=1e-3
675676
@test isa(x̂, Vector{Float32})
677+
678+
mhe4 = setconstraint!(MovingHorizonEstimator(nonlinmodel, He=1, nint_ym=0), v̂max=[50,50])
676679

677-
mhe4 = setconstraint!(MovingHorizonEstimator(nonlinmodel, He=1, nint_ym=0), x̂max=[50,50,50,50])
678-
g_X̂max_end = mhe4.optim.nlp_model.operators.registered_multivariate_operators[end].f
679-
@test g_X̂max_end((1.0, 1.0, 1.0, 1.0)) 0.0 # test gfunc_i(i,::NTuple{N, Float64})
680+
g_V̂max_end = mhe4.optim[:g_V̂max_2].func
681+
# test gfunc_i(i,::NTuple{N, Float64})
682+
@test g_V̂max_end(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) 0.0
680683
# test gfunc_i(i,::NTuple{N, ForwardDiff.Dual}) :
681-
@test ForwardDiff.gradient(g_X̂max_end, [1.0, 1.0, 1.0, 1.0]) [0.0, 0.0, 0.0, 0.0]
684+
@test ForwardDiff.gradient(vec->g_V̂max_end(vec...), zeros(8)) zeros(8)
682685
end
683686

684687
@testset "MovingHorizonEstimator set constraints" begin

0 commit comments

Comments
 (0)