You are on page 1of 4

DSA555 Data Structures & Algorithms

Assignment #3 Summer 2015


To maintain and schedule computer jobs

In this assignment you will use the C++ programming language to


model and maintain a set of computer jobs using directed graphs. Each
vertex represents one job and the arcs model the precedence relations
among the jobs. Basically, you have to write a program that monitors a
stream of incoming jobs. The stream provides the jobs in chronological
order. At any moment in time, the current jobs exhibit inter-dependency
which you should model using a directed graph. You need to model the
following tasks:
When a job is finished, delete it from the system.
When there is a new job, add it to the system.
Upon request, report a critical path in the current set of jobs.
Critical path:

--------------A path of jobs in the directed graph is a critical path if the


last job in the path has the greatest finish time among all jobs
in the graph. Note that there may be more than one critical path.

The stream of jobs:


-----------------You are given an ASCII file jobs.txt that models the stream of jobs.
You can assume that the file jobs.txt is present in the current
directory in which your program will be run. Each input line in the
file has the following format:
<time> <id> <earliest-start-time> <length> <pred-job> <pred-job>

...

The above sequences of parameters are separated by blanks.


The parameter <time> denotes the current time. It is an integer
and it is equal to i at the ith input line. So there is at most
one new job in the stream at any time unit. It is possible that
the input line contains the parameter <time> and nothing else.
In this case, there is no new job in the stream at the current
time.
The next parameter <id> is a string of non-blank alphanumeric
characters denoting the id of the new job. No two jobs have the
same id.
The next parameter <earliest-start-time> is an integer denoting
the earliest time at which the new job can start.It may be

greater than the current time. The rule is that a job will start
as soon as all jobs that it depends on have finished AND the
current time is greater than or equal to the earliest-start-time
of that job. That is, if i is the greatest finish time of the
jobs that the new job depends on, then the new job will start at
time i or its earliest-start-time, whichever is larger. For
example, if the current time is 3, and the earliest-start-time of
a job printing is 10, then printing can only start at time 10 or
later, depending on the precedence relations between printing and
other jobs. On the other hand, if the current time is 3 and the
earliest-start-time of printing is 1, then it may start at time 3
or later, depending on the precedence relations between printing
and other jobs.
There is NO LIMIT on the number of jobs that can run concurrently
in the system.
The next parameter <length> is an integer denoting the duration
of the new job. For example, if a job printing starts at time i
and its duration is 5, the finish time of printing is i + 5.
The job id critical is an exception and it does not denote a real
job.
Instead, upon seeing the job id critical, your program
should output a critical path in the current directed graph. In
this case, the input line contains nothing else after critical.
Recall
that
the
last
job
in a critical
path
has
the
greatest finish time among all existing jobs. If the directed
graph is empty at this moment, output nothing.
There may be several critical paths in the directed graph, and
your program can output any one of them. Your output critical
path must be printed in one output line in the following format.
<time>
<id>
<start>
<finish>
<id>
<start>
<finish>
...
[Note: See the given sample_output.txt to test your program with the
given jobs.txt input file]
The value <time> is the current time. The rest of the output line
contains one triple per job on the critical path. The left-to-right
order of the triples should be the execution order of the jobs on the
critical path.
The triples should be separated by blanks.In each
triple, <id> is the job id, <start> is the actual start time of the
job, and <finish>is the finish time of the job.
These three values
should be separated by blanks.
The id critical may appear multiple times in the file jobs.txt. Note
that when you see the id critical, there is no real job to be added to
the directed graph at the current time.

If there is no other parameter in the input line, the new job


does not depend on any existing job.
Otherwise, the remaining
parameters <pred-job> specify the ids of the existing jobs that
the new job depends on. It means that the new job cannot start
until all these jobs have finished. For example, if the new job
is printing and the greatest finish time of the jobs that
printing depends on is i, then printing will start at time i or
the earliest-start-time of printing, whichever is larger.
Requirements:
-----------You should define a class for the directed graph used in modeling the
jobs. You MUST represent your directed graph using adjacency lists or
adjacency matrix.
Submission Guidelines:
---------------------You are encouraged to test your program in as many C++ environments as
are available to you, but for submission purposes, your program must
work on Windows using the Visual Studio 2013 compiler.
Once you have completed and thoroughly tested your program, the source
file must be sent to your instructor by e-mail following the
guidelines written below:
1. E-mail must be sent to: asma.paracha@senecacollege.ca
2. E-mail subject must be: your subject's course code and
assignment number(DSA555_a3)
3. E-mail
must
be
sent
from
your
learn
account
(i.e.
userid@learn.senecac.on.ca)
4. The body of the e-mail is to remain empty (no text or
messages)
5. and you must attach all of the files as described in the
assignment
6. outline/requirements (ALL FILES ARE TO BE PLAIN TEXT ONLY!
NO *.zip, or *.rar, or *.tar.gz, etc will be accepted).
Late Penalty:
------------An assignment which is late will receive a penalty of 10% for every
week late (with no maximum penalty)!
NOTE:
-----DSA555 requires that all assignments must be submitted in perfect
working order. An assignment which does not produce the correct output
must be fixed and resubmitted, at which time it will receive a mark
that is 50% of what it would have received if it had not been
resubmitted. This means that if you know that your program doesn't
quite work, you are better off to continue working on it and
Submitting it a bit late, than to hand in something just to be ontime!

Due Date:
--------Friday August 21th, 2015 by 11:59:59 p.m.
This assignment is worth 12% of your final
semester.
Good Luck!

grade

in

DSA555

this

You might also like