Replies: 3 comments
-
Hi @aabsz , yes there is a way. It a bit depends on what you want to do. If you already have the time-varying profiles of the parameters you can define them as time-varying parameters (see option 1). If you want to change them online then you can just pass the new value online (see option 2). Note that the two approaches are conceptually different but the may lead to similar (not the same!) results. This section of the documentation explains how time-varying parameters are defined. Option 1: you want to pass the time-varying parameter profilesTime-varying model parametersThe trick is defining the parameters of the model, then set these parameters as "time-varying" in controller. As an example, have a look as this pendulum subject to a sinusoidal disturbance:
Time-varying weights of the MPCThis works also for the weights of the controller: the trick is to use the parameters of the model as weights for the MPC. This is sort of a work around, because defining the parameter of the controller in the model is something that we wouldn't like to do, but it works: For example, this point mass system
Note that Option 2: you want to change the parameters/weights onlineThen it is sufficient to proceed, as before, defining the parameters of the controller/model, but you do not need to define them as time-varying. You would need only to supply the value of the parameters in the for loop as follows:
Please let me know if something is not clear or you have further questions |
Beta Was this translation helpful? Give feedback.
-
Dear Bruno, Thank you so much for the comprehensive reply. I have a question regarding "option 1: Time-varying model parameters." In your example, you have defined d[0] as a variable parameter of the dynamical model. I noticed that before setting up the NMPC model, you defined the variable parameter as follows: nmpc.set_time_varying_parameters(names=['d_tvp'], values={'d_tvp': np.sin(np.arange(0, 50, dt)).tolist()}) Then, when creating the control loop, you specified its exact value like this: model.simulate(u=u, p=[np.sin(dt * step), 0.1]) (I assume "p" is incorrect, and it should be "d." Am I correct?) In this context, you assumed that you know the values of this variable parameter beforehand. Now, my question is, what if I don't know its value in advance? How can I pass it in the simulation? Suppose that its value is calculated somewhere in my code, but I don't know how to define it when setting up the NMPC. In other words, I'm uncertain about how to define it in the following line: nmpc.set_time_varying_parameters(names=['d_tvp'], values={'d_tvp': np.sin(np.arange(0, 50, dt)).tolist()}) |
Beta Was this translation helpful? Give feedback.
-
Hi, I figured it out! |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am wondering if it is possible to implement a parameter varying MPC using hilo?
I mean, suppose that I have a learning model which adjusts the parameters of the MPC at each run. particularly:
That would be perfect if there is an example, you share with me.
Beta Was this translation helpful? Give feedback.
All reactions