Sunday, June 26, 2011

CQ Simulation: Output and Input

In my last post, I let myself wander off into implementation land. That is, I started to worry that implementing calculating the median would be too complicated.

I can't approach it that way. Using the median wait time as the measure makes the most sense to me. I can't get lost in implementation at this stage.

This is what I want as the final output of the simulation:

  • Median wait time for users
  • Percent of time that computers are in use
  • Percentage of users who abandoned

The input will be a list of users, each with the following information:

  • Tick when the user gets in line
  • Waiting threshold, after which user abandons waiting
  • Amount of time user sits at computer

The input can also be viewed as a user generator that creates the list with users falling withing specified parameters. That is, users would each want to use the computer for a random amount of time between the numbers A and B. A might be 5 and B might be twenty or A might be 35 and B might be 65.

The simulation maps an input list into an output results object. The simulation includes the following facts:

  • Number of seats for users.
  • Length of time that a user can use a computer before it logs the user off.

(I noticed that I'm already referring to ticks. A tick is a unit of time, the same as a minutes, I suppose. I started calling them that back in the clock simulation.)

OK, next up: Preliminary Object Design.

Monday, June 20, 2011

CQ Simulation: Output

So, what should the result of the simulation be?

Well, if the point of the program is to figure out whether the computers are being used well, we wan to know the following things:

  • What's the average wait time? (Or would median be better?)
  • How much time do computers spend unused?
  • How many people (what percentage) leave before they get to a computer?

All of these are calculated elements. That is, I assume they only mean something related to how many people are trying to use the systems.

So, how about this:

  • medianWaitTime
  • seatFreeTime
  • percentAbandon
(And I wonder whether there's a way to calculate median without waiting until the end? SeatFreetime can be a running total later divided by the number of seats.

Well, I'm assuming that the number of seats is constant throughout the simulation. )

OK, if we're concerned with how much the systems are getting used, then we can calculate the number of minutes per hour that the system is occupied. That can be a running total for all systems.

Percent abandon, likewise, can be calculated on the fly.

If I go with median wait time, though, I'm not sure I can. I want to avoid average wait time because it seems to me that a few short waits might mess everything up.

Tomorrow: more of this.

Saturday, June 18, 2011

Another Project

Well, I've been away from this blog for a while and I'm getting antsy to try something new. I'm looking for something that will incorporate some new stuff, but that also includes meat-and-potatoes coding and testing.

Here's what I came up with.

A few years back, I moved to a new town. For a while, I was in a hotel and then I hadn't had cable set up, so I had no internet at home. (This was before free wi-fi everywhere.) So, I went to my local library.

My library had a bank of eight computers for public use. People came in, waited for a free one, and then could use the computer for up to an hour.

While standing in line, it occurred to me to wonder whether eight was the right number of computers, whether an hour was the right amount of time, and how you could figure that out.

So, what about an application that simulates this setup so we can compare different inputs?

The system will either generate input (people lined up) for the seats according to certain settings or read that data in. Using the same input data allows us to change the other parameters, such as the number of computers and the use time.

My plan for this will be:

  • Spec out the problem in more detail.
  • Determine the type of input and output to be created.
  • Plan out individual classes and methods.
  • Write code and write tests.

I'm going to start this as C# in a text file, as I did for the winding clock project. Once it's working and the bits have been tested, I'm going to move it into a dll as a cmdlet, as I described in the last posting.

This is a fair-sized project. Since I can't work on it every day, I'm going to make a point of keeping all my work here, in the blog. (Except for the code, I mean.) I'll include designs, planning, and status here.

And I'll end each post with my "Next item" -- the thing I will do when I do the next post.

So, next item: Specify input and output types.

Sunday, June 12, 2011

In the Interum

I haven't had much bandwidth for this blog in the last few weeks. I have been doing a bit, here and there.

Over the last week, I decided to create a test cmdlet. That is, an actual cmdlet, written in C# and imported into PowerShell.

I've wanted to write a cmdlet since I found out what they are. The are only two reason not to:
  • It does involve a few extra steps between the code and being able to run it in PowerShell.
  • There isn't any reason for individual scripters to write cmdlets.
I've always hated the second answer. I want to do what I want to do, not what somebody else decides I need to do.

The point is well taken, though. You can write all kinds of functionality in a function. You can also create cmdlet-looking scripts that you can export as modules. Doing it in C# in a separately compiled file doesn't add much unless you want to re-use some existing code or you need to optimize code or have some other good reason.

But I went ahead and did it anyway -- at least well enough to compile and to get PowerShell to read the contents of the module.