Design and Analysis of Algorithms

CSE 5311 Section 003 Fall 2004

Program 2

Due: October 27, 2004 (midnight). No late submissions accepted.

Consider a familiar scenario in which you have several assignments (or tasks) whose deadlines are approaching, and you want to know if you can complete all the tasks by their deadlines, by when you must begin each task, and how much free time you have to sleep or just have fun. For this assignment you will write a program to help that takes a list of tasks and produces a schedule of when to begin each task. The specifics follow.

  1. Your program will take a file name as an argument. The file will contain the current date and time in the format YYYYMMDDHHMM, the number of tasks, and then the details for each task: number, duration, deadline, priority, and predecessors. The task number is a unique, positive integer numbered consecutively from 1. The task duration is a positive integer representing the number of minutes the task will require to complete. The task deadline is in the same format as the current date above. The task priority is an integer between 1 and 10, where a lower number means higher priority. The task's predecessors is a list of task numbers that must be completed before this task can be performed. The list is delimited by parentheses and contains a comma-separated list of task numbers with no whitespace. Below is the generic format of the input file. Each task is on a separate line, and the components of a task are separated by a single space. You can see a sample input file here. <current date/time> <number of tasks> 1 <duration> <deadline> <priority> <predecessors> 2 <duration> <deadline> <priority> <predecessors> 3 <duration> <deadline> <priority> <predecessors> ...
  2. After reading in the current date and list of tasks, your program will then attempt to schedule the tasks according to the following criteria.

    The algorithm you use is up to you, but it must be implemented by you. You cannot use source code from the Internet or any other source. Your algorithm should also represent a reasonable tradeoff between efficiency and optimality (maximizing number of tasks scheduled). Note that a brute force solution of trying every possible ordering of tasks is exponential and not efficient. I would recommend the use of appropriate data structures to improve efficiency and readability of your code.

  3. Your program should output a schedule of tasks in increasing order by starting time. First, your program should output the current date and time as specified in the input file. For each scheduled task, the program should output the start date and time, finish date and time (start plus duration), slack time (deadline - finish in minutes), and the task's original duration, deadline, priority and predecessors. Your program should also indicate which tasks, if any, could not be scheduled to finish by their deadline along with their original duration, deadline, priority and predecessors. Below is the generic format of the output. You can see a sample output here. <current date/time> <task number> <start> <finish> <slack> <duration> <deadline> <priority> <predecessors> <task number> <start> <finish> <slack> <duration> <deadline> <priority> <predecessors> ... UNSCHEDULED <task number> <duration> <deadline> <priority> <predecessors> UNSCHEDULED <task number> <duration> <deadline> <priority> <predecessors> ...
  4. After ensuring that your program compiles and runs correctly on the omega or gamma system, submit all source code to me ( by the above deadline. Please only send one email message; use attachments if sending multiple files. In addition to correct functionality and satisfaction of the above constraints, your submission will be graded based on good programming style and documentation.