Interval Scheduling with with start and end times are intervals themselves - algorithm

So the classic interval scheduling problem is given a bunch of intervals [a_i, b_i] where a_i is the starting time of the interval and b_i is the ending time of the interval, find the most amount of non-overlapping intervals one can gather in a set. This problem is easy, one can use the greedy algorithm and that makes sense.
However, what if the starting time of the interval is an interval itself as well as the ending time of the interval as well. Essentially you have a list of intervals which contain intervals themselves. The motivation behind this is that often times, when one does a "task", they can start the task in an interval of time, and then can end the task in some interval of time. How would one approach/modify the interval scheduling problem to solve something of this nature.
Another way to look at this problem is that you have a bunch of "interval pairs: [a_i1, b_i1], [a_i2, b_i2]" and you want to apply the interval scheduling algorithm to these interval pairs. Same question, but perhaps a better way of looking at the problem. Can someone provide some help?

Related

Interval Scheduling Problem: accepting requests in order of latest starting time is always optimal?

I learned that the interval scheduling problem is optimal when we accepts the requests in the order of earliest finish time.
Then, is it also true that we also have always optimal solution if we accept the requests in the order of latest starting time?
I think it is false, because we would get a different schedule set, but I am wondering how I can come up with a more mathematical proof.
Scheduling by latest starting time is the same as:
Reverse time (negate all the times and swap interval ends)
Schedule by earliest finish time
Reverse time again to restore the original intervals.
By symmetry, the maximum number of schedulable intervals is the same whether you reverse time or not, so if "earliest finish time" is optimal, then "latest start time" is optimal, too.
As a hint, imagine mirroring all the intervals, or pretending that time runs backwards. You know that the greedy “take the earliest finish time” will select the maximum number of intervals. If you sweep backwards in time, what’s the equivalent condition?

Time Management Scheduling Algorithm

I am interested in solving a problem related to time management.
Suppose you are given N intervals, where the i-th interval has a start time and end time, as well as the amount. Each interval represents a constraint that requires (at least) the specified amount of total time doing task i by a machine inside the start and end time of the i-th interval.
The machine can only work on one task at any time but can switch between tasks and come back to another if necessary.
How do you produce a schedule (i.e. allocation of time and task) that satisfies all intervals (i.e. constraints), as well as reporting and minimizing maximum lateness, in the most efficient way?
Also, a variant of the problem:
Each interval is also given a task ID, and if a task is done at some time, it would be counted towards all intervals covering this time and requiring this task. In other words, if multiple intervals that require the same task overlaps, doing the task during the overlapping time will be counted as trying to satisfy all 3 constraints, thus saving some time.
Is there an efficient way to solve this problem as well?

Interval schedule maximization when encountering intervals with equivalent end points

In interval scheduling, the greedy solution which maximizes the schedule that contains the largest number of "compliant intervals" involves initially sorting the list of intervals in ascending order by the end-times/point of each interval.
What confuses me, is if two or more intervals have the same ending time.
When performing the initial sort, should one base the sort of the sub-range of intervals on start time?
and if so should it be in ascending or descending order?
It doesn't matter, with the greedy based solution. All you want to optimize is to maximize no.of jobs completed. Job length is considered for finding overlap s and elimination, not for the choice.
Given list of jobs ending in same time, you will only end up in choosing 1 of them, because they all overlap. Also, there is no negative impact of choosing any of them.
Depending on application, you may want to choose the longest job or shortest job.
Hope it helps!

Shortest Remaining Time - average turnaround time

Assuming all processes arrive at the same time, shortest job first seems to be optimal in terms of lowering the average turn around time. I also managed to prove that.
However, when procesess arrive at different times I felt like the optimal algorithm would be the Shortest Remaing Time (preemptive shortest job first). But I can't find a way to prove it. Can someone help me/point me to a solution? Or am I flat out wrong?
http://en.wikipedia.org/wiki/Shortest_remaining_time
You can run one process at a time. No context switch time.
EDIT:
Say we have n proccesses.
Each process has an execution time of P(i). 1<= i <= n
Each process becomes available for execution at a specific time R(i)
Each process ends running at some time C(i) (turn-around time) based on when it started running, if it was suspended e.t.c
all times are integers. no specific example. I just have to find an algorithm that optimizes the average turn around time ((C(1)+C(2)+...+C(n))/n) for any given input. (as low aas possible)

Optimization: Minimize number of meetings

This is an interview question
There is an airline company that wants to provide new updates to all of its flight
attendants through meetings. Each ith flight attendant has a working time from start
time i (si) to end time i (ei). Design an algorithm that minimizes the number of
meetings that company has to hold.
My approach is to pick a flight attendant who has the smallest end time. Then delete all those attendants whose start time <= this end time (because they already know the updates from the meeting). Continue until there is no more flight attendant to select. The airline should hold meetings at the end time of those attendants that I pick.
Is this a correct approach? If so, how to prove its correctness.
I think the complexity is O (n log n) since I will first sort the list in ascending order of end time and go through the list once.
To my understanding, the described algorithm yields an optimal solution by the following argument. Fix an instance and its optimal solution; fix the earliest ending time t of a working period; if a meeting is scheduled to t-1, all working periods starting earlier than t can be served by this meeting, so any optimal solution using more than one meeting up to t could improved. On the other hand, there must be at least one meeting up to time t-1 since otherwise some working periods could not be served.
After deletion of served working times, we obtain a smaller instance of the same problem. By using the above argument iteratively, a minimum number of meetings is obtained.

Resources