Skip to content
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 into
SciML:masterfrom
ChrisRackauckas-Claude:investigate-issue-5
Jan 9, 2026
Merged

Add error reduction function for selective component error calculation#175
ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:investigate-issue-5

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor

Summary

This implements the feature requested in issue #5, allowing users to specify a custom reduction function 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

  • 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

# 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])

# Compute error on a function of the solution
shoot = Shootout(prob, setups; 
    appxsol = test_sol, reduction = x -> sum(x))

Test Results

Testing error reduction feature...
✓ default_reduction export test passed
✓ appxtrue default test passed
✓ appxtrue custom reduction test passed
✓ appxtrue TestSolution test passed
✓ WorkPrecision reduction test passed
✓ WorkPrecisionSet reduction test passed
✓ Shootout reduction test passed

Error values with different reductions:
  Default (all components): final = 3.195463769811724e-6
  First component only:     final = 5.23092241744294e-6
  Second component only:    final = 1.1600051221805074e-6

✓ All error reduction tests passed!

Test plan

  • Verify default_reduction is identity function
  • Test appxtrue with TestSolution and AbstractODESolution
  • Test WorkPrecision with custom reduction
  • Test WorkPrecisionSet with custom reduction
  • Test Shootout with custom reduction
  • Verify different reductions produce different error values

Closes #5

@ChrisRackauckas - Please review this implementation.

🤖 Generated with Claude Code

claude added 2 commits January 7, 2026 19:27
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>
@ChrisRackauckas-Claude

Copy link
Copy Markdown
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.

@ChrisRackauckas ChrisRackauckas merged commit c94cf12 into SciML:master Jan 9, 2026
3 of 6 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error reduction function

3 participants