Thursday, June 20, 2013

Queueing Theory in Practice

Who hasn't been in the company restaurant at lunch time, the local grocery store at 6PM, or the coffee shop and experienced the queues at the cash registers?

The other day I ended up in an ad-hoc contest in our cafeteria with two colleagues trying to get through the process quickest. What's the best strategy when a new register opens and the operator calls out 'next guest in line please'? Stay in line and let others start a new queue? Move over and hopefully skip to the head of the new queue? This made me think about optimizing queue scheduling. Yep, I'm a #nerd...

According to Wikipedia's Queueing Theory topic queues may be managed using one of a number of scheduling policies:
  • First in first out - customers are served one at a time and that the customer who has been waiting the longest is served first. - typically I've been waiting the longest, so move aside!
  • Last in first out- the customer with the shortest waiting time will be served first. - what's up with that!
  • Processor sharing- Service capacity is shared equally between customers. - this results in a big pile up at the register. avoid this queue!
  • Priority- Customers with high priority are served first. -  this one is interesting. Do loyal customers have priority? Or new ones (giving them priority may entice them to return, while loyal customer by definition will return, since they're... loyal customers).
  • Shortest job first - The next job to be served is the one with the smallest size. - Ok, person in front of all of us ordering the double-java-chip-skim-soy-latte-frappuchino-with-no-room-for-whipped-cream-and-an-extra-shot-of-espresso... to the back of the queue!
  • Preemptive shortest job first - The next job to be served is the one with the original smallest size. - Get your cash/card ready already...
  • Shortest remaining processing time - The next job to serve is the one with the smallest remaining processing requirement. - Eh... get your cash/card ready already!

All apps thinkable have already been written. So I've downloaded the Java Modelling Tools for queueing analysis.Next time I go get my soup and salad, I'm coming prepared. That'll shave off at least 2 minutes of waiting time. Unless that one efficient cash register operator has a day off ...

And for the java-chip-at-lunch person I have the following tip. Bring your own whipped cream!

Saturday, November 17, 2012

feedback loop(holes)

Taxes have loopholes. That's nothing special because taxes are essentially feedback loops and any feedback loop has holes. Holes not in the shape of holes, but holes as things that break the loop.

This past week was much about feedback loops and the holes that break them, culminating in an impromptu ignite talk at MapSIN organized by .

Holes in feedback loops may be put into three general groups:  Chico, Harpo, and Groucho. I wish there was room for Gummo and Zeppo, but they left the act, so... Their loss.

Chico holes apply to the 'feed' part of the feedback loop. If there is no feed, there is no back and therefor no loop. The whole thing falls apart right at the start. Chico holes are the oldest ones. They stem from before the open data era. As you may expect, open data initiatives, government accountability and transparency, etc are threatening Chico holes (feedback loopholes are the only species where 'endangered' is a positive thing). Chico holes also occur if the 'feed' doesn't reach the audience.

Harpo holes break the 'back' part of the loop. They are the response part of the feedback loop. How many sites go around without anyone ever clicking the feedback button or contacting the webmaster. How many people have used google's webpage removal request? Most  of the website we build now include options for providing feedback, but what if the audience don't have web access?

Groucho holes break the 'loop' part of the loop, representing return on (my) investment (in providing feedback). If nothing changes after I gave my feedback, why would I continue providing feedback. Holes of this type just leave the audience grouchy.

The project that brought me to DC this week was very much focused no feedback loops. The feed, aid to local communities in developing countries is well defined. Most of our discussions were on Harpo, as the audience has limited or no Internet connectivity. We're looking to address this by integrating our Web 2.0 world with SMS and voice capabilities.

Innovation is not always inventing the next new thing, but can also be the use of something old in a new way.

Saturday, July 28, 2012

With a little help from a friend

Staying in the Olympic weekend theme... with a little help from a friend you can get the Census data from their recently released beta data API in a format more easily used in Excel.

I found out about the Census Data API and couldn't resist. Is there a map? What do you get? Quickly got an API key and off I went.

Oh... do you know the ANSI code for your state? Mine is 06. That's Ca/CA/California for most.
Wanted to get population by state? that's parameter code P0010001 in the 2010 Census Summary File 1 (SF1) dataset.

Enhancement Request #1 - provide more easily accessible lookup for the various parameters.
Enhancement Request #2 - allow state abbreviations in addition to ANSI codes.

Alright, once you have this plus the key, off you go:,NAME&for=state:*

response: a JSON array like this:

that's ok if you're a web developer, but I had thought to use this in Excel!

Enhancement Request #3 - support additional common output formats like CSV.

Based on 'stackoverflow convert-json-format-to-csv-format-for-ms-excel' I created a simple 
wrapper for the requests I was sending. The resulting CSV opens nicely in Excel like so:

AHA! From here we're good with the new Esri Maps for Office add-in:
And then shared to ArcGIS Online: 

View Larger Map