[Home] [Puzzles & Projects] [Delphi Techniques] [Math topics] [Library] [Utilities]
|
|
Problem DescriptionCreate a program capable of answering questions about job processing systems with input queuing. For example: A gas station has a single pump with customers arriving every 5 minutes on average, It takes an average of 4 minutes to fill up and pay. The owner makes $1 per customer, but a customer will give up and leave after 3 minutes, costing the station $8 in future profits. Each pump costs $1/hour in depreciation, electricity, overhead, etc. Should the owner install a second pump? or In a manufacturing firm, machines break down at the rate of 0.8 per hour, and the lost production cost of each machine waiting for service or repair is is estimated to be $25 per hour. There are two repair teams available to the firm. Team A asks for $25 per hour and guarantees that it can repair 1.5 machines per hour. Team B charges $20 per hour and can fix 1 machine per hour. Which team should the firm employ?
Background & Techniques
A system that serves discrete customers, humans, automobiles, messages, jobs, or dairy cows at milking time, is a queuing system. Such systems typically have one or more waiting areas and one or more servers. The customers may be of different classes or priorities and be handled differently as a result (emergencies at the doctors office or the express line at the grocery store, for example). Most of our transactions involve queuing systems: the gas station, bank, grocery store, post office, doctor's office, public restrooms, and phoning a business ("Your call is very important to us, please hold for the next available representative" ha!) , to name a few. Discrete event simulators are fun because they model these types of systems, especially this animated version where you can watch the little customers arrive, wait, get service and leave. We'll define customer classes and their arrival and cost characteristics. We'll also define one or more servers and what kinds of customer classes they can handle and how they process those classes. Several sample problem are included with both source and executable versions of the program. Most problems are from my old college text "Introduction to Operations Research", Frederick Hiller and Gerald Lieberman, Holden-Day Inc. The details of defining job class and server characteristics are included with the program, but for now lets look at the basic program processing loop. Non-programmers are welcome to read on, but if that sounds boring, click here to jump to the bottom of the page to download an executable version of the program. Programmer notesThe key trick is that everything is driven off of future events queue. We have four event types: Arrival, Start processing, End processing departure, and Give-up departure. (Give-ups result when a maximum wait time parameter has been exceeded.) Each event generated is placed in the future events queue in future time sequence. A new class TSim, derived from Delphi's TQueue type, serves as the future events queue. Initially a single job of each class is created and placed in this queue. The loop always removes the top queue entry, updates the clock to that time, and acts based on it's type.
This is a large, fairly complex, program (2500+ lines of code) and has lots of rough edges remaining. I could spend a couple of more weeks more working on smoothing them out. But the great thing about writing for fun, is that I don't have to! Learn and have fun! Running/Exploring the Program
Suggestions for Further ExplorationsA few possible enhancements:
|
[Feedback] [Newsletters (subscribe/view)] [About me]Copyright © 2000-2018, Gary Darby All rights reserved. |