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?
Related
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?
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?
I'm trying to look for an algorithm to optimally schedule events, given a set of timeslots. Each event (a,b) is a meeting between 2 users and each timeslot is a fixed amount of time.
eg. a possible set of events can be: [(1,2),(1,3),(4,2),(4,3),(3,1)] with 4 possible timeslots. All events have to be scheduled in a certain timeslot, however, waiting time per user should be minimised (time between two events) and at the same time, the amount of users in a waiting timeslot should be maximised.
Do you know of any possible algorithm or heuristic for this problem?
Greetings
Sound like a combination of Job Shop Scheduling (video) and Meeting Scheduling (video) with a fairness constraint. Both are NP-complete.
Use a simple greedy Construction Heuristic (such as First Fit Decreasing) with Local Search (such as Tabu Search). For these use cases, Local Search leads to better results than Genetic Algorithms, as well be more scalable (see research competitions for proof).
For the fairness constraint "waiting time per user should be minimised", penalize the waiting time squared:
You could get a maybe-better-than-random solution with a simple approach:
sort each pair with the lower-numbered user first
sort the list on first-user (primary key), second-user (secondary sort key)
schedule meetings in that order, with any independent meetings scheduled in parallel. (Like a CPU instruction scheduler looking ahead for independent instructions. Any given user will still have their meetings in the listed order. You're just finding allowed overlaps here.)
I'm unfortunately not an expert on trying to reduce problems to known NP problems like the travelling salesman problem. It's possible there's a polynomial-time solution to this, but it's not obvious to me. If nobody comes up with one, then read on:
If the list isn't too big, you could brute-force check every permutation. For each permutation, schedule all the meetings (with independent meetings in parallel), then sum the last-first meeting times for every user. That's the score for that permutation. Take the permutation with the lowest score.
Instead of brute force, you could use a random start point and evolve towards a local minimum. Phylogenetics software like phyml uses this technique to search for maximum-likelihood evolutionary tree, which has a similarly factorial search space.
Start with a random permutation and evaluate its score
make some random changes, then evaluate the score
if it's not an improvement, try another permutation until you find one that is. (maybe with a mechanism to remember that you already tried this modification to the starting tree).
Repeat from 2 with this new tree, until you've converged on a local minimum.
Repeat from 1 for some other starting guesses, and take the best final result.
If you can efficiently figure out the score change from a swap, that will be a big speedup over re-computing the score for a permutation from scratch.
This is similar to a genetic algorithm. You should read up on that and see if any of those ideas can work.
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)
I'm trying to improve an ordinal ranking implementation we are currently using to determine a unique ranking amongst competitors over a set of tasks.
The problem is as follows. There are K tasks and N competitors. All of the tasks are equally important. For each of the tasks, the competitors perform the task and the time it took for them to complete the task is noted. For each task, points are given to each competitor based on the order of their completion times. The fastest competitor gets N points, next fastest gets N-1 etc, the last competitor gets 1 point. The points are accumulated for a final tally from which a ranking is established.
Note in the event any two competitors complete in the same time, they are given equivalent points - In short ordinal ranking.
My problem is as follows, the tasks even though they are all equally important are not equally complex. Some tasks are more difficult than others. As a result what we observe is that the time difference between the 1st place and last place competitors can sometimes be 2-3 orders of magnitude. This situation is compounded when in scenarios the top M% competitors completes in a time that is 1-3 orders of magnitude less than the next best competitor.
I would like to somehow signify and make obvious these differences in the final ranking.
Is there such a ranking system that can accommodate such a requirement?
Since your system is based on completion time, you obviously need to rank the complexity of each task by expected time. So each task needs to have a weight that you multiply N by so that the first place would get weight*N, second would get weight*(N-1). The final tally would sort the final weight ranking of each competitor and use that order as their final placement.
On the other hand, you may keep your system as it is now. Let a part of the competition be the wisdom of differentiating which task is more complex than another.