Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed: @error instead of @warn in MHE arrival covariance fallback + update CI #154

Merged
merged 6 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,32 @@ jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
permissions: # needed for julia-actions/cache delete old caches that it has created
actions: write
contents: read
continue-on-error: ${{ matrix.version == 'nightly' }}
strategy:
fail-fast: false
matrix:
version:
- '1'
- '1.10'
- 'nightly'
- 'lts' # long-term support release
- '1' # latest stable 1.x release
- 'pre' # latest stable prerelease
# - 'nightly' # commented since noisy + 'pre' allows testing upcoming versions
os:
- ubuntu-latest
arch:
- x64
steps:
- name: Set JULIA_DEBUG environment variable
- name: Set JULIA_DEBUG environment variable if applicable
if: ${{ runner.debug == '1' }}
run: echo "JULIA_DEBUG=ModelPredictiveControl" >> $GITHUB_ENV
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
Expand Down
8 changes: 4 additions & 4 deletions src/estimator/mhe/execute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ following fields:
- `:Ŵ` or *`:What`* : optimal estimated process noise over ``N_k``, ``\mathbf{Ŵ}``
- `:ϵ` or *`:epsilon`* : optimal slack variable, ``ϵ``
- `:X̂` or *`:Xhat`* : optimal estimated states over ``N_k+1``, ``\mathbf{X̂}``
- `:x̂` or *`:xhat`* : optimal estimated state for the next time step, ``\mathbf{x̂}_k(k+1)``
- `:x̂` or *`:xhat`* : optimal estimated state, ``\mathbf{x̂}_k(k+p)``
- `:V̂` or *`:Vhat`* : optimal estimated sensor noise over ``N_k``, ``\mathbf{V̂}``
- `:P̄` or *`:Pbar`* : estimation error covariance at arrival, ``\mathbf{P̄}``
- `:x̄` or *`:xbar`* : optimal estimation error at arrival, ``\mathbf{x̄}``
Expand Down Expand Up @@ -445,7 +445,7 @@ function correct_cov!(estim::MovingHorizonEstimator)
invert_cov!(estim, estim.P̂arr_old)
catch err
if err isa PosDefException
@warn("Arrival covariance is not positive definite: keeping the old one")
@error("Arrival covariance is not positive definite: keeping the old one")
else
rethrow()
end
Expand All @@ -465,7 +465,7 @@ function update_cov!(estim::MovingHorizonEstimator)
invert_cov!(estim, estim.P̂arr_old)
catch err
if err isa PosDefException
@warn("Arrival covariance is not positive definite: keeping the old one")
@error("Arrival covariance is not positive definite: keeping the old one")
else
rethrow()
end
Expand All @@ -479,7 +479,7 @@ function invert_cov!(estim::MovingHorizonEstimator, P̄)
estim.invP̄ .= inv_cholesky!(estim.buffer.P̂, P̄)
catch err
if err isa PosDefException
@warn("Arrival covariance is not invertible: keeping the old one")
@error("Arrival covariance is not invertible: keeping the old one")
else
rethrow()
end
Expand Down
6 changes: 3 additions & 3 deletions test/test_state_estim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -988,19 +988,19 @@ end
P̂arr_old_copy = deepcopy(mhe.P̂arr_old)
invP̄_copy = deepcopy(mhe.invP̄)
@test_logs(
(:warn, "Arrival covariance is not positive definite: keeping the old one"),
(:error, "Arrival covariance is not positive definite: keeping the old one"),
preparestate!(mhe, [50, 30], [5])
)
@test mhe.P̂arr_old ≈ P̂arr_old_copy
@test mhe.invP̄ ≈ invP̄_copy
@test_logs(
(:warn, "Arrival covariance is not positive definite: keeping the old one"),
(:error, "Arrival covariance is not positive definite: keeping the old one"),
updatestate!(mhe, [10, 50], [50, 30], [5])
)
@test mhe.P̂arr_old ≈ P̂arr_old_copy
@test mhe.invP̄ ≈ invP̄_copy
@test_logs(
(:warn, "Arrival covariance is not invertible: keeping the old one"),
(:error, "Arrival covariance is not invertible: keeping the old one"),
ModelPredictiveControl.invert_cov!(mhe, Hermitian(zeros(mhe.nx̂, mhe.nx̂),:L))
)
end
Expand Down
Loading