@@ -386,7 +386,7 @@ function setconstraint!(
386
386
JuMP. delete (optim, optim[:linconstraint ])
387
387
JuMP. unregister (optim, :linconstraint )
388
388
@constraint (optim, linconstraint, A* Z̃var .≤ b)
389
- set_nonlincon! (mpc, model, optim)
389
+ set_nonlincon! (mpc, model, transcription, optim)
390
390
else
391
391
i_b, i_g = init_matconstraint_mpc (
392
392
model, transcription, nc,
@@ -400,94 +400,6 @@ function setconstraint!(
400
400
return mpc
401
401
end
402
402
403
-
404
- @doc raw """
405
- init_matconstraint_mpc(
406
- model::LinModel, transcription::TranscriptionMethod, nc::Int,
407
- i_Umin, i_Umax, i_ΔŨmin, i_ΔŨmax, i_Ymin, i_Ymax, i_x̂min, i_x̂max,
408
- args...
409
- ) -> i_b, i_g, A, Aeq, neq
410
-
411
- Init `i_b`, `i_g`, `neq`, and `A` and `Aeq` matrices for the all the MPC constraints.
412
-
413
- The linear and nonlinear constraints are respectively defined as:
414
- ```math
415
- \b egin{aligned}
416
- \m athbf{A Z̃ } &≤ \m athbf{b} \\
417
- \m athbf{A_{eq} Z̃} &= \m athbf{b_{eq}} \\
418
- \m athbf{g(Z̃)} &≤ \m athbf{0} \\
419
- \m athbf{g_{eq}(Z̃)} &= \m athbf{0} \\
420
- \e nd{aligned}
421
- ```
422
- The argument `nc` is the number of custom nonlinear inequality constraints in
423
- ``\m athbf{g_c}``. `i_b` is a `BitVector` including the indices of ``\m athbf{b}`` that are
424
- finite numbers. `i_g` is a similar vector but for the indices of ``\m athbf{g}``. The method
425
- also returns the ``\m athbf{A, A_{eq}}`` matrices and `neq` if `args` is provided. In such a
426
- case, `args` needs to contain all the inequality and equality constraint matrices:
427
- `A_Umin, A_Umax, A_ΔŨmin, A_ΔŨmax, A_Ymin, A_Ymax, A_x̂min, A_x̂max, A_ŝ`. The integer `neq`
428
- is the number of nonlinear equality constraints in ``\m athbf{g_{eq}}``.
429
- """
430
- function init_matconstraint_mpc (
431
- :: LinModel{NT} , :: TranscriptionMethod , nc:: Int ,
432
- i_Umin, i_Umax, i_ΔŨmin, i_ΔŨmax, i_Ymin, i_Ymax, i_x̂min, i_x̂max,
433
- args...
434
- ) where {NT<: Real }
435
- if isempty (args)
436
- A, Aeq, neq = nothing , nothing , nothing
437
- else
438
- A_Umin, A_Umax, A_ΔŨmin, A_ΔŨmax, A_Ymin, A_Ymax, A_x̂min, A_x̂max, A_ŝ = args
439
- A = [A_Umin; A_Umax; A_ΔŨmin; A_ΔŨmax; A_Ymin; A_Ymax; A_x̂min; A_x̂max]
440
- Aeq = A_ŝ
441
- neq = 0
442
- end
443
- i_b = [i_Umin; i_Umax; i_ΔŨmin; i_ΔŨmax; i_Ymin; i_Ymax; i_x̂min; i_x̂max]
444
- i_g = trues (nc)
445
- return i_b, i_g, A, Aeq, neq
446
- end
447
-
448
- " Init `i_b` without output constraints if [`NonLinModel`](@ref) & [`MultipleShooting`](@ref)."
449
- function init_matconstraint_mpc (
450
- :: NonLinModel{NT} , :: MultipleShooting , nc:: Int ,
451
- i_Umin, i_Umax, i_ΔŨmin, i_ΔŨmax, i_Ymin, i_Ymax, i_x̂min, i_x̂max,
452
- args...
453
- ) where {NT<: Real }
454
- if isempty (args)
455
- A, Aeq, neq = nothing , nothing , nothing
456
- else
457
- A_Umin, A_Umax, A_ΔŨmin, A_ΔŨmax, A_Ymin, A_Ymax, A_x̂min, A_x̂max, A_ŝ = args
458
- A = [A_Umin; A_Umax; A_ΔŨmin; A_ΔŨmax; A_Ymin; A_Ymax; A_x̂min; A_x̂max]
459
- Aeq = A_ŝ
460
- nΔŨ, nZ̃ = size (A_ΔŨmin)
461
- neq = nZ̃ - nΔŨ
462
- end
463
- i_b = [i_Umin; i_Umax; i_ΔŨmin; i_ΔŨmax; i_x̂min; i_x̂max]
464
- i_g = [i_Ymin; i_Ymax; trues (nc)]
465
- return i_b, i_g, A, Aeq, neq
466
- end
467
-
468
- " Init `i_b` without output & terminal constraints if [`NonLinModel`](@ref) & [`SingleShooting`](@ref)."
469
- function init_matconstraint_mpc (
470
- :: NonLinModel{NT} , :: SingleShooting , nc:: Int ,
471
- i_Umin, i_Umax, i_ΔŨmin, i_ΔŨmax, i_Ymin, i_Ymax, i_x̂min, i_x̂max,
472
- args...
473
- ) where {NT<: Real }
474
- if isempty (args)
475
- A, Aeq, neq = nothing , nothing , nothing
476
- else
477
- A_Umin, A_Umax, A_ΔŨmin, A_ΔŨmax, A_Ymin, A_Ymax, A_x̂min, A_x̂max, A_ŝ = args
478
- A = [A_Umin; A_Umax; A_ΔŨmin; A_ΔŨmax; A_Ymin; A_Ymax; A_x̂min; A_x̂max]
479
- Aeq = A_ŝ
480
- neq = 0
481
- end
482
- i_b = [i_Umin; i_Umax; i_ΔŨmin; i_ΔŨmax]
483
- i_g = [i_Ymin; i_Ymax; i_x̂min; i_x̂max; trues (nc)]
484
- return i_b, i_g, A, Aeq, neq
485
- end
486
-
487
-
488
- " By default, there is no nonlinear constraint, thus do nothing."
489
- set_nonlincon! (:: PredictiveController , :: SimModel , :: JuMP.GenericModel ) = nothing
490
-
491
403
"""
492
404
default_Hp(model::LinModel)
493
405
0 commit comments