Skip to content

Commit d4a41d2

Browse files
committed
improve coverage
1 parent 7a9d360 commit d4a41d2

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelPredictiveControl"
22
uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c"
33
authors = ["Francis Gagnon"]
4-
version = "0.14.1"
4+
version = "0.15.0"
55

66
[deps]
77
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"
@@ -24,15 +24,15 @@ LinearAlgebra = "1.6"
2424
OSQP = "0.8"
2525
PreallocationTools = "0.4"
2626
PrecompileTools = "1"
27-
RecipesBase = "1"
2827
Random = "1.6"
28+
RecipesBase = "1"
2929
julia = "1.6"
3030

31-
3231
[extras]
3332
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3433
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
3534
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
35+
DAQP = "c47d62df-3981-49c8-9651-128b1cd08617"
3636

3737
[targets]
38-
test = ["Test", "Documenter", "Plots"]
38+
test = ["Test", "Documenter", "Plots", "DAQP"]

src/plot_sim.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function SimResult(
6666
NU, NY, NX, NX̂ = size(U_data, 2), size(Y_data, 2), size(X_data, 2), size(X̂_data, 2)
6767
NRy, NRu = size(Ry_data, 2), size(Ru_data, 2)
6868
if !(NU == NY == NX == NX̂ == NRy == NRu)
69-
error("All arguments must have the same number of columns (time steps)")
69+
throw(ArgumentError("All arguments must have the same number of columns (time steps)"))
7070
end
7171
size(Y_data, 2) == N || error("Y_data must be of size ($ny, $N)")
7272
return SimResult{NT, O}(obj, T_data, Y_data, Ry_data, Y_data, U_data, U_data,

test/runtests.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ using ModelPredictiveControl
44
using ControlSystemsBase
55
using Documenter
66
using LinearAlgebra
7-
using JuMP, OSQP, Ipopt, ForwardDiff
7+
using JuMP, OSQP, Ipopt, DAQP, ForwardDiff
88
using Plots
99
using Test
1010

11-
1211
@testset "ModelPredictiveControl.jl" begin
1312
include("test_sim_model.jl")
1413
include("test_state_estim.jl")

test/test_plot_sim.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ sys = [ tf(1.90,[18.0,1]) tf(1.90,[18.0,1]) tf(1.90,[18.0,1]);
55
@testset "SimModel quick simulation" begin
66
model = LinModel(sys, Ts, i_d=[3])
77
res = sim!(model, 15)
8+
display(res)
89
@test isa(res.obj, LinModel)
910
@test length(res.T_data) == 15
1011
@test res.U_data[:, 1] model.uop .+ 1
@@ -16,6 +17,8 @@ sys = [ tf(1.90,[18.0,1]) tf(1.90,[18.0,1]) tf(1.90,[18.0,1]);
1617
@test res_man.Y_data res.Y_data
1718
@test res_man.D_data res.D_data
1819
@test res_man.X_data res.X_data
20+
21+
@test_throws ArgumentError SimResult(model, [res.U_data model.uop], res.Y_data, res.D_data)
1922
end
2023

2124
@testset "SimModel Plots" begin

test/test_predictive_control.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ sys = [ tf(1.90,[18.0,1]) tf(1.90,[18.0,1]) tf(1.90,[18.0,1]);
1818
@test mpc5.Ñ_Hc Diagonal(diagm([repeat(Float64[3, 4], 5); [1e3]]))
1919
mpc6 = LinMPC(model, Lwt=[0,1], Hp=15)
2020
@test mpc6.L_Hp Diagonal(diagm(repeat(Float64[0, 1], 15)))
21-
mpc7 = LinMPC(model, optim=JuMP.Model(Ipopt.Optimizer))
22-
@test solver_name(mpc7.optim) == "Ipopt"
21+
mpc7 = LinMPC(model, optim=JuMP.Model(DAQP.Optimizer))
22+
@test solver_name(mpc7.optim) == "DAQP"
2323
kf = KalmanFilter(model)
2424
mpc8 = LinMPC(kf)
2525
@test isa(mpc8.estim, KalmanFilter)

0 commit comments

Comments
 (0)