Skip to content

Commit 36350da

Browse files
committed
starting custom NL constraints
1 parent 44dba57 commit 36350da

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ for more detailed examples.
8484
- [x] move suppression
8585
- [x] input setpoint tracking
8686
- [x] terminal costs
87-
- [x] economic costs (economic model predictive control)
87+
- [x] custom economic costs (economic model predictive control)
8888
- [x] adaptive linear model predictive controller
8989
- [x] manual model modification
9090
- [x] automatic successive linearization of a nonlinear model
@@ -95,7 +95,7 @@ for more detailed examples.
9595
- [x] manipulated inputs
9696
- [x] manipulated inputs increments
9797
- [x] terminal states to ensure nominal stability
98-
- [ ] custom manipulated input constraints that are a function of the predictions
98+
- [x] custom economic inequality constraints (soft or hard)
9999
- [x] supported feedback strategy:
100100
- [x] state estimator (see State Estimation features)
101101
- [x] internal model structure with a custom stochastic model

src/controller/nonlinmpc.jl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,14 @@ controller minimizes the following objective function at each discrete time ``k`
115115
+ E J_E(\mathbf{U}_E, \mathbf{Ŷ}_E, \mathbf{D̂}_E, \mathbf{p})
116116
\end{aligned}
117117
```
118-
See [`LinMPC`](@ref) for the variable definitions. The custom economic function ``J_E`` can
119-
penalizes solutions with high economic costs. Setting all the weights to 0 except ``E``
120-
creates a pure economic model predictive controller (EMPC). The arguments of ``J_E`` include
121-
the manipulated inputs, the predicted outputs and measured disturbances from ``k`` to
122-
``k+H_p`` inclusively:
118+
subject to [`setconstraint!`](@ref) bounds, and the custom economic inequality constraints:
119+
```math
120+
\mathbf{g}_E(\mathbf{U}_E, \mathbf{Ŷ}_E, \mathbf{D̂}_E, \mathbf{p}, ε) ≤ \mathbf{0}
121+
````
122+
The economic function ``J_E`` can penalizes solutions with high economic costs. Setting all
123+
the weights to 0 except ``E`` creates a pure economic model predictive controller (EMPC).
124+
The arguments of ``J_E`` include the manipulated inputs, the predicted outputs and measured
125+
disturbances from ``k`` to ``k+H_p`` inclusively:
123126
```math
124127
\mathbf{U}_E = \begin{bmatrix} \mathbf{U} \\ \mathbf{u}(k+H_p-1) \end{bmatrix} , \quad
125128
\mathbf{Ŷ}_E = \begin{bmatrix} \mathbf{ŷ}(k) \\ \mathbf{Ŷ} \end{bmatrix} , \quad
@@ -133,7 +136,8 @@ mutable one if you want to modify it later e.g.: a vector.
133136
!!! tip
134137
Replace any of the 4 arguments with `_` if not needed (see `JE` default value below).
135138
136-
This method uses the default state estimator :
139+
See [`LinMPC`](@ref) for the definition of the other variables. This method uses the default
140+
state estimator :
137141
138142
- if `model` is a [`LinModel`](@ref), a [`SteadyKalmanFilter`](@ref) with default arguments;
139143
- else, an [`UnscentedKalmanFilter`](@ref) with default arguments.
@@ -154,7 +158,10 @@ This method uses the default state estimator :
154158
- `L_Hp=diagm(repeat(Lwt,Hp))` : positive semidefinite symmetric matrix ``\mathbf{L}_{H_p}``.
155159
- `Cwt=1e5` : slack variable weight ``C`` (scalar), use `Cwt=Inf` for hard constraints only.
156160
- `Ewt=0.0` : economic costs weight ``E`` (scalar).
157-
- `JE=(_,_,_,_)->0.0` : economic function ``J_E(\mathbf{U}_E, \mathbf{Ŷ}_E, \mathbf{D̂}_E, \mathbf{p})``.
161+
- `JE=(_,_,_,_)->0.0` : economic (or custom) cost function
162+
``J_E(\mathbf{U}_E, \mathbf{Ŷ}_E, \mathbf{D̂}_E, \mathbf{p})``.
163+
- `gE=(_,_,_,_,_)->[]` : economic (or custom) constraint function
164+
``\mathbf{g}_E(\mathbf{U}_E, \mathbf{Ŷ}_E, \mathbf{D̂}_E, \mathbf{p}, ε)``.
158165
- `p=model.p` : ``J_E`` function parameter ``\mathbf{p}`` (any type).
159166
- `optim=JuMP.Model(Ipopt.Optimizer)` : nonlinear optimizer used in the predictive
160167
controller, provided as a [`JuMP.Model`](https://jump.dev/JuMP.jl/stable/api/JuMP/#JuMP.Model)

0 commit comments

Comments
 (0)