Skip to content

Commit

Permalink
changed: default P0 not function of Q value
Browse files Browse the repository at this point in the history
  • Loading branch information
franckgaga committed Dec 9, 2023
1 parent 6277637 commit 3bfd43c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ModelPredictiveControl"
uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c"
authors = ["Francis Gagnon"]
version = "0.14.0"
version = "0.14.1"

[deps]
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"
Expand Down
30 changes: 15 additions & 15 deletions src/estimator/kalman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ its initial value with ``\mathbf{P̂}_{-1}(0) =
# Arguments
- `model::LinModel` : (deterministic) model for the estimations.
- `σP0=fill(1/model.nx,model.nx)` : main diagonal of the initial estimate covariance
``\mathbf{P}(0)``, specified as a standard deviation vector.
- `σP0int_u=fill(1,sum(nint_u))` : same than `σP0` but for the unmeasured disturbances at
manipulated inputs ``\mathbf{P_{int_u}}(0)`` (composed of integrators).
- `σP0int_ym=fill(1,sum(nint_ym))` : same than `σP0` but for the unmeasured disturbances at
measured outputs ``\mathbf{P_{int_{ym}}}(0)`` (composed of integrators).
- `<keyword arguments>` of [`SteadyKalmanFilter`](@ref) constructor.
- `σP0=σQ` : main diagonal of the initial estimate covariance ``\mathbf{P}(0)``, specified
as a standard deviation vector.
- `σP0int_u=σQint_u` : same than `σP0` but for the unmeasured disturbances at manipulated
inputs ``\mathbf{P_{int_u}}(0)`` (composed of integrators).
- `σP0int_ym=σQint_ym` : same than `σP0` but for the unmeasured disturbances at measured
outputs ``\mathbf{P_{int_{ym}}}(0)`` (composed of integrators).
# Examples
```jldoctest
Expand All @@ -277,15 +277,15 @@ KalmanFilter estimator with a sample time Ts = 0.5 s, LinModel and:
function KalmanFilter(
model::SM;
i_ym::IntRangeOrVector = 1:model.ny,
σP0::Vector = fill(1/model.nx, model.nx),
σQ ::Vector = fill(1/model.nx, model.nx),
σR ::Vector = fill(1, length(i_ym)),
σP0::Vector = σQ,
nint_u ::IntVectorOrInt = 0,
σQint_u ::Vector = fill(1, max(sum(nint_u), 0)),
σP0int_u ::Vector = σQint_u,
σP0int_u ::Vector = fill(1, max(sum(nint_u), 0)),
nint_ym ::IntVectorOrInt = default_nint(model, i_ym, nint_u),
σQint_ym ::Vector = fill(1, max(sum(nint_ym), 0)),
σP0int_ym::Vector = σQint_ym,
σP0int_ym::Vector = fill(1, max(sum(nint_ym), 0)),
) where {NT<:Real, SM<:LinModel{NT}}
# estimated covariances matrices (variance = σ²) :
P̂0 = Hermitian(diagm(NT[σP0; σP0int_u; σP0int_ym].^2), :L)
Expand Down Expand Up @@ -443,15 +443,15 @@ responsibility to ensure that the augmented model is still observable.
function UnscentedKalmanFilter(
model::SM;
i_ym::IntRangeOrVector = 1:model.ny,
σP0::Vector = fill(1/model.nx, model.nx),
σQ ::Vector = fill(1/model.nx, model.nx),
σR ::Vector = fill(1, length(i_ym)),
σP0::Vector = σQ,
nint_u ::IntVectorOrInt = 0,
σQint_u ::Vector = fill(1, max(sum(nint_u), 0)),
σP0int_u ::Vector = σQint_u,
σP0int_u ::Vector = fill(1, max(sum(nint_u), 0)),
nint_ym ::IntVectorOrInt = default_nint(model, i_ym, nint_u),
σQint_ym ::Vector = fill(1, max(sum(nint_ym), 0)),
σP0int_ym::Vector = σQint_ym,
σP0int_ym::Vector = fill(1, max(sum(nint_ym), 0)),
α::Real = 1e-3,
β::Real = 2,
κ::Real = 0
Expand Down Expand Up @@ -669,15 +669,15 @@ ExtendedKalmanFilter estimator with a sample time Ts = 5.0 s, NonLinModel and:
function ExtendedKalmanFilter(
model::SM;
i_ym::IntRangeOrVector = 1:model.ny,
σP0::Vector = fill(1/model.nx, model.nx),
σQ ::Vector = fill(1/model.nx, model.nx),
σR ::Vector = fill(1, length(i_ym)),
σP0::Vector = σQ,
nint_u ::IntVectorOrInt = 0,
σQint_u ::Vector = fill(1, max(sum(nint_u), 0)),
σP0int_u ::Vector = σQint_u,
σP0int_u ::Vector = fill(1, max(sum(nint_u), 0)),
nint_ym ::IntVectorOrInt = default_nint(model, i_ym, nint_u),
σQint_ym ::Vector = fill(1, max(sum(nint_ym), 0)),
σP0int_ym::Vector = σQint_ym,
σP0int_ym::Vector = fill(1, max(sum(nint_ym), 0)),
) where {NT<:Real, SM<:SimModel{NT}}
# estimated covariances matrices (variance = σ²) :
P̂0 = Hermitian(diagm(NT[σP0; σP0int_u; σP0int_ym].^2), :L)
Expand Down
6 changes: 3 additions & 3 deletions src/estimator/mhe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ function MovingHorizonEstimator(
model::SM;
He::Union{Int, Nothing}=nothing,
i_ym::IntRangeOrVector = 1:model.ny,
σP0::Vector = fill(1/model.nx, model.nx),
σQ ::Vector = fill(1/model.nx, model.nx),
σR ::Vector = fill(1, length(i_ym)),
σP0::Vector = σQ,
nint_u ::IntVectorOrInt = 0,
σQint_u ::Vector = fill(1, max(sum(nint_u), 0)),
σP0int_u ::Vector = σQint_u,
σP0int_u ::Vector = fill(1, max(sum(nint_u), 0)),
nint_ym ::IntVectorOrInt = default_nint(model, i_ym, nint_u),
σQint_ym ::Vector = fill(1, max(sum(nint_ym), 0)),
σP0int_ym::Vector = σQint_ym,
σP0int_ym::Vector = fill(1, max(sum(nint_ym), 0)),
optim::JM = JuMP.Model(DEFAULT_MHE_OPTIMIZER, add_bridges=false),
) where {NT<:Real, SM<:SimModel{NT}, JM<:JuMP.GenericModel}
# estimated covariances matrices (variance = σ²) :
Expand Down

2 comments on commit 3bfd43c

@franckgaga
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

  • changed: default P0 value not function of Q argument

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/96808

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.14.1 -m "<description of version>" 3bfd43cbd2babbb1a26190d6e7203c85e5d60666
git push origin v0.14.1

Please sign in to comment.