Skip to content

Conversation

@hakonhagland
Copy link
Contributor

Depends on #6703 which should be merged first.

Extract duplicated target calculation algorithm from four methods into two reusable helper methods:

  • getLocalReductionLevel_(): Finds the deepest level in the group chain where a group has both a guide rate and group-controlled wells (GCW > 0)
  • applyReductionsAndFractions_(): Applies local reductions, add-back (when applicable), and guide rate fractions to calculate the portion of a top-level group target assigned to a bottom group.

The refactored methods are:

  • checkGroupConstraintsInj()
  • checkGroupConstraintsProd()
  • getWellGroupTargetInjector()
  • getWellGroupTargetProducer()

This is a pure refactoring with no functional change. The helper methods use templates for the reduction and fraction lambdas to avoid std::function overhead in case of performance-critical code.

This commit extends the test_group_higher_constraints test suite with:

1. Extended hierarchy: Added MANI-2 group (with WELL-B) under PLAT to
   create realistic group competition scenarios where fractions < 1.0.
   The new hierarchy is:

     FIELD -> PLAT -> MANI -> WELL-A, WELL-A2
                   -> MANI-2 -> WELL-B
           -> PLAT-2 -> WELL-C

2. New tests for getWellGroupTargetProducer():
   - TestWellGroupTargetProducerIndividualControl: WELL-A under ORAT
   - TestWellGroupTargetProducerGrupControl: WELL-A under GRUP
   - TestWellGroupTargetProducerWithSiblingIndividualControl: WELL-A
     under GRUP with sibling WELL-A2 under ORAT (demonstrates case
     where reduction != addback)

3. Updated existing tests:
   - TestGroupHigherConstraintsWithGuideRate: scale now 0.922 (was 1.39)
   - TestGroupHigherConstraintsProdWithoutGuideRate: scale now 0.901
@hakonhagland hakonhagland added the manual:irrelevant This PR is a minor fix and should not appear in the manual label Jan 4, 2026
@hakonhagland
Copy link
Contributor Author

jenkins build this please

@hakonhagland
Copy link
Contributor Author

jenkins build this please

Extract duplicated target calculation algorithm from four methods
into two reusable helper methods:

- getLocalReductionLevel_(): Finds the deepest level in the group chain
  where a group has both a guide rate and group-controlled wells (GCW > 0)

- applyReductionsAndFractions_(): Applies local reductions, add-back
  (when applicable), and guide rate fractions to calculate the portion
  of a top-level group target assigned to a bottom group

The refactored methods are:
- checkGroupConstraintsInj()
- checkGroupConstraintsProd()
- getWellGroupTargetInjector()
- getWellGroupTargetProducer()

This is a pure refactoring with no functional change. The helper methods
use templates for the reduction and fraction lambdas to avoid std::function
overhead in case of performance-critical code.
@hakonhagland
Copy link
Contributor Author

jenkins build this please

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

Labels

manual:irrelevant This PR is a minor fix and should not appear in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant