Converts a vector of fractional probabilities into integer counts while preserving the required total number of agents.
Details
Because synthetic agents cannot be subdivided, direct multiplication of fractions by a target population size generally produces non-integer values. Simple rounding can also lead to totals that differ from the desired population size.
This function applies an iterative correction procedure that:
Calculates initial rounded counts.
Compares the resulting total with the desired population size.
Identifies the category with the largest rounding discrepancy.
Adjusts counts until the desired total is reached.
The returned counts always sum to
n_agents_total.
The allocation procedure attempts to preserve the supplied proportions as closely as possible while maintaining an integer-valued solution.
This function is used throughout the package wherever fractional distributions must be converted into agent-level assignments.
It is used by:
Conditional attribute assignment workflows
