Skip to content
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

Efficient factorization of diagonal outer Hessian in convex-over-nonlinear and nonlinear least-squares costs #1024

Merged
merged 24 commits into from
Mar 14, 2024

Conversation

sandmaennchen
Copy link
Contributor

@sandmaennchen sandmaennchen commented Jan 17, 2024

  • add flags indicating whether outer hessian is diagonal
  • if outer hessian is diagonal and ny > 4, its diagonal Cholesky factorization W_chol is computed manually and stored as blasfeo_dvec
  • adjust matrix-matrix/matrix-vector multiplications involving W_chol accordingly

acados/ocp_nlp/ocp_nlp_cost_conl.c Fixed Show fixed Hide fixed
acados/sim/sim_irk_integrator.c Fixed Show fixed Hide fixed
acados/ocp_nlp/ocp_nlp_cost_conl.c Fixed Show fixed Hide fixed
acados/sim/sim_irk_integrator.c Fixed Show fixed Hide fixed
@sandmaennchen sandmaennchen changed the title Efficient factorization of diagonal outer Hessian in convex-over-nonlinear costs Efficient factorization of diagonal outer Hessian in convex-over-nonlinear and nonlinear least-squares costs Feb 2, 2024
Copy link
Member

@FreyJo FreyJo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through the code and left some comments.

// hessian of outer loss function
blasfeo_dpotrf_l(ny, &work->W, 0, 0, &memory->W_chol, 0, 0);
// factorize hessian of outer loss function
// TODO: benchmark whether sparse factorization is faster
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that now that we are only storing the diagonal as a vector it should be always more efficient.
Then we can remove this TODO.
@giaf do you agree?

acados/ocp_nlp/ocp_nlp_cost_nls.c Outdated Show resolved Hide resolved
acados/sim/sim_irk_integrator.h Outdated Show resolved Hide resolved
@FreyJo
Copy link
Member

FreyJo commented Mar 14, 2024

I made a small comparison with these settings:

PendulumOcpOptions(
    qp_solver="FULL_CONDENSING_DAQP",
    cost_variant="CONL_LARGE",
    # cost_variant="CONL",
    nlp_solver="SQP_RTI",
    cost_discretization="INTEGRATOR",
    integrator_type="IRK",
    N=50
)

For cost_variant="CONL", with ny=nx+nu=5, there is no speedup:
cost_commit_comparison
For cost_variant="CONL", with ny=2*(nx+nu), there is a big speedup:
cost_commit_comparison_conl_large

Thus, I set outer_hess_is_diag = 0 if ny <= 4, in the last commit.

Copy link
Member

@FreyJo FreyJo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will make cost integration for medium+ sized problems much faster.
Great collaboration again 📈

@FreyJo FreyJo merged commit c52c283 into acados:master Mar 14, 2024
5 checks passed
@FreyJo FreyJo deleted the diag_flag branch March 14, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants