Skip to content

Commit 1a1a474

Browse files
committed
test: new test NMPC and MHE tests with FiniteDiff
1 parent 6095a15 commit 1a1a474

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

Project.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ julia = "1.10"
4141
[extras]
4242
DAQP = "c47d62df-3981-49c8-9651-128b1cd08617"
4343
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
44+
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
4445
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
4546
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4647
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
4748
TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe"
4849

4950
[targets]
50-
test = ["Test", "TestItems", "TestItemRunner", "Documenter", "Plots", "DAQP"]
51+
test = ["Test", "TestItems", "TestItemRunner", "Documenter", "Plots", "DAQP", "FiniteDiff"]

docs/src/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The objective is to provide a simple, clear and modular framework to quickly des
1212
predictive controllers (MPCs) in Julia, while preserving the flexibility for advanced
1313
real-time optimization. Modern MPCs based on closed-loop state estimators are the main focus
1414
of the package, but classical approaches that rely on internal models are also possible. The
15-
`JuMP` amd `DifferentiationInterface` dependencies allows the user to test different
15+
`JuMP` and `DifferentiationInterface` dependencies allows the user to test different
1616
optimizers and automatic differentiation (AD) backends easily if the performances of the
1717
default settings are not satisfactory.
1818

test/3_test_predictive_control.jl

+10-2
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,9 @@ end
555555
end
556556

557557
@testitem "NonLinMPC construction" setup=[SetupMPCtests] begin
558-
using .SetupMPCtests, ControlSystemsBase, LinearAlgebra, JuMP, Ipopt
558+
using .SetupMPCtests, ControlSystemsBase, LinearAlgebra
559+
using JuMP, Ipopt, DifferentiationInterface
560+
import FiniteDiff
559561
linmodel1 = LinModel(sys,Ts,i_d=[3])
560562
nmpc0 = NonLinMPC(linmodel1, Hp=15)
561563
@test isa(nmpc0.estim, SteadyKalmanFilter)
@@ -612,6 +614,10 @@ end
612614
@test nmpc17.transcription == MultipleShooting()
613615
@test length(nmpc17.Z̃) == linmodel1.nu*nmpc17.Hc + nmpc17.estim.nx̂*nmpc17.Hp + nmpc17.
614616
@test size(nmpc17.con.Aeq, 1) == nmpc17.estim.nx̂*nmpc17.Hp
617+
@test_nowarn nmpc18 = NonLinMPC(nonlinmodel, Hp=10,
618+
gradient=AutoFiniteDiff(),
619+
jacobian=AutoFiniteDiff()
620+
)
615621

616622
nonlinmodel2 = NonLinModel{Float32}(f, h, Ts, 2, 4, 2, 1, solver=nothing)
617623
nmpc15 = NonLinMPC(nonlinmodel2, Hp=15)
@@ -629,7 +635,9 @@ end
629635
end
630636

631637
@testitem "NonLinMPC moves and getinfo" setup=[SetupMPCtests] begin
632-
using .SetupMPCtests, ControlSystemsBase, LinearAlgebra, ForwardDiff
638+
using .SetupMPCtests, ControlSystemsBase, LinearAlgebra
639+
using DifferentiationInterface
640+
import FiniteDiff
633641
linmodel = setop!(LinModel(tf(5, [2000, 1]), 3000.0), yop=[10])
634642
Hp = 100
635643
nmpc_lin = NonLinMPC(linmodel, Nwt=[0], Hp=Hp, Hc=1)

0 commit comments

Comments
 (0)