I am currently using an MPC to have the TCLab heater reach a certain set point temperature. I am trying to have an MHE update certain parameter values every 50 seconds. I have a previous MPC model that worked amazing and I tried to add a part in my main loop that has it switch to improve certain values and then switch back into MPC mode. I have seen that other people doing this same problem have made a gekko class for the MPC and also for the MHE and then had them work together, but is there a way that I can add a part in my current MPC loop that will allow the MHE to update certain values and then switch back into MPC?
Here is the Code that I added into my loop to have it update the variables but it isn't updating my values
if i%50 == 0 or i == 0:
m.options.IMODE = 5
Q1.STATUS = 0
Q1.FSTATUS = 1
Q2.STATUS = 0
Q2.FSTATUS = 1
U.FSTATUS = 1
α1.FSTATUS = 1
α2.FSTATUS = 1
τ.FSTATUS = 1
m.solve(disp = False)
Q1.STATUS = 1
Q1.FSTATUS = 1
Q2.STATUS = 1
Q2.FSTATUS = 1
m.options.IMODE = 6
U.FSTATUS = 0
α1.FSTATUS = 0
α2.FSTATUS = 0
τ.FSTATUS = 0