@@ -460,7 +460,7 @@ function con_nonlinprog!(g, estim::MovingHorizonEstimator, ::SimModel, X̂0, V̂
460
460
end
461
461
462
462
463
- " Update the augmented model matrices of `estim` by default ."
463
+ " Update the augmented model, prediction matrices, constrains and data windows for MHE ."
464
464
function setmodel_estimator! (
465
465
estim:: MovingHorizonEstimator , model:: LinModel , uop_old, yop_old, dop_old
466
466
)
@@ -477,7 +477,6 @@ function setmodel_estimator!(
477
477
estim. D̂d .= D̂d
478
478
# --- update state estimate and its operating points ---
479
479
x̂op_old = copy (estim. x̂op)
480
- X̂op_old = copy (estim. X̂op)
481
480
estim. x̂0 .+ = estim. x̂op # convert x̂0 to x̂ with the old operating point
482
481
estim. x̂op .= x̂op
483
482
estim. f̂op .= f̂op
@@ -498,21 +497,20 @@ function setmodel_estimator!(
498
497
con. Jx̂ .= Jx̂
499
498
con. Bx̂ .= Bx̂
500
499
# convert x̃0 to x̃ with the old operating point:
501
- con. x̃0min[end - nx̂+ 1 : end ] .- = x̂op_old
502
- con. x̃0max[end - nx̂+ 1 : end ] .- = x̂op_old
500
+ con. x̃0min[end - nx̂+ 1 : end ] .+ = x̂op_old
501
+ con. x̃0max[end - nx̂+ 1 : end ] .+ = x̂op_old
503
502
# convert X̂0 to X̂ with the old operating point:
504
- con. X̂0min .- = X̂op_old
505
- con. X̂0max .- = X̂op_old
503
+ con. X̂0min .+ = estim . X̂op
504
+ con. X̂0max .+ = estim . X̂op
506
505
for i in 0 : He- 1
507
506
estim. X̂op[(1 + nx̂* i): (nx̂+ nx̂* i)] .= estim. x̂op
508
507
end
509
508
# convert x̃ to x̃0 with the new operating point:
510
- con. x̃0min[end - nx̂+ 1 : end ] .+ = estim. x̂op
511
- con. x̃0max[end - nx̂+ 1 : end ] .+ = estim. x̂op
509
+ con. x̃0min[end - nx̂+ 1 : end ] .- = estim. x̂op
510
+ con. x̃0max[end - nx̂+ 1 : end ] .- = estim. x̂op
512
511
# convert X̂ to X̂0 with the new operating point:
513
- con. X̂0min .+ = estim. X̂op
514
- con. X̂0max .+ = estim. X̂op
515
- con. A
512
+ con. X̂0min .- = estim. X̂op
513
+ con. X̂0max .- = estim. X̂op
516
514
con. A_X̂min .= A_X̂min
517
515
con. A_X̂max .= A_X̂max
518
516
con. A_V̂min .= A_V̂min
@@ -531,25 +529,25 @@ function setmodel_estimator!(
531
529
# --- data windows ---
532
530
for i in 1 : He
533
531
# convert x̂0 to x̂ with the old operating point:
534
- estim. X̂0[(1 + nx̂* (i- 1 )): (nx̂* i)] .- = x̂op_old
532
+ estim. X̂0[(1 + nx̂* (i- 1 )): (nx̂* i)] .+ = x̂op_old
535
533
# convert ym0 to ym with the old operating point:
536
- estim. Y0m[(1 + nym* (i- 1 )): (nym* i)] .- = @views yop_old[estim. i_ym]
534
+ estim. Y0m[(1 + nym* (i- 1 )): (nym* i)] .+ = @views yop_old[estim. i_ym]
537
535
# convert u0 to u with the old operating point:
538
- estim. U0[(1 + nu* (i- 1 )): (nu* i)] .- = uop_old
536
+ estim. U0[(1 + nu* (i- 1 )): (nu* i)] .+ = uop_old
539
537
# convert d0 to d with the old operating point:
540
- estim. D0[(1 + nd* (i- 1 )): (nd* i)] .- = dop_old
538
+ estim. D0[(1 + nd* (i- 1 )): (nd* i)] .+ = dop_old
541
539
# convert x̂ to x̂0 with the new operating point:
542
- estim. X̂0[(1 + nx̂* (i- 1 )): (nx̂* i)] .+ = x̂op
540
+ estim. X̂0[(1 + nx̂* (i- 1 )): (nx̂* i)] .- = x̂op
543
541
# convert ym to y0m with the new operating point:
544
- estim. Y0m[(1 + nym* (i- 1 )): (nym* i)] .+ = @views yop_old [estim. i_ym]
542
+ estim. Y0m[(1 + nym* (i- 1 )): (nym* i)] .- = @views model . yop [estim. i_ym]
545
543
# convert u to u0 with the new operating point:
546
- estim. U0[(1 + nu* (i- 1 )): (nu* i)] .+ = uop_old
544
+ estim. U0[(1 + nu* (i- 1 )): (nu* i)] .- = model . uop
547
545
# convert d to d0 with the new operating point:
548
- estim. D0[(1 + nd* (i- 1 )): (nd* i)] .+ = dop_old
546
+ estim. D0[(1 + nd* (i- 1 )): (nd* i)] .- = model . dop
549
547
end
550
- estim. Z̃[nϵ+ 1 : nϵ+ nx̂] .- = x̂op_old
551
- estim. Z̃[nϵ + 1 : nϵ + nx̂] .+ = x̂op
552
- estim. x̂0arr_old .- = x̂op_old
553
- estim. x̂0arr_old .+ = x̂op
548
+ estim. Z̃[nϵ+ 1 : nϵ+ nx̂] .+ = x̂op_old
549
+ estim. x̂0arr_old .+ = x̂op_old
550
+ estim. Z̃[nϵ + 1 : nϵ + nx̂] .- = x̂op
551
+ estim. x̂0arr_old .- = x̂op
554
552
return nothing
555
553
end
0 commit comments