dimanche 29 octobre 2023

Generate random table assignments in R

Here's a challenge that I thought would be easier than it is... I'm looking for an algorithm (ideally in R) that can generate random table assignments for a conference workshop I will be hosting. I have a list of participants with an affiliation, such as:

participants <- c(
  person("Rishi", "Sunak", comment = "Conservative"),
  person("Liz", "Truss", comment = "Conservative"),
  person("Boris", "Johnson", comment = "Conservative"),
  person("Theresa", "May", comment = "Conservative"),
  person("David", "Cameron", comment = "Conservative"),
  person("Gordon", "Brown", comment = "Labour"),
  person("Tony", "Blair", comment = "Labour"),
  person("Kier", "Starmer", comment = "Labour"),
  person("Jeremy", "Corbyn", comment = "Labour"),
  person("Ed", "Milliband", comment = "Labour")
  # Plus about 50 more delegates
)

We have a (TBD likely 5ish) number of tables, where the participants will each rotate: n_tables. There will be the same number of rotations, so each participant goes to each table once.

I am looking for a randomisation sequence that does the following:

  1. Randomises each participant to each table once
  2. Ensures the total number of participants on each table is balances - i.e. similar number on each table
  3. Balances the affiliations on each table to be approximately equal to the overall balance (note there will be about 4). So no tables all labour for example.
  4. Attempts to assign participants in such a way that they come into contact with as many of the other participants as possible over the whole session (i.e. not create one assignment then rotate)



Aucun commentaire:

Enregistrer un commentaire