Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
3ba3d34
added: introducing abstract `ODEmodel` and `DAEmodel` types
franckgaga Aug 13, 2026
dd74cd7
debug: avoid method ambiguity
franckgaga Aug 18, 2026
9571f8d
added: `NonLinDAEmodel`
franckgaga Aug 19, 2026
3d270d1
changed: renamed to `NonLinModelDAE`
franckgaga Aug 19, 2026
470fb78
change: similar rename
franckgaga Aug 19, 2026
8c9be77
Merge branch 'main' into dae_model
franckgaga Aug 29, 2026
72bf3e8
Merge branch 'main' into dae_model
franckgaga Aug 29, 2026
776357f
changed: single `f_q` or `f_q!` function for `NonLinModelDAE`
franckgaga Aug 29, 2026
b055d10
doc: documenting `NonLinModelDAE`
franckgaga Aug 29, 2026
cc031aa
wip: init optimization of `NonLinModelDAE`
franckgaga Aug 29, 2026
3c11fd5
removed: redundant definitions
franckgaga Aug 29, 2026
308ae73
Merge branch 'main' into dae_model
franckgaga Aug 29, 2026
8def0eb
doc: wip for `NonLinModelDAE`
franckgaga Aug 31, 2026
6e65f35
doc: details
franckgaga Aug 31, 2026
1980f20
changed: renamed `z` -> `a` (algebraic variables)
franckgaga Aug 31, 2026
d736aa4
doc: minor details
franckgaga Aug 31, 2026
52fdd91
removed: underscore in `f_q`
franckgaga Sep 1, 2026
eee25d6
Merge branch 'precompile_time' into dae_model
franckgaga Sep 2, 2026
07eff4a
doc: "Abstract supertype" -> "Supertype"
franckgaga Sep 2, 2026
a7756e5
idem
franckgaga Sep 2, 2026
e71bc33
changed: `init_orthocolloc` w/o `SimModel` object argument
franckgaga Sep 3, 2026
8173053
debug: correct padding for `MovingHorzionEstimator` pretty-print
franckgaga Sep 3, 2026
4b6b39a
changed: restructured main `transcription.jl` file
franckgaga Sep 3, 2026
d333034
Merge branch 'oc_notation_k' into dae_model
franckgaga Sep 3, 2026
953bc92
Merging same
franckgaga Sep 3, 2026
f5162b3
changed: support DAE in `get_nk̄`
franckgaga Sep 3, 2026
91a3cba
doc: DAEs with `TrapezoidalCollocation` decision vector
franckgaga Sep 3, 2026
1db3027
Merge, continued...
franckgaga Sep 3, 2026
6fed781
added: linear equality constraint in `NonLinModelDAE`
franckgaga Sep 4, 2026
3d313aa
changed: renamed `K` to `K̄`
franckgaga Sep 4, 2026
b68818a
debug: correct signature for `update_predictions`
franckgaga Sep 4, 2026
52a55c6
doc: documenting the decision vector on all cases
franckgaga Sep 4, 2026
b8f19ab
doc: debug doc
franckgaga Sep 4, 2026
cc6f9b9
doc: clearer sentence
franckgaga Sep 4, 2026
173f950
doc: shorter sentence
franckgaga Sep 4, 2026
f592a27
doc: update the main text of `OrthogonalCollocation`
franckgaga Sep 4, 2026
383f0cd
doc: correct error in `Z` for MHE
franckgaga Sep 5, 2026
414d654
added: `NonLinModelDAE` simulations start to work 🥳
franckgaga Sep 5, 2026
1c7f802
doc: correct `Z` for DAEs
franckgaga Sep 5, 2026
b34e2e8
changed: correct `nZ` values for `NonLinModelDAE` simulations
franckgaga Sep 5, 2026
f7ceaac
changed: correct `geq` for DAEs sim. with OC
franckgaga Sep 5, 2026
f5802c8
added: `con_nonlinprogeq!` methods for `NonLinModelDAE`
franckgaga Sep 5, 2026
9740d76
added: `TrapezoidalCollocation` now work with `NonLinModelDAE`
franckgaga Sep 6, 2026
3f8769c
removed: `a0` field in `NonLinModelDAE`
franckgaga Sep 6, 2026
53d9365
added: `optim_output` field in `NonLinModelDAE`
franckgaga Sep 6, 2026
b5c767b
wip: `q_oracle` for `evaloutput`
franckgaga Sep 7, 2026
014f7f4
changed: dense `AutoForwardDiff` by default for `NonLinModelDAE`
franckgaga Sep 8, 2026
1473b0e
doc: update `jacobian` field
franckgaga Sep 8, 2026
bf3b00d
changed: renamed `steadystate!` -> `initstate_core!`
franckgaga Sep 8, 2026
67abb1d
changed: dense backend for `hessian==true`
franckgaga Sep 8, 2026
b679fe5
added: `h!` method work for `NonLinModelDAE`
franckgaga Sep 8, 2026
fd79a06
doc: debug link
franckgaga Sep 8, 2026
be14d0c
doc: more compact OC extended help
franckgaga Sep 8, 2026
d815a12
changed: renaming `RHS` to `res`
franckgaga Sep 9, 2026
8258166
added: current alg. var. `a0` in OC decision vector `Z`
franckgaga Sep 9, 2026
66bdb10
changed: moved `a0` in `Z` vector for OC
franckgaga Sep 9, 2026
8ce9928
debug: ensure that `JNT` is identical in both `JuMP.Model`s
franckgaga Sep 9, 2026
1fafaca
added: avoid two solve functions in `NonLinModelDAE`
franckgaga Sep 10, 2026
3943f4c
removed: useless method
franckgaga Sep 10, 2026
eae1249
debug: ``evaloutput` now work on `NonLinModelDAE`
franckgaga Sep 10, 2026
8607acb
doc: minor correction
franckgaga Sep 10, 2026
1af59e9
added: validate strictly proper DAEs with `TracerSparsityDetector`
franckgaga Sep 10, 2026
c7b7ac7
changed: clearer error
franckgaga Sep 10, 2026
a107cb5
doc: clearer docstring
franckgaga Sep 10, 2026
7895efe
added: skip root solving in `evaloutput` if not needed
franckgaga Sep 10, 2026
d4b2150
bump
franckgaga Sep 10, 2026
b00e8e5
test: wip
franckgaga Sep 10, 2026
83e9727
added: precompile `NonLinModelDAE` simulation functions
franckgaga Sep 10, 2026
1a21ca5
debug: correctly initialize `SimModelBuffer` in `NonLinModelDAE`
franckgaga Sep 10, 2026
158502b
test: added `NonLinModelDAE` construction tests
franckgaga Sep 10, 2026
567ddfc
test: sim method tests for `NonLinModelDAE`
franckgaga Sep 11, 2026
fad8cf5
doc: minor detail in `h!` internals
franckgaga Sep 11, 2026
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ModelPredictiveControl"
uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c"
version = "2.12.3"
version = "2.13.0"
authors = ["Francis Gagnon"]

[deps]
Expand Down
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ links = InterLinks(
"JuMP" => "https://jump.dev/JuMP.jl/stable/objects.inv",
"MathOptInterface" => "https://jump.dev/MathOptInterface.jl/stable/objects.inv",
"DifferentiationInterface" => "https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface/stable/objects.inv",
"SparseConnectivityTracer" => "https://adrianhill.de/SparseConnectivityTracer.jl/stable/objects.inv",
"ForwardDiff" => "https://juliadiff.org/ForwardDiff.jl/stable/objects.inv",
"LowLevelParticleFilters" => "https://baggepinnen.github.io/LowLevelParticleFilters.jl/stable/objects.inv",
"LinearMPC" => "https://darnstrom.github.io/LinearMPC.jl/stable/objects.inv",
Expand Down
7 changes: 7 additions & 0 deletions docs/src/internals/misc.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
Pages = ["misc.md"]
```

## Abstract Types

```@docs
ModelPredictiveControl.ShootingMethod
ModelPredictiveControl.CollocationMethod
```

## Orthogonal Collocation

```@docs
Expand Down
17 changes: 15 additions & 2 deletions docs/src/internals/sim_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,28 @@
Pages = ["sim_model.md"]
```

## Abstract Types

```@docs
ModelPredictiveControl.SimModelODE
ModelPredictiveControl.SimModelDAE
```

## Model Construction

```@docs
ModelPredictiveControl.init_defectmat_dae
```

## State-Space Functions

```@docs
ModelPredictiveControl.f!
ModelPredictiveControl.h!
```

## Steady-State Calculation
## Init State

```@docs
ModelPredictiveControl.steadystate!
ModelPredictiveControl.initstate_core!
```
6 changes: 6 additions & 0 deletions docs/src/public/sim_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ LinModel
NonLinModel
```

## NonLinModelDAE

```@docs
NonLinModelDAE
```

## Set Variable Names

```@docs
Expand Down
6 changes: 3 additions & 3 deletions src/ModelPredictiveControl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using DifferentiationInterface: gradient!, value_and_gradient!, prepare_gradient
using DifferentiationInterface: jacobian!, value_and_jacobian!, prepare_jacobian
using DifferentiationInterface: hessian!, value_gradient_and_hessian!, prepare_hessian
using DifferentiationInterface: Constant, Cache
using SparseConnectivityTracer: TracerSparsityDetector
using SparseConnectivityTracer: TracerSparsityDetector, jacobian_sparsity, jacobian_buffer
using SparseMatrixColorings: GreedyColoringAlgorithm, sparsity_pattern
using SparseMatrixColorings: NaturalOrder, LargestFirst, SmallestLast
using SparseMatrixColorings: IncidenceDegree, DynamicLargestFirst, RandomOrder
Expand All @@ -41,7 +41,7 @@ import OSQP, Ipopt

import FastGaussQuadrature

export SimModel, LinModel, NonLinModel
export SimModel, LinModel, NonLinModel, NonLinModelDAE
export DiffSolver, RungeKutta, ForwardEuler
export setop!, setname!
export setstate!, setmodel!, preparestate!, updatestate!, evaloutput, linearize, linearize!
Expand All @@ -57,8 +57,8 @@ export TrapezoidalCollocation, OrthogonalCollocation
export SimResult, getinfo, sim!

include("general.jl")
include("sim_model.jl")
include("transcription.jl")
include("sim_model.jl")
include("state_estim.jl")
include("predictive_control.jl")
include("plot_sim.jl")
Expand Down
4 changes: 2 additions & 2 deletions src/controller/construct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ end

"Outer constructor to validate and convert weight matrices if necessary."
function ControllerWeights(
model::SimModel{NT}, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt=Inf, Ewt=0
model::SimModelODE{NT}, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt=Inf, Ewt=0
) where {NT<:Real}
validate_weights(model, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt, Ewt)
M_Hp, N_Hc, L_Hp = NT.(M_Hp), NT.(N_Hc), NT.(L_Hp)
Expand Down Expand Up @@ -568,7 +568,7 @@ Estimate the default prediction horizon `Hp` for [`LinModel`](@ref).
"""
default_Hp(model::LinModel) = DEFAULT_HP0 + estimate_delays(model)
"Throw an error when model is not a [`LinModel`](@ref)."
function default_Hp(::SimModel)
function default_Hp(::SimModelODE)
msg = "Prediction horizon Hp must be explicitly specified if model is not a LinModel."
throw(ArgumentError(msg))
end
Expand Down
20 changes: 10 additions & 10 deletions src/controller/execute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -277,25 +277,25 @@ function initpred!(mpc::PredictiveController, model::LinModel, ry, d, lastu, D̂
end

@doc raw"""
initpred!(mpc::PredictiveController, model::SimModel, ry, d, lastu, D̂, R̂y, R̂u) -> nothing
initpred!(mpc::PredictiveController, model::SimModelODE, ry, d, lastu, D̂, R̂y, R̂u) -> nothing

Init `lastu0, ŷ, F, d0, D̂0, D̂e, R̂y, R̂u` vectors when model is not a [`LinModel`](@ref).
"""
function initpred!(mpc::PredictiveController, model::SimModel, ry, d, lastu, D̂, R̂y, R̂u)
function initpred!(mpc::PredictiveController, model::SimModelODE, ry, d, lastu, D̂, R̂y, R̂u)
initpred_common!(mpc, model, ry, d, lastu, D̂, R̂y, R̂u)
return nothing
end

"""
initpred_common!(mpc::PredictiveController, model::SimModel, ry, d, lastu, D̂, R̂y, R̂u) -> F
initpred_common!(mpc::PredictiveController, model::SimModelODE, ry, d, lastu, D̂, R̂y, R̂u) -> F

Common computations of `initpred!` for all types of [`SimModel`](@ref).
Common computations of `initpred!` for all types of [`SimModelODE`](@ref).

Will also init `mpc.F` with 0 values, or with the stochastic predictions `Ŷs` if `mpc.estim`
is an [`InternalModel`](@ref). The function returns `mpc.F`.
"""
function initpred_common!(
mpc::PredictiveController, model::SimModel, ry, d, lastu, D̂, R̂y, R̂u
mpc::PredictiveController, model::SimModelODE, ry, d, lastu, D̂, R̂y, R̂u
)
mpc.lastu0 .= lastu .- model.uop
mul!(mpc.Tu_lastu0, mpc.Tu, mpc.lastu0)
Expand Down Expand Up @@ -327,14 +327,14 @@ end
predictstoch!(Ŷs, ::PredictiveController, ::StateEstimator) = (Ŷs .= 0; nothing)

@doc raw"""
linconstraint_custom!(mpc::PredictiveController, model::SimModel)
linconstraint_custom!(mpc::PredictiveController, model::SimModelODE)

Init the ``\mathbf{F_w}`` vector for the custom linear inequality constraints.

See [`relaxW`](@ref) for the definition of the vector. The function does nothing if
`mpc.con.nw < 1`.
"""
function linconstraint_custom!(mpc::PredictiveController, model::SimModel)
function linconstraint_custom!(mpc::PredictiveController, model::SimModelODE)
mpc.con.nw < 1 && return nothing
ny, nu, nd, buffer = model.ny, model.nu, model.nd, mpc.buffer
Fw = mpc.con.Fw
Expand Down Expand Up @@ -363,7 +363,7 @@ function linconstraint_custom_outputs!(mpc::PredictiveController, model::LinMode
return nothing
end
"Do nothing for other model types."
linconstraint_custom_outputs!(::PredictiveController, ::SimModel) = nothing
linconstraint_custom_outputs!(::PredictiveController, ::SimModelODE) = nothing

"""
extended_vectors!(Ue, Ŷe, mpc::PredictiveController, U0, Ŷ0) -> Ue, Ŷe
Expand Down Expand Up @@ -506,7 +506,7 @@ end


"By default, no need to update the objective function."
set_objective_linear_coef!(::PredictiveController, ::SimModel, _) = nothing
set_objective_linear_coef!(::PredictiveController, ::SimModelODE, _) = nothing

"Update the linear coefficients of the quadratic objective with `mpc.q̃` for `LinModel`."
function set_objective_linear_coef!(mpc::PredictiveController, ::LinModel, Z̃var)
Expand Down Expand Up @@ -790,7 +790,7 @@ function setmodel_controller!(mpc::PredictiveController, uop_old, x̂op_old)
end

"No need to set the objective Hessian by default (only needed for quadratic objective)."
set_objective_hessian!(::PredictiveController, ::SimModel, _ ) = nothing
set_objective_hessian!(::PredictiveController, ::SimModelODE, _ ) = nothing

"Set the objective Hessian with `mpc.H̃` if the objective is quadratic."
function set_objective_hessian!(mpc::PredictiveController, ::LinModel, Z̃var)
Expand Down
Loading
Loading