/**
   * Updates the lower and upper bounds for each alternative to reflect potential minimum and
   * maximum weighted results in case the provided leaves are set to their potential minimum and
   * maximum values respectively.
   *
   * @param leafSet leaves for the plan to consider
   * @param resultRanges the result ranges to update
   */
  private void updateBounds(
      final Set<VPlanLeaf> leafSet, List<AlternativeResultRange> resultRanges) {
    for (VPlanLeaf leaf : leafSet) {
      double leafMinimum = leaf.getPotentialMinimum();
      double leafMaximum = leaf.getPotentialMaximum();

      for (AlternativeResultRange resultRange : resultRanges) {
        resultRange.setLowerBound(
            resultRange.getLowerBound()
                - ((resultRange.getResult() - leafMinimum) * leaf.getTotalWeight()));
        resultRange.setUpperBound(
            resultRange.getUpperBound()
                + ((leafMaximum - resultRange.getResult()) * leaf.getTotalWeight()));
      }
    }
  }