Skip to content

Commit 5396fbc

Browse files
authored
Merge pull request #333 from JuliaControl/debug_hold
debug: do not allow `h>1` in `OrthogonalCollocation`
2 parents c06273f + 3b4f97b commit 5396fbc

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ModelPredictiveControl"
22
uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c"
3-
version = "2.1.0"
3+
version = "2.1.1"
44
authors = ["Francis Gagnon"]
55

66
[deps]

src/controller/transcription.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ end
129129
Construct an orthogonal collocation on finite elements [`TranscriptionMethod`](@ref).
130130
131131
Also known as pseudo-spectral method. It supports continuous-time [`NonLinModel`](@ref)s
132-
only. The `h` argument is the hold order for ``\mathbf{u}``, and the `no` argument, the
133-
number of collocation points ``n_o``. The decision variable is similar to [`MultipleShooting`](@ref),
134-
but it also includes the collocation points:
132+
only. The `h` argument is the hold order for ``\mathbf{u}`` (`0` or `1`), and the `no`
133+
argument, the number of collocation points ``n_o``. The decision variable is similar to
134+
[`MultipleShooting`](@ref), but it also includes the collocation points:
135135
```math
136136
\mathbf{Z} = \begin{bmatrix} \mathbf{ΔU} \\ \mathbf{X̂_0} \\ \mathbf{K} \end{bmatrix}
137137
```
@@ -186,6 +186,9 @@ struct OrthogonalCollocation <: CollocationMethod
186186
function OrthogonalCollocation(
187187
h::Int=0, no::Int=3; f_threads=false, h_threads=false, roots=:gaussradau
188188
)
189+
if !(h == 0 || h == 1)
190+
throw(ArgumentError("h argument must be 0 or 1 for OrthogonalCollocation."))
191+
end
189192
if roots==:gaussradau
190193
x, _ = FastGaussQuadrature.gaussradau(no, COLLOCATION_NODE_TYPE)
191194
# we reverse the nodes to include the τ=1.0 node:

test/3_test_predictive_control.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,10 +877,11 @@ end
877877
@test isa(nmpc15.optim, JuMP.GenericModel{Float64}) # Ipopt does not support Float32
878878

879879
@test_throws ArgumentError NonLinMPC(nonlinmodel)
880-
@test_throws ArgumentError NonLinMPC(nonlinmodel, Hp=2, transcription=TrapezoidalCollocation())
881-
@test_throws ArgumentError NonLinMPC(nonlinmodel, Hp=2, transcription=TrapezoidalCollocation(2))
882880
@test_throws ArgumentError NonLinMPC(nonlinmodel, Hp=2, Wy=[1 0;0 1])
881+
@test_throws ArgumentError NonLinMPC(nonlinmodel, Hp=2, transcription=TrapezoidalCollocation())
882+
@test_throws ArgumentError TrapezoidalCollocation(2)
883883
@test_throws ArgumentError OrthogonalCollocation(roots=:gausslobatto)
884+
@test_throws ArgumentError OrthogonalCollocation(2)
884885
end
885886

886887
@testitem "NonLinMPC moves and getinfo (LinModel)" setup=[SetupMPCtests] begin

0 commit comments

Comments
 (0)