Skip to contents

Solve grouping based on priorities or costs.

Usage

prioritized_grouping(
  data,
  cap_classes = NULL,
  excess_space = 20,
  pre_grouped = NULL,
  seed = 6293812
)

Arguments

data

data set in wide format. First column should be ID, then one column for each group containing cost/priorities.

cap_classes

class capacity. Numeric vector length 1 or length=number of groups. If NULL equal group sizes are calculated. Default is NULL.

excess_space

allowed excess group fill in percentage. Default is 20. Supplied group capacities will be enlarged by this factors and rounded up.

pre_grouped

Pre grouped data set. Optional. Should contain two columns, 'id' and 'group', with 'group' containing the given group index.

seed

specify a seed value. For complex problems.

Value

list of custom class 'prioritized_groups_list'

Examples

# prioritized_grouping(
# data=read.csv(here::here("data/prioritized_sample.csv")),
# pre_grouped=read.csv(here::here("data/pre_grouped.csv"))) |> plot()
data.frame(id=paste0("id",1:100),
matrix(replicate(100,sample(c(1:5,rep(NA,15)),10)),ncol=10,byrow = TRUE)) |>
prioritized_grouping()