@@ -457,26 +457,40 @@ end
457457estimate_delays (:: SimModel ) = 0
458458
459459
460- """
460+ @doc raw """
461461 move_blocking(Hp::Int, Hc::AbstractVector{Int}) -> nb
462462
463- Get move blocking vector `nb` and actual control horizon from `Hp` and `Hc` arguments.
464-
465- The argument `Hc` is in fact the move blocking vector `nb` provided by the user. The `nb`
466- vector is modified in these two cases:
463+ Get the move blocking vector `nb` from the `Hc` argument, and modify it to match `Hp`.
467464
465+ The argument `Hc` is interpreted as the move blocking vector `nb`. It specifies the length
466+ of each step (or "block") in the ``\m athbf{ΔU}`` vector, to customize the pattern (strictly
467+ positive integers):
468+ ```math
469+ \m athbf{n_b} = \b egin{bmatrix} n_1 & n_2 & \c dots & n_{H_c} \e nd{bmatrix}'
470+ ```
471+ The vector with all the manipulated input increments is then defined as:
472+ ```math
473+ \m athbf{ΔU} = \b egin{bmatrix}
474+ \m athbf{Δu}(k + 0) \\ [0.1em]
475+ \m athbf{Δu}(k + ∑_{i=1}^1 n_i) \\ [0.1em]
476+ \m athbf{Δu}(k + ∑_{i=1}^2 n_i) \\ [0.1em]
477+ \v dots \\ [0.1em]
478+ \m athbf{Δu}(k + ∑_{i=1}^{H_c-1} n_i)
479+ \e nd{bmatrix}
480+ ```
481+ The provided `nb` vector is modified in these two cases:
468482- If `sum(nb) < Hp`, a new element is pushed to `nb` with the value `Hp - sum(nb)`.
469483- If `sum(nb) > Hp`, the intervals are truncated until the sum is `Hp`. For example, if
470484 `Hp = 10` and `nb = [1, 2, 3, 6, 7]`, then `nb` is truncated to `[1, 2, 3, 4]`.
471485"""
472486function move_blocking (Hp_arg:: Int , Hc_arg:: AbstractVector{Int} )
473487 Hp = Hp_arg
474488 nb = Hc_arg
489+ all (> (0 ), nb) || throw (ArgumentError (" Move blocking vector must be strictly positive integers." ))
475490 if sum (nb) < Hp
476491 newblock = [Hp - sum (nb)]
477492 nb = [nb; newblock]
478493 elseif sum (nb) > Hp
479- # For example, if Hp = 10 and nb = [1, 2, 3, 6, 7], than nb is truncated to [1, 2, 3, 4]
480494 nb = nb[begin : findfirst (≥ (Hp), cumsum (nb))]
481495 if sum (nb) > Hp
482496 # if the last block is too large, it is truncated to fit Hp:
489503"""
490504 move_blocking(Hp::Int, Hc::Int) -> nb
491505
492- Construct a move blocking vector `nb` that match the provided `Hp` and `Hc` horizons .
506+ Construct a move blocking vector `nb` that match the provided `Hp` and `Hc` integers .
493507
494508The vector is filled with `1`s, except for the last element which is `Hp - Hc + 1`.
495509"""
0 commit comments