LIBRARY
Examples.LinearMPCEconomicExample ​
Economic MPC of a first-order plant with LinearMPCController: a time-varying price enters the linear control cost (Eu p + eu)' u through the generalized-parameter input p, so the controller trades tracking against the cost of actuation when the price is high. The prediction model is the plant itself (dynamics = plant), which the controller discretizes exactly with the sample time 0.1.
Usage ​
MPCComponents.Examples.LinearMPCEconomicExample()
Variables ​
| Name | Description | Units |
|---|---|---|
y1 | Plant output | – |
u1 | Control signal | – |
Behavior ​
Behavior of this component cannot be rendered because it includes path variables.
Source ​
dyad
"""
Economic MPC of a first-order plant with `LinearMPCController`: a time-varying price enters
the linear control cost `(Eu p + eu)' u` through the generalized-parameter input `p`, so the
controller trades tracking against the cost of actuation when the price is high. The prediction
model is the plant itself (`dynamics = plant`), which the controller discretizes exactly with the
sample time 0.1.
"""
example component LinearMPCEconomicExample
periodicclock = DiscreteComponents.PeriodicClock(dt = 0.1) {}
plant = BlockComponents.Continuous.FirstOrder(k = 1.0, T = 0.5, x(initial = 0)) {}
s1 = DiscreteComponents.Sampler() {}
sr = DiscreteComponents.Sampler() {}
sp = DiscreteComponents.Sampler() {}
zoh = DiscreteComponents.ZeroOrderHold() {}
ref = BlockComponents.Sources.Constant(k = 1.0) {}
price = BlockComponents.Sources.Sine(amplitude = 0.5, frequency = 0.2, offset = 0.5) {}
mpc = MPCComponents.LinearMPCController(dynamics = plant, inputs = ["u"], outputs = ["y"], state_variables = ["x"], Ts = 0.1, Q1 = [1.0], Q2 = [0.01], Eu = [[1.0]], umin = [0.0], umax = [2.0], Np = 8, R1 = [0.01], R2 = [0.01]) {}
"Plant output"
variable y1::Real
"Control signal"
variable u1::Real
relations
y1 = plant.y
u1 = mpc.u[1]
connect(zoh.y, plant.u)
connect(plant.y, s1.u)
connect(s1.y, mpc.y[1], periodicclock.y)
connect(ref.y, sr.u)
connect(sr.y, mpc.r[1])
connect(price.y, sp.u)
connect(sp.y, mpc.p[1])
connect(mpc.u[1], zoh.u)
metadata {"Dyad": {"tests": {"case1": {"stop": 10}}, "doc": {"behavior": false}}}
endFlattened Source
dyad
"""
Economic MPC of a first-order plant with `LinearMPCController`: a time-varying price enters
the linear control cost `(Eu p + eu)' u` through the generalized-parameter input `p`, so the
controller trades tracking against the cost of actuation when the price is high. The prediction
model is the plant itself (`dynamics = plant`), which the controller discretizes exactly with the
sample time 0.1.
"""
example component LinearMPCEconomicExample
periodicclock = DiscreteComponents.PeriodicClock(dt = 0.1) {}
plant = BlockComponents.Continuous.FirstOrder(k = 1.0, T = 0.5, x(initial = 0)) {}
s1 = DiscreteComponents.Sampler() {}
sr = DiscreteComponents.Sampler() {}
sp = DiscreteComponents.Sampler() {}
zoh = DiscreteComponents.ZeroOrderHold() {}
ref = BlockComponents.Sources.Constant(k = 1.0) {}
price = BlockComponents.Sources.Sine(amplitude = 0.5, frequency = 0.2, offset = 0.5) {}
mpc = MPCComponents.LinearMPCController(dynamics = plant, inputs = ["u"], outputs = ["y"], state_variables = ["x"], Ts = 0.1, Q1 = [1.0], Q2 = [0.01], Eu = [[1.0]], umin = [0.0], umax = [2.0], Np = 8, R1 = [0.01], R2 = [0.01]) {}
"Plant output"
variable y1::Real
"Control signal"
variable u1::Real
relations
y1 = plant.y
u1 = mpc.u[1]
connect(zoh.y, plant.u)
connect(plant.y, s1.u)
connect(s1.y, mpc.y[1], periodicclock.y)
connect(ref.y, sr.u)
connect(sr.y, mpc.r[1])
connect(price.y, sp.u)
connect(sp.y, mpc.p[1])
connect(mpc.u[1], zoh.u)
metadata {"Dyad": {"tests": {"case1": {"stop": 10}}, "doc": {"behavior": false}}}
endTest Cases ​
Test Case case1 ​
Related ​
Examples
Experiments
Analyses