You have probably found an answer by now, but the set_initial_guess
function of the estimator suggests that you can assign values to the opt_x_num
variable directly:
def set_initial_guess(self):
"""..."""
assert self.flags['setup'] == True, 'mhe was not setup yet. Please call mhe.setup().'
self.opt_x_num['_x'] = self._x0.cat/self._x_scaling
self.opt_x_num['_u'] = self._u0.cat/self._u_scaling
self.opt_x_num['_z'] = self._z0.cat/self._z_scaling
self.opt_x_num['_p_est'] = self._p_est0.cat/self._p_est_scaling
self.flags['set_initial_guess'] = True
In particular, the above code samples sets each opt_x_num
component to an instance of DM
(from casadi
). The values are computed using the x0
, u0
, etc. variables. As the docstrings suggest:
Uses the current class attributes :py:obj:x0
, :py:obj:z0
and :py:obj:u0
, :py:obj:p_est0
to create an initial guess for the MHE.
you can set the initial guess contents by setting the x0
, u0
, etc. variables. For example, you can call something like:
self._controller.x0 = np.array([100, 200, 0, 0])
self._controller.set_initial_guess()
Finally, you can ask for further help by opening a GitHub discussion - https://github.com/do-mpc/do-mpc/discussions