@@ -492,7 +492,7 @@ function init_defectmat(
492
492
nu, nx̂, nd = model. nu, estim. nx̂, model. nd
493
493
Â, B̂u, B̂d = estim. Â, estim. B̂u, estim. B̂d
494
494
# --- current state estimates x̂0 ---
495
- Kŝ = [Â; zeros (NT, nx̂* (Hp- 1 ), nx̂)]
495
+ Kŝ = [Â; spzeros (NT, nx̂* (Hp- 1 ), nx̂)]
496
496
# --- previous manipulated inputs lastu0 ---
497
497
Vŝ = repeat (B̂u, Hp)
498
498
# --- decision variables Z ---
@@ -508,9 +508,10 @@ function init_defectmat(
508
508
iCol = (1 : nx̂) .+ nx̂* (j- 1 ) .+ nu* Hc
509
509
Eŝ[iRow, iCol] = Â
510
510
end
511
+ Eŝ = sparse (Eŝ)
511
512
# --- current measured disturbances d0 and predictions D̂0 ---
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)]
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)]
514
515
# --- state x̂op and state update f̂op operating points ---
515
516
Bŝ = repeat (estim. f̂op - estim. x̂op, Hp)
516
517
return Eŝ, Gŝ, Jŝ, Kŝ, Vŝ, Bŝ
@@ -526,10 +527,10 @@ function init_defectmat(
526
527
) where {NT<: Real }
527
528
nx̂, nu, nd = estim. nx̂, model. nu, model. nd
528
529
nZ = get_nZ (estim, transcription, Hp, Hc)
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̂)
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̂)
533
534
Vŝ = zeros (NT, 0 , nu)
534
535
Bŝ = zeros (NT, 0 )
535
536
return Eŝ, Gŝ, Jŝ, Kŝ, Vŝ, Bŝ
0 commit comments