-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Real-Time Iterations (RTI) for Nonlinear MPC and Moving Horizon Estimation #140
Comments
Implementing RTI with a generic choice of solver is very difficult. In particular, it is not feasible when using Ipopt. If you read the papers you're citing closely, you see that they use a very particular and purpose-built solver. |
RTI would be in long term goals. And yeah it's not clear how to implement this feature using the generic solver-independent interface of JuMP. In the midterm and shorterm, there is other enhancement that should improve the NMPC speed:
|
I can try to work on this myself, but it would be much appreciated if I could get some help pointing me in the right direction. I can implement the RTI specific solver. But then it maybe doesn't make sense to register this solver to JuMP, because the RTI isn't solver-independent anyways? |
I would not attempt to implement such a solver, it is an absolutely enormous task if you'd like it to be anything but a toy. If you need this, I'd use acados instead. There's a proof of concept interface here |
Thanks, I will try using acados! |
Do you know what aspect of your problem makes it too slow? Is it very large state dimension, is it stiff, does it have complicated constraints etc.? |
It is a stiff ODE (stiff tether segments simulation). |
In that case it might be sufficient to use an integration method for stiff solvers, which would avoid having to take super small steps. Oftentimes, trapezoidal integration is sufficient, the simplest method that's able to handle stiff systems. |
Yeah that's what Matlab uses by default for |
You need a way to differentiate through the root find for it to be efficient. SimpleNonlinearSolve.jl defines the required chain rules for this to work using the implicit function theorem |
Alright thanks I'll try to implement a new solver during the Christmas holiday! |
The most efficient way to implement trapezoidal discretization tends to be to implement it as constraints to IPOPT. This way, you don't need any external root finder, Ipopt will handle everything through the constraints |
Oh I did not though of that! That's also great since no other additional dependency. But that would also means that open-loop simulations the a While I'm at it, I would need to use another ODE solver for the edit: maybe adding a lightweight nonlinear root solver package as a new dependency, but using it only for open loop simulations and for the state estimtator 🤔 |
Yeah, the state estimator would need a root solver. Open loop simulation could use the same transcription as when doing optimization, but with x as the only desicion variables and u fixed. Ipopt could then solve this as a pure constraint satisfaction problem. You could in principle do this in the state estimator as well, but it would perhaps feel a bit heavyweight for a single step integration |
@1-Bart-1 you can try to pull the |
It would be amazing if we could implement the algorithms for Real-Time Iterations for Nonlinear MPC and MHE from this paper: https://scholar.google.no/citations?view_op=view_citation&hl=en&user=38fYqeYAAAAJ&citation_for_view=38fYqeYAAAAJ:RYcK_YlVTxYC
From the paper:
"Real-time methods for MPC and MHE such as the RTI exploit
the similarity of the NLPs underlying the MPC and MHE from one
sampling time to the next. Indeed, for a reasonably high sampling
frequency, the parameters (estimated states and parameters) en-
tering the NLPs do not change significantly from one time sample
to the next, and the resulting solutions to the NLPs are very similar.
The solution of the NLP at a sampling time T_i is therefore used as
an initial guess for the solution of the NLP at the next time instant
T_(i+1) with the aim to maintain a fast rate of convergence at all time
instants. In that context, the RTI scheme relies on taking a single
Newton-type iteration at every time instant, always based on the
latest system information. Consequently, the method produces
locally sub-optimal solutions. Careful initialization strategies with
shifting and initial value embedding ensure that the good con-
traction properties of the Newton-type iterations are preserved"
This solution solves the problem where Nonlinear MPC is slower than the system's sample time, which is a common challenge in many control applications (for example: https://discourse.julialang.org/t/how-fast-does-a-model-has-to-be-for-nmpc/120694).
The text was updated successfully, but these errors were encountered: