-
Notifications
You must be signed in to change notification settings - Fork 280
QP warm-start in first NLP solver iteration #1428
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
giaf
reviewed
Feb 4, 2025
feb3675
to
72876fb
Compare
Looks good! |
FreyJo
added a commit
that referenced
this pull request
Feb 11, 2025
… more (#1432) ### Added `setup_qp_matrices_and_factorize()`: ``` This function sets up the QP and factorizes Hessian matrix. The current NLP iterate is used to setup the QP iterate, which includes t-slacks. The t and lambda values are clipped according to `solution_sens_qp_t_lam_min` to avoid ill-conditioning. Then the Hessian matrix is factorized. If a two-solver approach is used to obtain solution sensitivities from acados, this function should be called before calling `eval_solution_sensitivity`, or `eval_adjoint_solution_sensitivity()`. This is only implemented for HPIPM QP solver without condensing. ``` ### Key differences of using `setup_qp_matrices_and_factorize()` vs. `solve()` in the two-solver approach: - The QP solver does not need to perform multiple IP iterations to converge and only a single Riccati factorization is performed at the current iterate. - In the chain example this reduces the "Median time to factorize exact Hessian QP:" 450.000 ms to 117.000 ms -> roughly 4x faster 🚀 - In the `solve()`-approach, the Riccati factorization at the second last QP iterate is used, as the system i 6D83 s not factorized at the final QP iterate. However, for the final iterate the system of equations becomes typically ill-conditioned, which is why the final iterate is modified, by clipping the inequality multipliers and t slacks, see option `solution_sens_qp_t_lam_min`. - Less options that have to be set. The options that were needed to use the `solve` approach are now commented: ``` # Old settings needed, when calling solve() instead of setup_qp_matrices_and_factorize() # ocp.solver_options.globalization_fixed_step_length = 0.0 # to not perfrom an SQP step update # ocp.solver_options.nlp_solver_max_iter = 1 # ocp.solver_options.qp_solver_iter_max = 200 # ocp.solver_options.tol = 1e-10 # to "force" a QP solve ``` ### How it works The option `update_fact_exit` was added in HPIPM. This option being active, plus the warm start, plus limiting the QP solver iterations to 0, results in the correct behavior. ### Other things that changed in this PR - fixed warm-starting QP from NLP iterate, was not correctly implemented in #1428, as the QP iterate needs to be condensed and eliminated degrees of freedom need to be taken into account. Only for N==N2 condensing right now, to be extended #1433
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implement option
nlp_solver_warm_start_first_qp_from_nlp
, if True first QP will be initialized using values from NLP iterate, otherwise from previous QP solution, only relevant ifnlp_solver_warm_start_first_qp
is True. Default: False.The new initialization (with
nlp_solver_warm_start_first_qp = True
) is likely beneficial.We might change the default behavior after more testing.
Fixed option
warm_start_first_qp
for SQP-RTI.