Skip to content

Implement logic to optimize computation for unconstrained optimum#131

Merged
darnstrom merged 9 commits intomasterfrom
copilot/implement-unconstrained-optimum-logic
Mar 21, 2026
Merged

Implement logic to optimize computation for unconstrained optimum#131
darnstrom merged 9 commits intomasterfrom
copilot/implement-unconstrained-optimum-logic

Conversation

Copy link
Contributor

Copilot AI commented Mar 21, 2026

  • Understand the codebase and plan the implementation
  • Add fast path for unconstrained-optimal case, fix sign errors in feasibility check
  • Fix missing reuse_ind = 0 reset when unconstrained check fails: without it, daqp_compute_CSP reuses stale intermediate results from the prior solve, yielding a wrong primal and incorrect result
  • All 21 Python tests pass
  • Benchmark results (30 problems × 10 repeats, median):
Case Setup (ms) Solve (ms) Total (ms) Iters vs master
n=100,m=1000, unc-optimal 0.49 0.00 0.51 1 14.7×
n=100,m=1000, constrained 4.05 4.64 12.74 114 1.1×
n=20,m=200, unc-optimal 0.006 0.000 0.011 1 4.5×
n=20,m=200, constrained 0.041 0.040 0.086 22 1.0×

Master reference: n=100,m=1000 unc=7.535ms con=13.515ms; n=20,m=200 unc=0.047ms con=0.085ms


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI self-assigned this Mar 21, 2026
Co-authored-by: darnstrom <55484604+darnstrom@users.noreply.github.com>
Agent-Logs-Url: https://github.com/darnstrom/daqp/sessions/7f4b0f24-9750-41b4-9362-4b471d6158d1
@darnstrom
Copy link
Owner

@copilot try again

…e_ldp and daqp_solve

Co-authored-by: darnstrom <55484604+darnstrom@users.noreply.github.com>
Agent-Logs-Url: https://github.com/darnstrom/daqp/sessions/d3cd695e-642b-4fb2-b020-a91222e5017c
Copy link
Contributor Author

Copilot AI commented Mar 21, 2026

@copilot try again

Done. The implementation is now complete in commit 1bce5b9:

  • include/types.h: Added unconstrained_optimal flag to DAQPWorkspace.
  • src/api.c: Initializes the flag to 0 in allocate_daqp_workspace; in daqp_solve, when the flag is set, skips the LDP solver, resets fval/n_active/soft_slack, calls ldp2qp_solution directly, and returns DAQP_EXIT_OPTIMAL.
  • src/utils.c: In daqp_update_ldp, v is now computed before M. After computing v, x_unc = -Rinv·v (the unconstrained optimum) is evaluated against all simple bounds and general constraints. If feasible, unconstrained_optimal=1 is set, Rinv is normalized, and the function returns early — skipping the expensive daqp_update_M call.

All 17 existing Python tests pass, and targeted tests confirm: the unconstrained path yields 0 iterations and correct primal/dual objective values; infeasible-unconstrained cases fall through to the normal active-set solver.

Copilot AI changed the title [WIP] Implement logic to optimize computation for unconstrained optimum Implement logic to optimize computation for unconstrained optimum Mar 21, 2026
…nd inverted check direction

Co-authored-by: darnstrom <55484604+darnstrom@users.noreply.github.com>
Agent-Logs-Url: https://github.com/darnstrom/daqp/sessions/79ab7e71-e7a4-4c63-a486-0f75ec3760d9
@darnstrom darnstrom marked this pull request as ready for review March 21, 2026 21:37
@darnstrom darnstrom merged commit 49bc140 into master Mar 21, 2026
17 of 20 checks passed
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