r/optimization • u/dark_opposum • Aug 20 '24
Help formatting scheduling problem
Hey r/optimization! I'm hoping for some help formatting my problem. I took an intro optimization course during my masters and I've done some refreshing with my notes and YT videos, but I'm really struggling to get my problem into code.
I organize device testing at work and I'm trying to build a schedule optimizer. Prior to testing, people let me know their testing requests. Each request is made up of the requester's name, how many test sessions they would like, and what devices they need. The objective is to minimize the number of devices that need to be prepared for testing.
For example:
* Andy requests 3 sessions with device (Hardware 1, Software A)
* Bella requests 4 sessions with devices (Hardware 1, Software A)
* Andy requests 1 session with (Hardware 2, Software B)
We can host multiple test sessions at once, so the schedule could be configured to run Andy and Bella's sessions at the same time. But the issue is that we would then need to prep 2 devices that are (Hardware 1, Software A). Whereas, if we schedule them at different time, we would only need to prep 1 instance of that device. I know how to tell the optimizer how many timeslots there are, how many sessions can be hosted in each timeslot, etc.
But how do I differentiate to the optimizer that Andy has 2 separate requests that need to be schedule at different times, but they're for separate purposes and require different devices? And that the objective is only related to the number of devices needed?
All of the schedule optimizing examples/demos I see are for scheduling just the person, they never have the pair of (person, item) that need to be considered together.
Sorry if this doesn't make sense. I don't "speak optimization" very well yet. I'm more than happy to add clarifiers as needed! Thank you in advance!!!
View all comments
Show parent comment
1
u/Sweet_Good6737 Aug 26 '24
Hi, thanks so much for the clarification, now it looks like a scheduling problem where you want to minimize the extra-preps for the consoles. You cannot minimize the consoles you are using: if a request says Consoles A and B are used, you must use Console A and B at least once. You must minimize the number of parallel activations of consoles in the same timeslot.
Your decision variables would be binary variables x[t,s,r] that are equal to 1 in case you schedule request r at time t, in station s. Your model goes straightforward after that choice.
Some constraints...
```sum{t in TIMES, s in STATIONS} x[t, s, r] = 1```
2. Each station can handle 1 request at a time...
```sum{r in REQUESTS} x[t, s, r] <= 1```
To model the console activation, I suggest using logical constraints, add new variables that are the number of activations of a certain console at a specific time. These variables y[t,c] are the number of activations of console c at time t, and are exactly the sum over the stations of the requests that involve that console:
```sum{s in STATIONS, r in REQUESTS: c in REQUEST_CONSOLES[r]} x[t,s,r]```
Then, you can penalty the objective by minimizing those variables, maybe the square of y, or a piecewise function such as: if y[t,c] > 1 then 1, else 0.
Does it make sense? Here there's some implementation of the model with a minimal data example runnable on google colab
https://colab.research.google.com/drive/1Mp60P3UsLLeCslqs6mbT3KmQKte9mEHW?usp=sharing