|
Assignment 4The Assignmenthttp://learnu.ics.hawaii.edu/~nickles/211_Spring_2005/labs/ queue/EventQueue.htmlSubmission
RecommendationsQueueThe first part of this assigment is to write a queue. It should implement the Queue interface given by Nickles. You must use singly-linked nodes to implement it. (Hint: reuse your stack node.) For your convenience, here is a zip file containing the interface, two exceptions, and a grader for your Queue. (You may write your own exceptions or expand these to take string messages if you want to.) You will not need to throw the QueueFullException, since your linked-list implementation won't have a capacity limit. Event QueueThere are a number of ways do write this simulation. It is possible to do it without a queue at all, but you are required to use a queue. Even when using a queue, there are at least 4 different ways to do it. I will go over these differences in lab, but briefly they are as follows: Job Queue. If you never use a JobEndEvent, you are using a job queue. In this implementation, the queue does not "control" the printer. Rather, the printer controls the queue. The printer processes the first job in the queue. Only once it has finished the job does it look at the next thing in the queue. This is probably the easiest implementation to do. However, it is less flexible in the long run, since you are not processing events (only jobs). If you write your simulation this way, it will -0.5 points (which may be worth it if you can finish the assignment early doing it this way). "Event" Queue. If, every time you start processing a new event, you always put the JobEndEvent at the start of the queue (in front of all the other print jobs), it seems like you are doing a true event queue. However, since no other event is ever processed until after the JobEndEvent, this has the same functionality as a job queue. Event Queue--with dynamic job creation and processing. This is the approach shown in Nickles's psuedocode. Since you have the pseudocode, this will probably be the best approach to do for this assignment. Event Queue--with Priority Queue. In true event simulations, you usually use a priority queue. When adding to a priority queue, the object is inserted in sorted order rather than just at the end. This means you have less processing of events to do. If you would like to use a priority queue, you may. However, you must still submit a normal queue as well. (Hint: have a look at java.lang.Comparable, and make all your Events comparable. You may subclass MyQueue to create MyPriorityQueue and just override the enqueue method.) Final Comments (04 March)
Grading:Out of 10 points:
Solution
Zach's Solution (zip file). See the README.txt file in the zip for a brief overview. Solution updated 20 April: I found a small bug in JobSimulation in scenarios where there are not big backlogs of jobs. (Basically, I forgot to update the current time if the printer had been sitting idle until the next job.) Notes on grading and resultsI based my evaluation of your simulation code's correctness (worth only about 1.5 of the total value of the assignment) on your output. I ran both the original simulation and another set of parameters. If you have any questions, here are the numbers I was looking for:
These results are approximate medians; the range was sometimes rather large. I ran each version 4 to 10 times to see if the numbers were close. Occasionally a submission would produce results within the acceptable range, but would always be lower or higher than the average. I usually just called these correct, but be aware I'd would recommend more exhaustive testing before relying on them if they were part of a real project. If you still have questions why your code is incorrect, let me know. We can meet and go over your code. |
~ztomasze Index :
TA Details: ICS211:
Assignment 4 http://www2.hawaii.edu/~ztomasze |
Last Edited: 20 Apr 2005 ©2004 by Z. Tomaszewski. |