@@ -63,7 +63,7 @@ struct NonLinMPC{
6363 Dop:: Vector{NT}
6464 buffer:: PredictiveControllerBuffer{NT}
6565 function NonLinMPC {NT} (
66- estim:: SE , Hp, Hc, weights:: CW ,
66+ estim:: SE , Hp, Hc, nb, weights:: CW ,
6767 JE:: JEfunc , gc!:: GCfunc , nc, p:: PT ,
6868 transcription:: TM , optim:: JM ,
6969 gradient:: GB , jacobian:: JB
@@ -84,7 +84,6 @@ struct NonLinMPC{
8484 ŷ = copy (model. yop) # dummy vals (updated just before optimization)
8585 # dummy vals (updated just before optimization):
8686 R̂y, R̂u, Tu_lastu0 = zeros (NT, ny* Hp), zeros (NT, nu* Hp), zeros (NT, nu* Hp)
87- nb = ones (Hc)
8887 PΔu = init_ZtoΔU (estim, transcription, Hp, Hc)
8988 Pu, Tu = init_ZtoU (estim, transcription, Hp, Hc)
9089 E, G, J, K, V, B, ex̂, gx̂, jx̂, kx̂, vx̂, bx̂ = init_predmat (
@@ -280,7 +279,7 @@ NonLinMPC controller with a sample time Ts = 10.0 s, Ipopt optimizer, UnscentedK
280279function NonLinMPC (
281280 model:: SimModel ;
282281 Hp:: Int = default_Hp (model),
283- Hc:: Int = DEFAULT_HC,
282+ Hc:: IntVectorOrInt = DEFAULT_HC,
284283 Mwt = fill (DEFAULT_MWT, model. ny),
285284 Nwt = fill (DEFAULT_NWT, model. nu),
286285 Lwt = fill (DEFAULT_LWT, model. nu),
@@ -337,7 +336,7 @@ NonLinMPC controller with a sample time Ts = 10.0 s, Ipopt optimizer, UnscentedK
337336function NonLinMPC (
338337 estim:: SE ;
339338 Hp:: Int = default_Hp (estim. model),
340- Hc:: Int = DEFAULT_HC,
339+ Hc:: IntVectorOrInt = DEFAULT_HC,
341340 Mwt = fill (DEFAULT_MWT, estim. model. ny),
342341 Nwt = fill (DEFAULT_NWT, estim. model. nu),
343342 Lwt = fill (DEFAULT_LWT, estim. model. nu),
@@ -364,11 +363,12 @@ function NonLinMPC(
364363 @warn (" prediction horizon Hp ($Hp ) ≤ estimated number of delays in model " *
365364 " ($nk ), the closed-loop system may be unstable or zero-gain (unresponsive)" )
366365 end
366+ nb, Hc = move_blocking (Hc)
367367 validate_JE (NT, JE)
368368 gc! = get_mutating_gc (NT, gc)
369369 weights = ControllerWeights {NT} (estim. model, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt, Ewt)
370370 return NonLinMPC {NT} (
371- estim, Hp, Hc, weights, JE, gc!, nc, p, transcription, optim, gradient, jacobian
371+ estim, Hp, Hc, nb, weights, JE, gc!, nc, p, transcription, optim, gradient, jacobian
372372 )
373373end
374374
0 commit comments