@@ -460,7 +460,7 @@ function con_nonlinprog!(g, estim::MovingHorizonEstimator, ::SimModel, X̂0, V̂
460460end
461461
462462
463- " Update the augmented model matrices of `estim` by default ."
463+ " Update the augmented model, prediction matrices, constrains and data windows for MHE ."
464464function setmodel_estimator! (
465465 estim:: MovingHorizonEstimator , model:: LinModel , uop_old, yop_old, dop_old
466466)
@@ -477,7 +477,6 @@ function setmodel_estimator!(
477477 estim. D̂d .= D̂d
478478 # --- update state estimate and its operating points ---
479479 x̂op_old = copy (estim. x̂op)
480- X̂op_old = copy (estim. X̂op)
481480 estim. x̂0 .+ = estim. x̂op # convert x̂0 to x̂ with the old operating point
482481 estim. x̂op .= x̂op
483482 estim. f̂op .= f̂op
@@ -498,21 +497,20 @@ function setmodel_estimator!(
498497 con. Jx̂ .= Jx̂
499498 con. Bx̂ .= Bx̂
500499 # 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
503502 # 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
506505 for i in 0 : He- 1
507506 estim. X̂op[(1 + nx̂* i): (nx̂+ nx̂* i)] .= estim. x̂op
508507 end
509508 # 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
512511 # 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
516514 con. A_X̂min .= A_X̂min
517515 con. A_X̂max .= A_X̂max
518516 con. A_V̂min .= A_V̂min
@@ -531,25 +529,25 @@ function setmodel_estimator!(
531529 # --- data windows ---
532530 for i in 1 : He
533531 # 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
535533 # 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]
537535 # 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
539537 # 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
541539 # 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
543541 # 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]
545543 # 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
547545 # 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
549547 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
554552 return nothing
555553end
0 commit comments