Ordinary differential equations are specified by differentiation a variable with the dt() method. For example, velocity v is the derivative of position x:

m.Equation(v==x.dt())

Discretization is determined by the model time attribute. For example, m.time = [0,1,2,3] will discretize all equations and variable at the 4 points specified. Only ordinary differential equations discretized by time are available internally. Other discretization must be performed manually.

Simultaneous methods use orthogonal collocation on finite elements to implicitly solve the DAE system. Non-simulation simultaneous methods (modes 5 and 6) simultaneously optimize the objective and implicitly calculate the model/constraints. Simultaneous methods tend to perform better for problems with many degrees of freedom.

Sequential methods separate the NLP optimizer and the DAE simulator. Sequential methods will satisfy the differential equations, even when the solver is unable to find a feasible optimal solution.

Simulation just solves the given equations. These modes provide little benefit over other ODE integrator packages. However, successful simulation of a model within GEKKO helps debug the model and greatly facilitates the transition from model development/simulation to optimization.

Moving Horizon Estimation is for dynamic estimation, both for states and parameter regression. The horizon to match is the discretized time horizon of the model m.time. m.time should be discretized and regular intervals. New measurements are added at the end of the horizon m.time[-1] and the oldest measurements (m.time[0]) is dropped off.

m.options.TIMESHIFT enables automatic shifting of all variables and parameters with each new solve of a model. The frequency of new measurements should match the discretization of m.time.

If FSTATUS is on (FSTATUS=1), an objective function is added to minimize the
model prediction to the measurements. The error is either squared or absolute depending
on if m.options.EV_TYPE is 2 or 1, respectively. FSTATUS enables receiving measurements
through the MEAS attribute.

If m.options.EV_TYPE = 1, CV.MEAS_GAP=v will provide a dead-band of size v around the measurement to avoid fitting to measurement noise.

Controlled variables are the objective to match. When STATUS=1 for a CV, the
objective includes a minimization between model predictions and the setpoint.

If m.options.CV_TYPE=1, the objective is an l1-norm (absolute error) with
a dead-band. The setpoint range should be specified with SPHI and SPLO.
If m.options.CV_TYPE=2, the objective is an l2-norm (squared error). The
setpoint should be specified with SP.