Mister V says:
What’s the best way to schedule the senator-journalist meetings so that the greatest number of meeting requests are fulfilled?
So I am assuming you give no preference to journalists relative to their number of meeting requests (or any other conceivable preference). All you want to do is assure the maximum number of meeting requests are fulfilled. I am also assuming each journalist will meet with one, and only one, senator per time-slot and there are no requirements for multiple senators to meet with a single journalist at any time.
Here’s a tedious, but programmable, way to do it:
Let me start by making my own definitions for X and Y. X is the senator’s name and Y is a time-slot. I am making the assumption all time-slots are equal in length, let’s say for clarity, all time-slots are one hour beginning on the hour.
This way you can define a 2-dimensional array (matrix) with the senators names on the X-axis and the time-slots on the Y-axis. For programming purposes, assign each senator a number. Fill in the matrix with zeros where the senator/time-slot is available, -1 where the senator/time-slot is not available to any journalist.
Next, define a matrix for EACH journalist, with senator’s number on the X-axis and time-slot on the Y-axis. Each senator/ time-slot in this case will contain the name of the journalist for each time-slot this journalist requests for each senator, or a zero if no senator/time-slot is requested (for programming purposes, assign each journalist a number).
Now “overlay” each journalist’s matrix onto the senators matrix, one at a time. If the corresponding senator/time-slot is available, assign the current journalist to that time-slot. Do this for all of the senators/time-slots requested by this journalist. Then overlay the next journalist’s matrix on the modified senators/time-slot matrix, assigning this journalist senators/time-slots he has requested that are available.
Keep track of the number of time slots filled. Once you have applied ALL of the journalist’s matrices to the senator’s matrix, permute the order in which you apply the journalist’s matrices and then do the procedure over again. After doing this procedure for every permutation of journalists, choose the permutation that filled the largest number of slots in the senators matrix.
I hope this all makes sense. :dubious: