Open caxelrud opened 1 week ago
yes good point that would simplify the interface!
I'll take a look at your code soon.
Your code seems ok to me. Some minor comments : you should avoid global variable if possible (for performance and readability). Here model1
, M_Hp1
and Ñ_Hc1
are global variables in test_mpc
function. Add new arguments in test_mpc
function to avoid globals.
Also, I don't know if it was intended but, at i==101
, you modified the plant model in the controller but not the plant simulator. About that, be careful if you assign a new plant simulator during simulations. The simulators states are stored inside the objects (at obj.x0
). Thus, at i==101
, if you do model=model1
, the state of the plant simulator will jump to model1
internal value at this moment, that is, zero.
I'll work on your suggestion to simplify the interface.
Hi. I tested the model adaptation and tuning online changes using the code that follows my comments. I am using:
Let me know if it correct.
One suggestion, to make it simpler, is to use Mwt and Nwt parameters as in LinMPC:
mpc = LinMPC(estim, Hp=200, Hc=50, Mwt=[1.0, 1.0, 0.01], Nwt=[2.0, 2.0])
Regards, Celso