Skip to content

Conversation

@hakonhagland
Copy link
Contributor

@hakonhagland hakonhagland commented Dec 13, 2025

Fixes a bug in the efficiency factor addback part of the group constraint checking. The addback calculation at local_reduction_level was using the accumulated efficiency factor (from entity to control group) instead of the partial efficiency factor (from entity to local_reduction_level).

This might cause incorrect constraint violations when checking higher-level group constraints. The fix computes the partial efficiency by multiplying efficiency factors from local_reduction_level down to the entity. Also added a test case to demonstrate the issue, see the first commit of this PR.

This test exposes a bug in GroupStateHelper::checkGroupConstraintsProd()
where the addback calculation uses the accumulated efficiency factor
instead of the partial efficiency factor at local_reduction_level.

Test setup:
- Group hierarchy: FIELD -> PLAT (E=0.9) -> MANI (E=0.8) / MANI2 (E=0.7)
- MANI has individual ORAT control, PLAT has guide rate
- WELL-A produces 10000 SM3/day under MANI

The bug causes:
- Addback uses 0.72 (E_MANI * E_PLAT) instead of 0.8 (E_MANI)
- This results in scale = 0.9465 (false constraint violation)
- Correct calculation would give scale = 1.0288 (no violation)

The test currently passes with the buggy expected values. A subsequent
commit will fix the bug and update the test expectations.
@hakonhagland hakonhagland added manual:irrelevant This PR is a minor fix and should not appear in the manual manual:bugfix This PR is a bug fix and should be noted in the manual and removed manual:irrelevant This PR is a minor fix and should not appear in the manual labels Dec 13, 2025
@hakonhagland
Copy link
Contributor Author

jenkins build this please

1 similar comment
@hakonhagland
Copy link
Contributor Author

jenkins build this please

The addback calculation at local_reduction_level was using the
accumulated efficiency factor (from entity to control group) instead
of the partial efficiency factor (from entity to local_reduction_level).

This caused incorrect constraint violations when checking higher-level
group constraints. The fix computes the partial efficiency by multiplying
efficiency factors from local_reduction_level down to the entity.
@hakonhagland
Copy link
Contributor Author

jenkins build this please

@hakonhagland hakonhagland requested a review from totto82 December 16, 2025 14:40
Copy link
Member

@totto82 totto82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Also, thanks for adding a test. I did not see any issues in the code. If there are no other comments from others, I will merge this later today.

@GitPaean
Copy link
Member

I am not reviewing the PR. Just want to make sure Jenkins runs fine.

@GitPaean
Copy link
Member

jenkins build this please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:bugfix This PR is a bug fix and should be noted in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants