I believe this problem is similar to the Weighted Interval Scheduling problem, but slightly different.
Say you have a Shift s that has a start and end time, with the Shift having n slots to fill from s.start to s.end. A slot is a fillable range of time from s.start to s.end. You are given m intervals, where each interval has a start and end time. Assign the intervals to the slots, such that you use the minimum number of slots necessary. An interval can be assigned to a slot as long as there are no overlapping intervals. The given intervals are known to fit in the given number of slots (but they don't have to fill the slots). Once an interval i is assigned to a slot, that slot has been filled for i's time range.
I've written a jsbin that does a brute force algorithm for this, but it is O(n!) or worse, since it checks every possible sequence of intervals and tries to greedily place them into the first slot that has no conflicts.
http://jsbin.com/bixalabume/1/edit?js,console (I call intervals "segments".)
Is this problem solvable in a reasonable amount of time? I feel like there is a DP solution but can't think of one.
I'm not particularly strong in this kind of programming, but here were some similar questions that I looked at but couldn't understand:
- https://cs.stackexchange.com/questions/42008/weighted-interval-scheduling-with-m-machines - Similar but my problem doesn't have weighted intervals (I think)
- Appointment scheduling algorithm (N people with N free-busy slots, constraint-satisfaction) (This is more complicated I believe because it has variable timings for the slots, whereas my slots are equal timings)