Repository navigation
Return a status from the postsolve functions - #140
Merged
Merged
Conversation
postsolve, map_original_sol_to_reduced, postsolve_primal_infeas_ray and postsolve_dual_infeas_ray were void and reported a failure (out of memory, unsupported problem, call after free_presolver_reduced_problem) only by printing to stderr. A program that embeds PSLP could neither route that text nor detect the failure (#133). They now return bool, true on success. The reason for a failure is printed to stdout and only when 'verbose' is set, so a release build no longer writes to stderr from these functions. Also: - map_original_sol_to_reduced: an output requested without its input is a precondition (assert) and no longer a runtime warning. - postsolve_primal_infeas_ray: a failed scratch allocation returns false instead of dereferencing NULL in a release build. - The "Maximum time limit reached" line is printed only when 'verbose' is set. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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 #133 (its second part; the first part was #137).
postsolve,map_original_sol_to_reduced,postsolve_primal_infeas_rayandpostsolve_dual_infeas_raywerevoidand reported a failure only by printing tostderr. A program that embeds PSLP could neither route that text nor detect that the outputs were left untouched.What changes
bool, true on success. Existing callers that ignore the result compile and behave as before. The failure conditions are listed in the comments ofPSLP_API.h.stderrfrom these functions. The reason for a failure is printed tostdout, and only whenverboseis set, like the rest of PSLP's output.map_original_sol_to_reduced: requesting an output without its input (x_redwithoutx,y_redwithouty,z_redwithouty_red) is now a documented precondition checked withassert, where it used to print a warning and skip that output. Skipping a part by passingNULLoutputs still works.postsolve_primal_infeas_ray: a failed scratch allocation returns false. Before, a release build dereferencedNULL.verboseis set. It used to be printed always.With
verboseoff, the only remaining output of a release build is theexit(1)path of #139.Not in this PR
postsolve,Settings,INFEASIBLE, ...): Prefix the public API (functions, types and status constants) #138.exit(1)when a vector cannot grow: Do not call exit(1) when an allocation fails #139.Testing
On macOS: Debug and Release, shared and static, with
PSLP_BUILD_TESTING=ON: all tests pass and the exported-symbol check passes. The tests of the failure paths (ray postsolve with a fold, with cone blocks and afterfree_presolver_reduced_problem; the map for a QP and forz_redafter the reduced problem was freed) now assert the false return, and representative success paths assert true. The test binary writes nothing tostderr.🤖 Generated with Claude Code