Jalesh,
I recommend using the Python GEKKO package as an interface to APMonitor. To change the moving horizon window in Moving Horizon Estimation (MHE) with APMonitor (GEKKO), you need to adjust the m.time array. This array specifies the discretized time points over which the estimation is performed. By modifying the length or resolution of the m.time array, you effectively set the size of the moving horizon window.
Example:
from gekko import GEKKO
import numpy as np
m = GEKKO()
m.time = np.linspace(0, 10, 11) # Moving horizon from 0 to 10 with 11 points
Number of Cycles
The number of cycles in MHE refers to how frequently the model is updated with new measurements. Typically, this matches the time resolution of your data and is tied to the discretization in the m.time array. For every "cycle," new measurements at the current time step are incorporated, and the horizon is shifted forward by dropping the oldest data point and adding the newest.
For automated shifting in GEKKO, you can use:
m.options.TIME_SHIFT = 1 # Enable automatic time shifting
This setting ensures that with each cycle, the time horizon shifts forward, maintaining the moving horizon framework dynamically. The frequency of measurement updates and shifting depends on the problem's setup and data availability.
If you need additional information on estimator tuning with the Python or MATLAB interface, there is more information here:
https://apmonitor.com/do/index.php/Main/EstimatorTuning Use parameters CTRL_HOR and PRED_HOR to adjust the time steps if not specifying
m.time (GEKKO) or a CSV file with
time column (APM)
Best regards,
John Hedengren