@@ -1403,21 +1403,26 @@ end
14031403
14041404Nonlinear equality constrains for [`NonLinModel`](@ref) and [`MultipleShooting`](@ref).
14051405
1406- The method mutates the `geq`, `X̂0`, `Û0` and `K` vectors in argument. The nonlinear
1407- equality constraints `geq` only includes the augmented state defects, computed with:
1406+ The method mutates the `geq`, `X̂0`, `Û0` and `K` vectors in argument. The defects of the
1407+ stochastic states are linear equality constraints (see [`init_defectmat`](@ref)). The
1408+ defects of the deterministic states are computed with:
1409+ with:
14081410```math
1409- \m athbf{ŝ }(k+j+1) = \m athbf{f̂ }\B ig(\m athbf{x̂_0 }(k+j), \m athbf{u_0 }(k+j), \m athbf{d̂_0}(k+j)\B ig)
1410- - \m athbf{x̂_0 }(k+j+1)
1411+ \m athbf{ŝ_d }(k+j+1) = \m athbf{f }\B ig(\m athbf{x_0 }(k+j), \m athbf{û_0 }(k+j), \m athbf{d̂_0}(k+j)\B ig)
1412+ - \m athbf{x_0 }(k+j+1)
14111413```
1412- for ``j = 0, 1, ... , H_p-1``, and in which the augmented state ``\m athbf{x̂_0}`` are
1413- extracted from the decision variables `Z̃`, and ``\m athbf{f̂}`` is the augmented state
1414- function defined in [`f̂!`](@ref).
1414+ for ``j = 0, 1, ... , H_p-1``, and in which the deterministic state ``\m athbf{x_0}`` are
1415+ extracted from the decision variables `Z̃`, ``\m athbf{f}`` is the deterministic state update
1416+ function [`f!`](@ref), the disturbed input ``\m athbf{û_0}`` is defined in [`f̂!`](@ref)
1417+ documentation. The defects of the stochastic states are linear equality constraints (see
1418+ [`init_defectmat`](@ref)).
14151419"""
14161420function con_nonlinprogeq! (
14171421 geq, X̂0, Û0, K,
1418- mpc:: PredictiveController , model:: NonLinModel , transcription:: MultipleShooting , U0, Z̃
1422+ mpc:: PredictiveController , model:: NonLinModel , transcription:: MultipleShooting ,
1423+ U0, Z̃
14191424)
1420- nu, nx̂, nd, nk = model . nu, mpc. estim. nx̂, model. nd, model. nk
1425+ nx̂, nx, nu, nd, nk = mpc. estim. nx̂, model . nx, model . nu , model. nd, model. nk
14211426 Hp, Hc = mpc. Hp, mpc. Hc
14221427 nΔU, nX̂ = nu* Hc, nx̂* Hp
14231428 f_threads = transcription. f_threads
@@ -1426,25 +1431,19 @@ function con_nonlinprogeq!(
14261431 disturbedinput! (Û0, mpc, mpc. estim, U0, X̂0_Z̃)
14271432 @threadsif f_threads for j= 1 : Hp
14281433 if j < 2
1429- x̂0_Z̃ = @views mpc. estim. x̂0[1 : nx̂ ]
1434+ x0_Z̃ = @views mpc. estim. x̂0[1 : nx ]
14301435 d̂0 = @views mpc. d0[1 : nd]
14311436 else
1432- x̂0_Z̃ = @views X̂0_Z̃[(1 + nx̂* (j- 2 )): (nx̂* (j- 1 ))]
1437+ x0_Z̃ = @views X̂0_Z̃[(1 + nx̂* (j- 2 )): (nx + nx̂* (j- 2 ))]
14331438 d̂0 = @views D̂0[(1 + nd* (j- 2 )): (nd* (j- 1 ))]
14341439 end
14351440 û0 = @views Û0[(1 + nu* (j- 1 )): (nu* j)]
14361441 k = @views K[(1 + nk* (j- 1 )): (nk* j)]
1437- x̂0next = @views X̂0[(1 + nx̂* (j- 1 )): (nx̂* j)]
1438- x̂0next_Z̃ = @views X̂0_Z̃[(1 + nx̂* (j- 1 )): (nx̂* j)]
1439- ŝnext = @views geq[(1 + nx̂* (j- 1 )): (nx̂* j)]
1440- f̂! (x̂0next, û0, k, mpc. estim, model, x̂0_Z̃, u0, d̂0)
1441-
1442- @views xdnext = x̂0next[1 : model. nx], x̂0next[model. nx+ 1 : end ]
1443-
1444- f! (xdnext, k, model, xd, û0, d0, model. p)
1445-
1446-
1447- ŝnext .= @. x̂0next - x̂0next_Z̃
1442+ x0next = @views X̂0[(1 + nx̂* (j- 1 )): (nx + nx̂* (j- 1 ))]
1443+ x0next_Z̃ = @views X̂0_Z̃[(1 + nx̂* (j- 1 )): (nx + nx̂* (j- 1 ))]
1444+ sdnext = @views geq[(1 + nx* (j- 1 )): (nx* j)]
1445+ f! (x0next, k, model, x0_Z̃, û0, d̂0, model. p)
1446+ sdnext .= @. x0next - x0next_Z̃
14481447 end
14491448 return geq
14501449end
@@ -1458,10 +1457,8 @@ end
14581457
14591458Nonlinear equality constrains for [`NonLinModel`](@ref) and [`TrapezoidalCollocation`](@ref).
14601459
1461- The method mutates the `geq`, `X̂0`, `Û0` and `K̇` vectors in argument. The nonlinear equality
1462- constraints `geq` includes the defects of the deterministic states only. The stochastic
1463- states are handled seperatly as linear equality constraints, see [`init_defectmat`](@ref).
1464- The deterministic state defects are computed with:
1460+ The method mutates the `geq`, `X̂0`, `Û0` and `K̇` vectors in argument. The deterministic
1461+ state defects are computed with:
14651462```math
14661463\m athbf{s_d}(k+j+1) = \m athbf{x_0}(k+j) + 0.5 T_s [\m athbf{k̇}_1(k+j) + \m athbf{k̇}_2(k+j)]
14671464 - \m athbf{x_0}(k+j+1)
0 commit comments