Hi
Buddi,
Here's a bit of a breakdown on how these different timescales work together:
Run Time: This is the total time for which the experiment or the simulation will run. In this case, it's 5 minutes.
Loops: This is the total number of loops the script will run. Here, loops = 60*run_time, so if run_time is 5 minutes, loops will be 300. This means the script will run 300 cycles. It's important to note that in this context, each cycle corresponds to a second, as the run_time is converted to seconds by multiplying it with 60.
m.time: This is the prediction horizon in the model predictive control. It is discretized into 31 points from 0 to 30 seconds. The controller will generate a control plan for this entire prediction horizon at every cycle of the script.
Here's how all of these work together:
At each cycle (300 in total), the script will measure the current temperature, then solve the MPC problem to generate a control plan for the next 30 seconds (the prediction horizon). However, it will only implement the first second of this plan (first step of m.time), then it will measure the temperature again, solve the MPC problem again, and so on.
So, in essence, the control and prediction horizons are not longer than the discretization of the variables. The control plan is updated every second (each loop cycle) using the latest measurements.
This method is known as receding horizon control strategy, where the control action is re-computed at each time step, considering the current state of the system.
It's important to understand that the prediction horizon (m.time) does not need to be the same as the run time of the script. The prediction horizon just needs to be long enough to predict the future behavior of the system accurately, and it's often much shorter than the total run time of the experiment or the simulation.
Thanks,
Adnan