MATLAB Answers

0

Random assignments through the use of a MatLab programmed Calender

Asked by Alexander Mullison on 18 Jul 2019
Latest activity Answered by John D'Errico
on 19 Jul 2019
So my job on campus is being a Resient Assistant. Part of the job I have to do is assign my fellow RA's to a duty day.
My project that I am wanting to do is to create an academic (semesterly) calender, and then on Sunday-Wednesday I want to randomly assign two RA's, Thursdays two RA's and Friday-Saturday two RA's but I want these to all be equally split, and to be able to have certain days blacked out that they request off (i.e. if I request the second weekend of November off, the first Monday of every month, and the third Thursday in September off, the assignments would not put me on those days). I know this seems like a big task but I was wondering how I would do this, or if you could help me create these situations (even if on a smaller scale and I just increase it from there). I know some sort of "if,then,else" statements would be needed but I was hoping that you all could help. The reasoning the split up the days like this is that the Sun-Wed are our least busy days while Thur are our busiest and then Fri-Sat are 24 hour shifts and so those are the longest days. Any help or precode that you could help provide would be greatly appreciated.

  0 Comments

Sign in to comment.

2 Answers

Answer by Steven Lord
on 18 Jul 2019

Since is the assignment problem, and that Wikipedia page suggests solving it as a linear program, one place to start would be the Linear Programming and Mixed-Integer Linear Programming page in the documentation for Optimization Toolbox.

  0 Comments

Sign in to comment.


Answer by John D'Errico
on 19 Jul 2019

This is not really a MATLAB question, because it is just programming, something you could do in any language at least in theory.
Do you need some sort of if-then-else statements? NO!! You don't know before you write the code who has what requirements. And those requirements will change. Some months, someone will be unable to serve these duties on a given day. Your code will need to recognize that. So hard coded if statements are a terrible idea.
Instead, you have several options. You could just generate random assignments, then just test to see if the requirements are met. Stop when you have success. Note that it is possible that some sets of requirements will never have a solution.
You could also try a random scheme, where if the goals are not met, then you choose people randomly, swapping their assignments. Continue the random swap process until the target is achieved.
With somewhat more sophistication, you could formulate this as an integer programming problem. However that will require more sophistication, both to understand how to use an IP tool to solve this class of problem, and to set up a tool like intlinprog for the task. And of course, it will require the optimiztino toolbox.

  0 Comments

Sign in to comment.