Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

binPack

Simple bin packing.


Description

Maps numeric items in x into groups with sum less or equal than capacity. A very simple greedy algorithm is used, which is not really optimized for speed. This is a convenience function for smaller vectors, not a competetive solver for the real binbacking problem. If an element of x exceeds capacity, an error is thrown.

Usage

binPack(x, capacity)

Arguments

x

[numeric]
Numeric vector of elements to group.

capacity

[numeric(1)]
Maximum capacity of each bin, i.e., elements will be grouped so their sum does not exceed this limit.

Value

[integer]. Integer with values “1” to “n.bins” indicating bin membership.

Examples

x = 1:10
bp = binPack(x, 11)
xs = split(x, bp)
print(xs)
print(sapply(xs, sum))

BBmisc

Miscellaneous Helper Functions for B. Bischl

v1.11
BSD_2_clause + file LICENSE
Authors
Bernd Bischl [aut, cre], Michel Lang [aut], Jakob Bossek [aut], Daniel Horn [aut], Jakob Richter [aut], Dirk Surmann [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.