255255
256256@doc raw """
257257 init_predmat(
258- model::LinModel, estim, transcription::SingleShooting, Hp, Hc
258+ model::LinModel, estim, transcription::SingleShooting, Hp, Hc, nb
259259 ) -> E, G, J, K, V, ex̂, gx̂, jx̂, kx̂, vx̂
260260
261261Construct the prediction matrices for [`LinModel`](@ref) and [`SingleShooting`](@ref).
@@ -355,7 +355,7 @@ each control period ``k``, see [`initpred!`](@ref) and [`linconstraint!`](@ref).
355355 ```
356356"""
357357function init_predmat (
358- model:: LinModel , estim:: StateEstimator{NT} , transcription:: SingleShooting , Hp, Hc
358+ model:: LinModel , estim:: StateEstimator{NT} , transcription:: SingleShooting , Hp, Hc, nb
359359) where {NT<: Real }
360360 Â, B̂u, Ĉ, B̂d, D̂d = estim. Â, estim. B̂u, estim. Ĉ, estim. B̂d, estim. D̂d
361361 nu, nx̂, ny, nd = model. nu, estim. nx̂, model. ny, model. nd
@@ -394,10 +394,15 @@ function init_predmat(
394394 ex̂ = Matrix {NT} (undef, nx̂, nZ)
395395 E = zeros (NT, Hp* ny, nZ)
396396 for j= 1 : Hc # truncated with control horizon
397- iRow = (ny* (j- 1 )+ 1 ): (ny* Hp)
398397 iCol = (1 : nu) .+ nu* (j- 1 )
399- E[iRow, iCol] = V[iRow .- ny* (j- 1 ),:]
400- ex̂[: , iCol] = W (Hp- j)* B̂u
398+ for i= j: Hc
399+ i_Q = i == j ? 0 : nb[i- 1 ]
400+
401+ end
402+
403+
404+ n = j > 1 ? nb[j- 1 ] : 0
405+ ex̂[: , iCol] = W (Hp- n- 1 )* B̂u
401406 end
402407 # --- current measured disturbances d0 and predictions D̂0 ---
403408 gx̂ = getpower (Âpow, Hp- 1 )* B̂d
431436
432437@doc raw """
433438 init_predmat(
434- model::LinModel, estim, transcription::MultipleShooting, Hp, Hc
439+ model::LinModel, estim, transcription::MultipleShooting, Hp, Hc, nb
435440 ) -> E, G, J, K, V, B, ex̂, gx̂, jx̂, kx̂, vx̂, bx̂
436441
437442Construct the prediction matrices for [`LinModel`](@ref) and [`MultipleShooting`](@ref).
@@ -451,7 +456,7 @@ They are defined in the Extended Help section.
451456 ```
452457"""
453458function init_predmat (
454- model:: LinModel , estim:: StateEstimator{NT} , :: MultipleShooting , Hp, Hc
459+ model:: LinModel , estim:: StateEstimator{NT} , :: MultipleShooting , Hp, Hc, nb
455460) where {NT<: Real }
456461 Ĉ, D̂d = estim. Ĉ, estim. D̂d
457462 nu, nx̂, ny, nd = model. nu, estim. nx̂, model. ny, model. nd
@@ -476,12 +481,12 @@ function init_predmat(
476481end
477482
478483"""
479- init_predmat(model::NonLinModel, estim, transcription::SingleShooting, Hp, Hc)
484+ init_predmat(model::NonLinModel, estim, transcription::SingleShooting, Hp, Hc, nb )
480485
481486Return empty matrices for [`SingleShooting`](@ref) of [`NonLinModel`](@ref)
482487"""
483488function init_predmat (
484- model:: NonLinModel , estim:: StateEstimator{NT} , transcription:: SingleShooting , Hp, Hc
489+ model:: NonLinModel , estim:: StateEstimator{NT} , transcription:: SingleShooting , Hp, Hc, _
485490) where {NT<: Real }
486491 nu, nx̂, nd = model. nu, estim. nx̂, model. nd
487492 nZ = get_nZ (estim, transcription, Hp, Hc)
@@ -496,7 +501,7 @@ function init_predmat(
496501end
497502
498503@doc raw """
499- init_predmat(model::NonLinModel, estim, transcription::TranscriptionMethod, Hp, Hc)
504+ init_predmat(model::NonLinModel, estim, transcription::TranscriptionMethod, Hp, Hc, nb )
500505
501506Return the terminal state matrices for [`NonLinModel`](@ref) and other [`TranscriptionMethod`](@ref).
502507
@@ -509,7 +514,7 @@ given in the Extended Help section.
509514 for ``\m athbf{e_x̂} = [\b egin{smallmatrix}\m athbf{0} & \m athbf{I}\e nd{smallmatrix}]``
510515"""
511516function init_predmat (
512- model:: NonLinModel , estim:: StateEstimator{NT} , transcription:: TranscriptionMethod , Hp, Hc
517+ model:: NonLinModel , estim:: StateEstimator{NT} , transcription:: TranscriptionMethod , Hp, Hc, _
513518) where {NT<: Real }
514519 nu, nx̂, nd = model. nu, estim. nx̂, model. nd
515520 nZ = get_nZ (estim, transcription, Hp, Hc)
0 commit comments