DISTRIBUTE
- DISTRIBUTE(value, array)[source]
Distributes an integer value across a series of buckets with defined capacities.
DISTRIBUTE allocates the input value to the buckets in a left-to-right manner, filling each bucket up to its specified capacity before moving to the next.
- Parameters:
value (
Operand|int) –The total value to distribute. Can be an integer constant or a model object of type INTEGER.
Supported types:
INTEGER
array (
Operand) –The bucket capacities. Must be an integer array where each element represents a bucket’s maximum capacity.
Supported types:
INTEGER_ARRAY
- Return type:
- Returns:
A formula object evaluating to an integer array where each element indicates the portion of value allocated to the corresponding bucket. The array length matches the input bucket array length.
Supported types:
INTEGER_ARRAY
- Raises:
ValueError – If value is not an INTEGER
ValueError – If array is not an INTEGER_ARRAY
Examples
Basic full distribution:
DISTRIBUTE(10, [5, 3, 2]) # Returns [5, 3, 2] # Explanation: # 5 goes to first bucket (capacity 5) # 3 goes to second bucket (capacity 3) # 2 goes to third bucket (capacity 2)
Partial filling:
DISTRIBUTE(7, [5, 3, 2]) # Returns [5, 2, 0] # Explanation: # 5 goes to first bucket # 2 goes to second bucket (capacity 3, only 2 remaining) # third bucket remains empty