apportion

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package apportion divides an integer total across weighted claimants.

LoadWave has to split whole virtual users — and whole iterations, and whole worker processes — across nodes whose capacities differ. Proportional division produces fractions, and naive rounding either loses or invents units. Every split in the system funnels through this package so that the same rule applies everywhere and the parts always add back up to the whole.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(total, n int) []int

Equal divides total across n claimants as evenly as possible, giving the remainder to the lowest indices.

func Largest

func Largest(total int, weights []int) []int

Largest divides total across weights using the largest remainder method.

Each claimant first receives the floor of its exact proportional share; the units left over by rounding down are then handed out one at a time, to the claimants with the largest discarded fractions. Ties break toward the lower index, which keeps the result deterministic — important, because the coordinator and the node both compute apportionments and they must agree.

The returned slice always sums to exactly total, provided total is non-negative and at least one weight is positive. A total of zero, or an empty or all-zero weight set, yields all zeros.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL