-
-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting a Control Horizon #90
Comments
You are correct that |
Sorry, I am still new to GEKKO / APmonitor as a whole. The non uniform time horizon seems like a possible workaround somewhat akin to input blocking; the solver still calculates optimal MV moves for the end of the non uniform time horizon just as it does for uniform ones (ctrl horizon m still equals pred horizon p). I was able to eliminate the MV cycling I was observing by using relatively high MV change weighting in the cost function and using max MV change limits. This behavior seemed a bit odd to me so I will try cross checking these results with other MPC platforms as well. Before closing I am still unclear on why the horizons were implemented this way. Does APMonitor believe there are advantages for setting m = p in most cases or was it simply a feature that got pushed out due to more pressing issues? I am not trying to say one way is right or wrong, but was wondering if there is something I am missing here |
One of the unique things about Gekko MPC is that is includes both MV and CV tuning. Other MPC platforms typically either use a reference trajectory (CV tuning) or move suppression (MV tuning). There is more information on MV / CV tuning here: https://apmonitor.com/do/index.php/Main/ControllerTuning Another parameter that you could try is You are correct that CTRL_HOR, PRED_HOR, CTRL_TIME, PRED_TIME, and other parameters are not fully supported in Gekko. I could add back in the CTRL_HOR concept, if needed. Specifying m.time to be whatever is needed makes PRED_HOR, CTRL_TIME, and PRED_TIME obsolete. |
That's a great animation! I don't think I need to be able to adjust the control horizon, but clarifying in the m.time +/or options.CTRL_HOR sections in the documentation that the control horizon can not be updated manually or adjusted (when CSV_READ is on and m.time is specified) may save future users some time. Nonetheless thanks for your replies and for this awesome package |
@APMonitor would it be possible to use connections to fix the last n points of the MV together, effectively removing their degrees of freedom? Would there be any concerns with bug #59? |
I don't think the CSV is critical but it is an important way to initialize variables from Gekko. There is no problem with #59 endpoint derivatives because an MV is a subclass of parameters and Param doesn't have a derivative. The easiest way to integrate this features is to turn off the degrees of freedom for the MV based on CTRL_HOR. It has a default value of 1 so I was using CSV_READ to determine when we would either use the data from the CSV file or use the specifications from CTRL_HOR, PRED_HOR, CTRL_TIME, PRED_TIME. Maybe we just need a vector that has length m.time that has a True or False for the MV dof. It could be an option for MVs. |
In designing, configuring, and simulating MPCs, I am used to setting a control horizon, often distinct from the prediction horizon, for use at every sampling instant of the controller. I saw in the documentation that the global option CTRL_HOR of a gekko model can be read but perhaps not written (if I try to set it, then run the MPC, then read the current CTRL_HOR, the CTRL_HOR has reset to the default value of points in the supplied time array). In the documentation it is written:
"When CSV_READ is on and the horizon time points are specified from the data file, the CTRL_HOR and PRED_HOR are set equal to the number of time steps present in the data file."
I do not believe that I want to turn CSV_READ off. Is there a way to set the control horizon? I was surprised to see this parameter not readily adjustable, as I had thought others commonly use it for tuning MPCs.
If it helps, I have mainly been looking at the gas pedal example on the wiki: http://apmonitor.com/wiki/index.php/Main/Control
The text was updated successfully, but these errors were encountered: