Reputation: 71
I am working on an MPC problem with individual linear models predicting the control variable at each time step in the prediction horizon (see below where u is the manipulated variable and y is the control variable). The coefficients of each linear model in the prediction horizon change based on the current state variables each time the window moves.
y[i+1] = A[i]@u[i]+B[i]
y[i+2] = A[i+1]@u[i:i+2]+B[i+1]
...
y[i+n] = A[i+n-1]@u[i:i+n]+B[i+n-1]
A and B are a list of matrices which are determined from a function of the current state. I basically want to pause the controller at the beginning of each time step (prior to optimization) and recalculate these coefficient matrices based on the feedback from the system. Is it possible to do this in Gekko using MPC mode (IMODE=6) or do I need to manage the time outside of Gekko?
Upvotes: 5
Views: 326
Reputation: 997
This is for your follow-up question in the comment.
Just for clarification, does the ARX model structure for MPC prediction change throughout all simulation time steps? Or, does it only happen at the beginning of the simulation when you don't have enough past data?
If the latter is your case, GEKKO will automatically handle it for you.
This is the structure of the ARX model.
na: # of the coefficient for CV
nb: # of the coefficient for MV
nk: Length of a time-delay between CV and MV
Gekko automatically adjusts the na and nb for the beginning of the simulation when t < na or t < nb
, which turns out the same formula in your original question above.
Upvotes: 2
Reputation: 997
You can do it by running both MHE and MPC in a row
. You want to run MHE(imode=5)
at every time step to estimate the model parameters A and B. Then, update the MPC model with the new A and B before executing the MPC(mode=6)
calculation.
Here is an example of TCLab temperature control using combined MHE and MPC. https://apmonitor.com/do/index.php/Main/TCLabH
You might need to change the model in this example with an ARX type of model that you can find on this page. https://apmonitor.com/do/index.php/Main/NonlinearControl
Upvotes: 4