smartgrid.util.bounded.increase_bounded¶
- smartgrid.util.bounded.increase_bounded(original_quantity, amount, upper_bound)[source]¶
Increase a bounded quantity by an amount, enforcing an upper bound.
- Parameters:
original_quantity – The original quantity, before we increase it. It must be a number, e.g., int or float.
amount – The amount we want to add to
original_quantity
. The actual increase may be lower than this (because of the constraints), but cannot be higher. It must be a number, e.g., int or float, which can be added to the quantity (compatible types).upper_bound – The upper bound we want to enforce on the quantity. The new quantity is guaranteed to be lower or equal to this bound.
- Return type:
- Returns:
new_quantity – The new value of the quantity, after the increase.
actual_amount – The actual amount that was added to the
original_quantity
, i.e.,original_quantity + actual_amount = new_quantity
.overhead – The quantity that could not be added (because it would have exceeded the bound), i.e.,
actual_amount + overhead = amount
.