Hi everyone!
I've implemented an MPC controller for my plant in GRAMPC, which is working alright for now, but I want to tune the parameters to get a better performance.
Is there a method, that some of you used for your plants that worked well? Or is there a method you know about for gradient based MPCs in general that I should have a look at? Hopefully some of you have some experience and tips for MPC tuning!
Also, I noticed that by increasing the prediction horizon, the system tends to get unstable, although I thought that with a bigger prediction horizon, the controller would improve... I can attach my files if necessary, however I an not quite finished yet, as I plan to extend the MPC to a Lyapunov-MPC (hence I have no terminal cost), just so you know. Some infomation about the controller: It's an formation controller for satellite formations, so it controls the relative position of one satellite to another. The sample time is quite big as the actuators are very slow and not so powerful.
there is no easy step-by-step guide for MPC tuning, since it is usually problem-specific. I would recommend reading the GRAMPC manual, in particular section 4 on the optimization algorithm and the options as well as section 6. Regarding the choice of the prediction horizon, it is true that a longer horizon should be better for the MPC, however, the numerical solution of the optimal control problem is more challenging for longer horizons.
Are all states and controls in the same order of magnitude? If not, consider scaling the problem such that all states and controls are, for example, in the range [-1, 1].
Choose the sampling time and the initial prediction horizon based on your knowledge of the system. The horizon sould be long enough that it captures the relevant dynamics.
Choose the integrator and the number of discretization steps such that the forward and backward integration is sufficiently accurate. Start with a single gradient iteration and inspect the trajectories. I often start with the Heun-method and 20-30 discretization steps. Note that GRAMPC does not require that dt matches Thor / Nhor. Some problems require variable step-size integrators like ruku45 or rodas, for others a simple Euler-scheme is sufficient.
Deactivate all constraints, choose the number of gradient iterations and the line search type (often 'explicit2' is a good choice) such that the cost function is decreasing along the MPC time steps. In some cases it may be necessary to change the default values for the maximum step size (LineSearchMax) and the fallback step size (LineSearchInit).
If the solution of the unconstrained problem is satisfactorily, activate your constraints (g, h, gT, hT). Start with a single multiplier iteration per sampling step. Choose the minimal penalty parameter (PenaltyMin) such that the typical value of the cost function is in the same order of magnitude as PenaltyMin times the squared typical constraint violation. Follow the steps in section 6.5 of the GRAMPC manual regarding constraint tuning.
I noticed in your probfct that you have a rate constraint, i.e. a constraint that |d/dt u(t)| < limit. In this case, I would consider adding additional integrators \dot u = v to the dynamics, such that the rate limit can be handled via the projection method. The constraint u \in [umin, umax] must then be treated as state constraint.
Regards,
Andreas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm currently facing an issue executing a file in MATLAB, and I'm seeking some assistance. Despite installing GCC as a compiler, I'm encountering difficulties compiling the file properly. I've ensured that MATLAB recognizes the directory containing the file and configured MATLAB to use the GCC compiler. However, despite these efforts, the file isn't executing as expected.
Could anyone offer some guidance or troubleshooting tips to help resolve this issue? Any insights or suggestions would be greatly appreciated. I am using Matlab in windows.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
if it is only a MATLAB+GCC issue without relation to GRAMPC, then you better ask for help in another place. However, if it is clearly related to GRAMPC, we can of course help you here. To this end, you should describe in detail what you have done and what are the error messages that you get.
Best regards,
Andreas Völz
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everyone!
I've implemented an MPC controller for my plant in GRAMPC, which is working alright for now, but I want to tune the parameters to get a better performance.
Is there a method, that some of you used for your plants that worked well? Or is there a method you know about for gradient based MPCs in general that I should have a look at? Hopefully some of you have some experience and tips for MPC tuning!
Also, I noticed that by increasing the prediction horizon, the system tends to get unstable, although I thought that with a bigger prediction horizon, the controller would improve... I can attach my files if necessary, however I an not quite finished yet, as I plan to extend the MPC to a Lyapunov-MPC (hence I have no terminal cost), just so you know. Some infomation about the controller: It's an formation controller for satellite formations, so it controls the relative position of one satellite to another. The sample time is quite big as the actuators are very slow and not so powerful.
Thanks in advance and best regards!
Hello Lisa,
there is no easy step-by-step guide for MPC tuning, since it is usually problem-specific. I would recommend reading the GRAMPC manual, in particular section 4 on the optimization algorithm and the options as well as section 6. Regarding the choice of the prediction horizon, it is true that a longer horizon should be better for the MPC, however, the numerical solution of the optimal control problem is more challenging for longer horizons.
I noticed in your probfct that you have a rate constraint, i.e. a constraint that |d/dt u(t)| < limit. In this case, I would consider adding additional integrators \dot u = v to the dynamics, such that the rate limit can be handled via the projection method. The constraint u \in [umin, umax] must then be treated as state constraint.
Regards,
Andreas
Hey everyone,
I'm currently facing an issue executing a file in MATLAB, and I'm seeking some assistance. Despite installing GCC as a compiler, I'm encountering difficulties compiling the file properly. I've ensured that MATLAB recognizes the directory containing the file and configured MATLAB to use the GCC compiler. However, despite these efforts, the file isn't executing as expected.
Could anyone offer some guidance or troubleshooting tips to help resolve this issue? Any insights or suggestions would be greatly appreciated. I am using Matlab in windows.
Dear Raahul,
if it is only a MATLAB+GCC issue without relation to GRAMPC, then you better ask for help in another place. However, if it is clearly related to GRAMPC, we can of course help you here. To this end, you should describe in detail what you have done and what are the error messages that you get.
Best regards,
Andreas Völz