diff --git a/.github/workflows/juliaci.yml b/.github/workflows/juliaci.yml index 3c882dd5f..0cf3f944e 100644 --- a/.github/workflows/juliaci.yml +++ b/.github/workflows/juliaci.yml @@ -15,10 +15,10 @@ jobs: julia-ci: uses: franckgaga/testitem-workflow/.github/workflows/juliaci.yml@patch-1 with: - memory-threshold: 0.9 # try to avoid OOM error on ubuntu and Julia 1.10 include-windows-x86: false # not worth it, windows 32bit is too uncommon include-macos-x64: false # most mac are aarch64 nowadays include-macos-aarch64: false # would like to include it, but too unreliable for now + include-linux-x86: false # would like to include it, but too unreliable for now permissions: write-all secrets: codecov_token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/src/precompile.jl b/src/precompile.jl index 0479fca89..04d0b25ac 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -98,9 +98,9 @@ R̂y = repeat([55; 30], 3) daemodel = NonLinModelDAE(fq_dae!, h_dae!, 100.0, 1, 1, 1, 1; transcription) sim!(daemodel, 2, [10]) - mhe_dae = MovingHorizonEstimator(daemodel, He=2, direct=false) + mhe_dae = MovingHorizonEstimator(daemodel, He=2, direct=false, hessian=true) setconstraint!(mhe_dae, x̂min=[-50, 50], x̂max=[50, 50]) - nmpc_dae = NonLinMPC(mhe_dae, Hp=3) + nmpc_dae = NonLinMPC(mhe_dae, Hp=3, hessian=true) setconstraint!(nmpc_dae, ymin=[-50], ymax=[50]) preparestate!(nmpc_dae, [5]) moveinput!(nmpc_dae, [0.1]) diff --git a/test/2_test_state_estim.jl b/test/2_test_state_estim.jl index c24efde7c..4831e19b7 100644 --- a/test/2_test_state_estim.jl +++ b/test/2_test_state_estim.jl @@ -1241,9 +1241,9 @@ end end @testitem "MHE estim. & getinfo (NonLinModel, SS)" setup=[SetupMPCtests] begin - using .SetupMPCtests, ControlSystemsBase, LinearAlgebra, ForwardDiff + using .SetupMPCtests, ControlSystemsBase, LinearAlgebra using JuMP, Ipopt, DifferentiationInterface, SparseMatrixColorings, SparseConnectivityTracer - import ForwardDiff + import FiniteDiff linmodel = LinModel(sys,Ts,i_u=[1,2], i_d=[3]) linmodel = setop!(linmodel, uop=[10,50], yop=[50,30], dop=[5]) @@ -1341,7 +1341,10 @@ end @test evaloutput(mhe5, [5]) ≈ mhe5([5]) ≈ [50, 30] info = getinfo(mhe5) @test info[:x̂] ≈ x̂ atol=1e-9 - @test info[:Ŷ][end-1:end] ≈ [50, 30] atol=1e-9 + @test info[:Ŷ][end-1:end] ≈ [50, 30] atol=1e-9 + + @test_nowarn ModelPredictiveControl.info2debugstr(info) + @test_throws ErrorException setstate!(mhe1, [1,2,3,4,5,6], diagm(.1:.1:.6)) # coverage of the branch with error termination status (with an infeasible problem): mhe_infeas = MovingHorizonEstimator(nonlinmodel, He=1, Cwt=Inf) @@ -1352,21 +1355,20 @@ end preparestate!(mhe_infeas, [0, 0], [0]) ) - @test_nowarn ModelPredictiveControl.info2debugstr(info) - @test_throws ErrorException setstate!(mhe1, [1,2,3,4,5,6], diagm(.1:.1:.6)) - - hessian = AutoSparse( - AutoForwardDiff(); - sparsity_detector=TracerSparsityDetector(), - coloring_algorithm=GreedyColoringAlgorithm(), - ) + gradient, jacobian, hessian = AutoFiniteDiff(), AutoFiniteDiff(), AutoFiniteDiff() - mhe8 = MovingHorizonEstimator(nonlinmodel; He=2, hessian) + mhe8 = MovingHorizonEstimator(nonlinmodel; He=2, gradient, jacobian, hessian) + @test mhe8.gradient isa AutoFiniteDiff + @test mhe8.jacobian isa AutoFiniteDiff + @test mhe8.hessian isa AutoFiniteDiff + x̂ = preparestate!(mhe8, [50, 30], [5]) + @test x̂ ≈ zeros(6) atol=1e-6 + updatestate!(mhe8, [10, 50], [50, 30], [5]) @test_logs( (:warn, "NaN values in the MHE measurements ym: ignoring them in the objective"), preparestate!(mhe8, [50, NaN], [5]) ) - @test mhe8.x̂0 ≈ zeros(6) atol=1e-9 + @test mhe8.x̂0 ≈ zeros(6) atol=1e-6 function f!(ẋ, x, u, d, p) ẋ[] = -p[] * (x[] - 0.2 * u[] - 0.2 * d[]) @@ -1388,6 +1390,7 @@ end @test mhe_foh([0.0]) ≈ [1.5] info = getinfo(mhe_foh) @test info[:x̂] ≈ x̂ + end @testitem "MHE estim. & getinfo (NonLinModel, MS)" setup=[SetupMPCtests] begin