Skip to content

Commit 760ecbd

Browse files
committed
Revert "changed: store defect matrices as sparse ones"
This reverts commit baca399.
1 parent baca399 commit 760ecbd

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/controller/construct.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ struct ControllerConstraint{NT<:Real, GCfunc<:Union{Nothing, Function}}
105105
vx̂ ::Matrix{NT}
106106
bx̂ ::Vector{NT}
107107
# matrices for the zero defect constraints (N/A for single shooting transcriptions):
108-
Ẽŝ ::SparseMatrixCSC{NT}
108+
Ẽŝ ::Matrix{NT}
109109
Fŝ ::Vector{NT}
110-
Gŝ ::SparseMatrixCSC{NT}
111-
Jŝ ::SparseMatrixCSC{NT}
112-
Kŝ ::SparseMatrixCSC{NT}
110+
Gŝ ::Matrix{NT}
111+
Jŝ ::Matrix{NT}
112+
Kŝ ::Matrix{NT}
113113
Vŝ ::Matrix{NT}
114114
Bŝ ::Vector{NT}
115115
# bounds over the prediction horizon (deviation vectors from operating points):

src/controller/transcription.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ function init_defectmat(
492492
nu, nx̂, nd = model.nu, estim.nx̂, model.nd
493493
Â, B̂u, B̂d = estim.Â, estim.B̂u, estim.B̂d
494494
# --- current state estimates x̂0 ---
495-
Kŝ = [Â; spzeros(NT, nx̂*(Hp-1), nx̂)]
495+
Kŝ = [Â; zeros(NT, nx̂*(Hp-1), nx̂)]
496496
# --- previous manipulated inputs lastu0 ---
497497
Vŝ = repeat(B̂u, Hp)
498498
# --- decision variables Z ---
@@ -508,10 +508,9 @@ function init_defectmat(
508508
iCol = (1:nx̂) .+ nx̂*(j-1) .+ nu*Hc
509509
Eŝ[iRow, iCol] =
510510
end
511-
Eŝ = sparse(Eŝ)
512511
# --- current measured disturbances d0 and predictions D̂0 ---
513-
Gŝ = [B̂d; spzeros(NT, (Hp-1)*nx̂, nd)]
514-
Jŝ = [spzeros(nx̂, nd*Hp); repeatdiag(B̂d, Hp-1) spzeros(NT, nx̂*(Hp-1), nd)]
512+
Gŝ = [B̂d; zeros(NT, (Hp-1)*nx̂, nd)]
513+
Jŝ = [zeros(nx̂, nd*Hp); repeatdiag(B̂d, Hp-1) zeros(NT, nx̂*(Hp-1), nd)]
515514
# --- state x̂op and state update f̂op operating points ---
516515
Bŝ = repeat(estim.f̂op - estim.x̂op, Hp)
517516
return Eŝ, Gŝ, Jŝ, Kŝ, Vŝ, Bŝ
@@ -527,10 +526,10 @@ function init_defectmat(
527526
) where {NT<:Real}
528527
nx̂, nu, nd = estim.nx̂, model.nu, model.nd
529528
nZ = get_nZ(estim, transcription, Hp, Hc)
530-
Eŝ = spzeros(NT, 0, nZ)
531-
Gŝ = spzeros(NT, 0, nd)
532-
Jŝ = spzeros(NT, 0, nd*Hp)
533-
Kŝ = spzeros(NT, 0, nx̂)
529+
Eŝ = zeros(NT, 0, nZ)
530+
Gŝ = zeros(NT, 0, nd)
531+
Jŝ = zeros(NT, 0, nd*Hp)
532+
Kŝ = zeros(NT, 0, nx̂)
534533
Vŝ = zeros(NT, 0, nu)
535534
Bŝ = zeros(NT, 0)
536535
return Eŝ, Gŝ, Jŝ, Kŝ, Vŝ, Bŝ

0 commit comments

Comments
 (0)