Skip to content

Allow fixed entries in probability constraints#683

Open
hmgaudecker wants to merge 3 commits intomainfrom
probability-allow-fixed-entries
Open

Allow fixed entries in probability constraints#683
hmgaudecker wants to merge 3 commits intomainfrom
probability-allow-fixed-entries

Conversation

@hmgaudecker
Copy link
Copy Markdown
Member

@hmgaudecker hmgaudecker commented Apr 30, 2026

In an application, I need probability constraints where one element is fixed. This is currently rejected by optimagic; this PR fixes that.

hmgaudecker and others added 3 commits April 22, 2026 10:49
Consolidate fixed-at-zero entries out of a ProbabilityConstraint before the
kernel transformation runs, so a FixedConstraint pinning some selected
entries to 0.0 can coexist with a ProbabilityConstraint on the same
parameters. The zero-fixed entries are driven by the existing fixed-value
pipeline; the remaining free entries form a simplex summing to one.

Fixes to values other than 0.0 still raise InvalidConstraintError; that
generalisation is left for a follow-up commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Generalise the zero-fix fold: any fix in [0, 1) whose sum over the
selector is strictly less than 1 is accepted. The fold attaches
sum_target = 1 - sum(fixed_values) to the transformation dict, and
probability_from_internal and its Jacobian scale by sum_target. The pure
zero-fix path is unchanged (sum_target key omitted, semantics identical
to the no-fix path).

probability_to_internal stays untouched because x / x[-1] is scale
invariant; the internal pivot is still 1.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The zero-fix and non-zero-fix changes ship together in one PR; one
bullet describes the end-state behaviour.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hmgaudecker hmgaudecker requested a review from janosg April 30, 2026 16:22
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/optimagic/parameters/check_constraints.py 87.39% <ø> (ø)
...rc/optimagic/parameters/consolidate_constraints.py 96.86% <100.00%> (+0.36%) ⬆️
src/optimagic/parameters/kernel_transformations.py 99.18% <100.00%> (+0.01%) ⬆️

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

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.

1 participant