This repository was archived by the owner on May 12, 2026. It is now read-only.
Add error reduction function for selective component error calculation#175
Merged
ChrisRackauckas merged 2 commits intoJan 9, 2026
Merged
Conversation
This implements the feature requested in issue SciML#5, allowing users to specify a custom reduction function to compute errors only on specific components of a solution rather than all components. Changes: - Add `default_reduction` function (identity) as the default behavior - Add `reduction` keyword argument to `appxtrue` functions (both TestSolution and AbstractODESolution variants) - Pass `reduction` through to `WorkPrecision`, `WorkPrecisionSet`, `Shootout`, `ShootoutSet`, and `analyticless_test_convergence` functions - Add comprehensive tests for the reduction functionality - Export `default_reduction` for user extensibility Example usage: ```julia # Compute error only on the third component of a system errsol = appxtrue(sol, ref_sol; reduction = x -> x[3]) # Compute error only on first two components wp = WorkPrecision(prob, alg, abstols, reltols; appxsol = test_sol, reduction = x -> x[1:2]) ``` Closes SciML#5 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…oid passing it to solve
Contributor
Author
|
I have fixed the issue where the keyword was being passed to in for . This was because was not explicitly captured in the function signature for (unlike other methods). I have also applied the reduction function to the error calculation in that method for consistency. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
This implements the feature requested in issue #5, allowing users to specify a custom
reductionfunction to compute errors only on specific components of a solution rather than all components.This addresses the use case where users want to measure error only on specific indices (e.g., the third component of a system like the Quorum Sensing problem mentioned in the issue).
Changes
default_reductionfunction (identity) as the default behaviorreductionkeyword argument toappxtruefunctions (bothTestSolutionandAbstractODESolutionvariants)reductionthrough toWorkPrecision,WorkPrecisionSet,Shootout,ShootoutSet, andanalyticless_test_convergencefunctionsdefault_reductionfor user extensibilityExample Usage
Test Results
Test plan
default_reductionis identity functionappxtruewithTestSolutionandAbstractODESolutionWorkPrecisionwith custom reductionWorkPrecisionSetwith custom reductionShootoutwith custom reductionCloses #5
@ChrisRackauckas - Please review this implementation.
🤖 Generated with Claude Code