Sie sind auf Seite 1von 3

Program

3 Assignment

You are to implement a scheduling algorithm that will schedule tasks in a directed
acyclic network graph (DAG). I strongly suggest that you use algorithms discussed
in class and summarized in power point presentation(s) to complete this task.

Input
You will use an input format that is very similar to the one you used in program
two with one addition, that being the number of crews available to complete tasks.
To indicate the number of such crews you will start with a single integer number to
be read from standard input (cin or scanf I STRONGLY recommend that you use
cin). Then, continuing to use standard input you will read the same commands
with much the same meaning that you did for program two where there were two
types of statements, namely

A create command, with syntax c # to create a new node for the DAG
An arc command, with syntax p, s, # where p (predecessor) is the
number of the tail of the arc (using the texts terminology) and s
(successor) being the head of the directed arc.

So, below is a sample input file that I will use in this discussion.

---------------- Input file ----------------------------
2
c 1
c 2
c 3
c 4
c 5

a 1 2 1
a 1 3 1
a 1 4 1
a 2 5 3
a 3 5 4
a 4 5 5
--------------- end of input file ---------

which means that we would have two crews and our DAG would look like the figure
on page 3.

Output

The output of your program should be sent to standard output (cout or printf) and
should include the following information:

The length of the critical path of the DAG (6 for our example)
A list of all nodes on one or more critical paths (1, 4, 5 four our example)
A listing of a schedule to complete the task which might look something like
the following for our example

Time Unit Crew 1 Crew 2
1
1

2
4
3
3


4


5


6

2
7


8


9
5


Submission Requirements

Your program must:
Be written in C++
Use separate classes for DAG, DAGNode DataReadySet
Be submitted to Blackboard on or before the due date of 11:59 pm on
4/29/16
Not include any templates from the Standard Template Library
Produce the output required.

Note: You should be able to easily compute the critical path length for the DAG and
the list of nodes that are on a critical path. HOWEVER, since scheduling (like
Travelling Sales Person) is an NP-Complete problem you will NOT be able to
guarantee a minimum cost (length) schedule without trying all possible schedules
so youll need to rely on heuristics to obtain a good schedule. We will expect some
difference in the quality of schedules you generate but DONT go overboard
wasting your time on getting the best schedule possible.

Of course you all realize that its not always possible to obtain a schedule in which
the number of time units required matches the critical path length. For example, for
the small DAG I used as my example we could NOT complete the project in the time
suggested by the critical path. BUT, if you come up with a schedule that requires
fewer instructions than the critical path length your program has a problem!


Limitations on Input DAGs
I guarantee you that no DAG we use to test your program will have more than
1000 nodes. Whats more, each DAG will have exactly ONE sink (nodes without
successors, node 5 in our example) but it may have many sources (nodes with no
predecessor).








2



3

1

1
3

1
5

Das könnte Ihnen auch gefallen