Skip to content

Base the default error penalty on the scalar start value - #716

Open
hmgaudecker wants to merge 1 commit into
mainfrom
fix/error-penalty-scalar-default
Open

hmgaudecker wants to merge 1 commit into
mainfrom
fix/error-penalty-scalar-default

Conversation

@hmgaudecker

Copy link
Copy Markdown
Member

Closes #715.

With error_handling="continue", the default error penalty was built from start_criterion.internal_value(solver_type). For least-squares and likelihood solvers that is a vector, so:

  • least squares: the first failing evaluation raised InvalidFunctionError instead of being penalized;
  • likelihood: the penalty landed at the wrong level.

The default constant is now computed from the scalar start value for every aggregation level. The new test checks that, without explicit error_penalty options, the likelihood and least-squares penalties equal the scalar penalty of the same start value. It fails on main for both.

https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW

For least-squares and likelihood solvers the default penalty constant was
built from the start criterion's residual or contribution vector, so it
became an array: a least-squares penalty raised InvalidFunctionError and a
likelihood penalty landed at the wrong level. The default now derives from
the scalar start value for every aggregation level.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/optimagic/optimization/error_penalty.py 96.29% <100.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hmgaudecker
hmgaudecker requested a review from janosg October 16, 2026 16:51

This branch has not been deployed

No deployments
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.

error_handling="continue" fails for least-squares objectives: default penalty constant is a vector

1 participant