Skip to content

Fix Eigen interface: general Hessian workspace allocation and add time_limit setting - #129

Merged
darnstrom merged 2 commits into
masterfrom
copilot/improve-eigen-interface
Mar 21, 2026
Merged

darnstrom merged 2 commits into
masterfrom
copilot/improve-eigen-interface

Conversation

Copilot AI commented Mar 21, 2026 •

Copy link
Copy Markdown
Contributor

The DAQP workspace class was broken for non-identity Hessians because allocate_daqp_ldp was called with alloc_R=0, alloc_v=0, leaving work_.Rinv = nullptr. Any call to update(H, ...) with a non-identity H would crash inside daqp_update_Rinv writing to a null pointer. Additionally, the default update mask always included DAQP_UPDATE_Rinv even when H was null, causing a null dereference in the other direction.

Changes

  • Pre-allocate Rinv/v buffers — allocate_daqp_ldp now called with alloc_R=1, alloc_v=1. Two new private members rinv_buf_ / v_buf_ hold the raw pointers.

  • Buffer visibility management in update() — daqp.c uses Rinv != nullptr to detect non-identity Hessian. The buffers are exposed (work_.Rinv = rinv_buf_) only when H is provided, and hidden (nullptr) otherwise to preserve correct LDP/identity-Hessian behavior:

    DAQP solver(n, m, ns);
    solver.update(H, f, A, bu, bl, sense, bp);  // now works for any H
    solver.solve(A, bu, bl, bp);                 // LDP path still correct
  • Fix default update mask — DAQP_UPDATE_Rinv / DAQP_UPDATE_v are only added to the default mask when H / f are actually provided.

  • Destructor cleanup — restores buffer pointers into work_.Rinv before free_daqp_ldp to avoid leaking the pre-allocated memory when in LDP mode (where both Rinv and RinvD are null).

  • Add set_time_limit(double val) — mirrors all other settings setters; was the only DAQPSettings field without a corresponding setter in the Eigen interface.

  • New test 06_general_hessian — validates the workspace class with a non-identity H, comparing against the stateless daqp_solve() reference.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…e_limit setting

Co-authored-by: darnstrom <55484604+darnstrom@users.noreply.github.com>
Agent-Logs-Url: https://github.com/darnstrom/daqp/sessions/8b7553d3-d02f-431b-8f7e-691679583cea
Copilot AI changed the title [WIP] Fix eigen interface for general Hessian and add time limit setting Fix Eigen interface: general Hessian workspace allocation and add time_limit setting Mar 21, 2026
Copilot AI requested a review from darnstrom March 21, 2026 08:25
@darnstrom
darnstrom marked this pull request as ready for review March 21, 2026 09:41
@darnstrom
darnstrom merged commit 5313036 into master Mar 21, 2026
14 checks passed
@darnstrom
darnstrom deleted the copilot/improve-eigen-interface branch July 19, 2026 11:54
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.

2 participants