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.