Add compute_control_result: the control together with the solver status - #117
Open
baggepinnen wants to merge 1 commit into
Open
baggepinnen wants to merge 1 commit into
baggepinnen wants to merge 1 commit into
Conversation
compute_control asserts on the exit flag and returns only the control, so a caller that must not throw (a simulation loop, a controller embedded in a larger model) has no public way to know whether the QP was actually solved (darnstrom#115). compute_control_result performs the same solve and returns a type-stable MPCResult carrying control, exitflag, status (the flag as a Symbol) and solver_info; compute_control now delegates to it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LNTSoj8uSmNpSqpRTor8di
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #117 +/- ##
==========================================
+ Coverage 89.57% 89.59% +0.01%
==========================================
Files 15 15
Lines 2389 2393 +4
==========================================
+ Hits 2140 2144 +4
Misses 249 249 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
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.
Closes #115, following the entry point suggested there.
MPCResult{I}is a plain struct (parametric on the info type so it stays type-stable);compute_control_resultperforms exactly the same solve anduprevbookkeeping ascompute_control, which now delegates to it (check = true/falsebehave as before).MPC;ExplicitMPC's tree evaluation has no solver status, so it is left out —happy to add a trivially-
:Optimalmethod if you prefer symmetry.manual/simple.md, and a testset (feasible: same control ascompute_controlon a fresh controller,:Optimal, info populated; infeasible hard outputbound:
exitflag < 1,:Primal_Infeasible, no throw, whilecompute_controlstill asserts).One observation from writing the tests, possibly worth its own issue: after an infeasible solve,
subsequent
solvecalls on the samempc.opt_modelreturnexitflag = 1withNaNcontrol —the Julia-side DAQP workspace is not reset after a failure (the generated C resets it every call).
The tests therefore use a fresh controller per assertion. That behaviour makes the status all the
more important to surface: the second call reports
:Optimalwhile returningNaN.Full test suite passes locally (Julia 1.12.7).
🤖 Generated with Claude Code
https://claude.ai/code/session_01LNTSoj8uSmNpSqpRTor8di