How would one provide a solution to this in R using ompr (or alternative package)?
This is a basic data sample:
participant---timeslot---topic---preference
dave_smith, 09:05-10:05, topic1, very interested
dave_smith, 09:05-10:05, topic2, interested
dave_smith, 09:05-10:05, topic3, not interested
dave_smith, 09:05-10:05, topic4, interested
dave_smith, 11:05-12:05, topic5, very interested
dave_smith, 11:05-12:05, topic6, very interested
dave_smith, 11:05-12:05, topic7, not interested
dave_smith, 13:05-14:05, topic8, mandatory
dave_smith, 13:05-14:05, topic9, interested
dave_smith, 13:05-14:05, topic10, not interested
ellie_ghadia, 09:05-10:05, topic1, interested
ellie_ghadia, 09:05-10:05, topic2, not interested
ellie_ghadia, 09:05-10:05, topic3, mandatory
ellie_ghadia, 09:05-10:05, topic4, very interested
ellie_ghadia, 11:05-12:05, topic5, very interested
ellie_ghadia, 11:05-12:05, topic6, interested
ellie_ghadia, 11:05-12:05, topic7, not interested
ellie_ghadia, 13:05-14:05, topic8, not interested
ellie_ghadia, 13:05-14:05, topic9, interested
ellie_ghadia, 13:05-14:05, topic10, very interested
Objective: maximise average per-person preference score across all participants.
contraints:
-
All participants must be assigned to exactly one of the available topics within each and every timeslot.
-a. Given this constraint, if there are 20 participants and 3 timeslots there should be 60 positive assignements.
-b. To clarify: multiple participants can be assigned to the same topic within a timeslot. But each of those should not be assigned to any other topics within that same timeslot. -
maximise preference in equitable way across participants/ minimse the variation in prefernce score achieved by each participant
-a. i.e. we do not want one person getting all there top preferences if it means someone else gets none of their top preferences.
-b. A simple and sufficient way to address this constraint would be to calculate the maximum preference score for each person and then try to come up with a solution which maximises the averge per-person preference score. -
where preference == mandatory, that participant must be assigned to corresponding topic for that timeslot.
-
people should not be allocated topic where preference == not-interested unless there is no better alternative, this need not be a hard constraint but could be implemented by simply offering a very hash penalty for "not-interested".
I want achieve output table like this:
participant---timeslot---topic---preference---assigned---preference_rank
dave_smith, 09:05-10:05, topic1, very interested, T, first-choice
dave_smith, 09:05-10:05, topic2, interested, F, second-choice
dave_smith, 09:05-10:05, topic3, not interested, F, last-choice
dave_smith, 09:05-10:05, topic4, interested, F, second-choice
dave_smith, 11:05-12:05, topic5, very interested, F, fist-choice-joint
dave_smith, 11:05-12:05, topic6, very interested, T, first-choice-joint
dave_smith, 11:05-12:05, topic7, not interested, F, last-choice
dave_smith, 11:05-12:05, topic7, not interested, F, last-choice
dave_smith, 13:05-14:05, topic5, mandatory, T, mandatory
dave_smith, 13:05-14:05, topic6, interested, F, non-mandatory
dave_smith, 13:05-14:05, topic7, not interested,F, non-mandatory
output$assigned shows the best assigments as determined by the optimisation model.
output$preference_rank ranks each topic by preference against other topics in same timeslot.
If anyone could share a solution it would be immensly appreciated!