Recently I was
reacquainted with The Greedy Algorithm.
An interesting name, with, to me at least, immediate appeal, which required me to find out to what it referred when I first heard it. It sounds like a title to a children's book, and indeed the underlying story is one of wonder and amazement, first introduced to me during my studies in software design, long ago in a land far away.
How it is related to
dipsomania may not be immediately apparent, but to my slightly off beat way of
thinking I found a degree of resonance that showed some clear correlation, and
I thought it worth sharing.
An algorithm is a
step-by-step recipe for solving a problem or performing a function. In software
devlopment all code is written to create algorithms that in turn are combined
to form a program, or some kind of software. A greedy algorithm might also be
called a "single-minded" algorithm or an algorithm that gobbles up
all of its favorites first. The idea behind a greedy algorithm is to perform a
single procedure in the recipe over and over again until it can't be done any more
and see what kind of results it will produce. It may not completely solve the
problem, or, if it produces a solution, it may not be the very best one, but it
is one way of approaching the problem and sometimes yields very good (or even
the best possible) results. It all depends on the problem.
The most commonly used
example is working out how to give change of a given amount in the minimum
possible number of coins. The greedy algorithm will always choose the largest
available denomination available that is less than the remaining amount, and in
most currency systems will produce the optimal result in the least number of
steps. So for instance, if you wanted to give 95 cents in change the greedy
algorithm would start with a 50 cent piece, then 20,and another 20, then 5. A
perfect solution.
However for a chess
game, for instance, it would be useless, as future decision making is not
contemplated. The decision is made based on the conditions presented at the
time, and once the decision is made, the same decision will generally be reached
repeatedly.
It can be useful in much
more advanced applications also, and a mention of the concept in a technical
briefing on new database products recently reminded me of the principle. Since
the majority of the technical presentation was frankly over my head (I am,
after all as wide as the ocean, but as deep as a puddle) I sat and contemplated
whilst my colleagues lapped up the details of my company's latest foray into
engineered systems. Ho-hum.
Dipsomania, on the other
hand, is a term that fell out of favour in the early 20th century at a time
when psychology and psychiatry were in their infancy and these new sciences were
looking always to classify categorise and treat a large number of human
behaviors. At that time it was fashionable to use the term -mania to describe
something that appeared to have a sound definition and might be a condition of
the brain that may be a disease. Many things were initially described as one
kind of mania or another. Eventually it was decided that the condition it refers to was only a
single aspect of a wider problem - these days we know it as one facet of what we
typically refer to as alcoholism, the term used to describe a raft of issues
related to alcohol consumption. To whit, the demon drink.
Most people think of
alcoholism as the classic chronic drunkenness. Got to have a drink, any drink,
now, in fact right now, no matter what time of day or night. Often
concealed, generally self-destructive, this is the most common face of
alcoholism. Hello, my name is...
Dipsomania refers to a
more subtle but unfortunately much more common type of alcohol abuse, described
in 1893 in as "a crisis lasting from one day to two weeks, and
consisting of a rapid and huge ingestion of alcohol or whatever other strong,
excitatory liquid is available". Sound familiar? Pretty much any central
city bar or club full of 18 and overs out for a good time, right? Just goes to
show that there isn't much new under the sun, really. In fact the term 'dipso'
used to be used to describe someone who was famous for their benders, such as,
for instance, Ernest Hemmingway and, some postulate, Edgar Allen Poe. The mania
part comes in if it is something that apparently cannot be controlled.
These days we tend to,
regrettably in my opinion, look upon this not as entirely undesirable but in
young people actually almost to be expected and tolerated. Witness
the excesses of Schoolies week in Australia, Summer Break in the US and many
other such semi-ritualistic and tolerated binge drinking activities. We watch our kids get
mind-numbingly out of it on the drink du jour and tut tut, telling ourselves, O
well, better at home/pub/mates house under some kind of control that in a
park/car/street corner. Nice sentiment, but complete bollocks.
Every culture has its
coming-of-age rituals usually involving some kind of substance abuse and
potentially physical challenge; in our case the one is often the result of the
other - get pissed and pick a fight, or, get pissed and shag each other, or
indeed sometimes all of these in the same night. Altogether too often, it
seems, as any A&E doctor will tell you on any given weekend.
I myself have through
most of my adult life been a drinker of varying appetites and degrees. I think
most adult baby boomers would have to say that they have suffered at one time
or another with the symptoms of dipsomania, often referred to as 'got the bit
between my teeth', 'had a taste for it', or 'had a bit of a head on','put the
pedal to the metal', or even 'blowing off a bit of steam', one of those nights
where the drinks flowed, the night was yours, and somehow before you know it it
is around 3 AM, you are blotto and the beer googles are ON. And you know what,
that ain't necessarily a problem, now is it? The problem is when this becomes a
habit. When, every time you drink, somehow it turns into a big night. Or at
least more often than it should, or is desirable, or when you get a bit weary
earlier in the night than your companions and need a 'bit of a lie down'. Know
what I mean?
Perhaps
the relationship between these two seemingly disparate terms is
becoming clearer. You see, another way of looking at the
Greedy Algorithm is repeated behaviour seeking optimal results
regardless of consequences, and at each step in the process the decision making
is made for the most optimal result at that point in time, regardless of future
potential. Generally it is assumed that the first seemingly correct solution
will be re-applied ad-infinitum. Now I don't know about you, but I
think subconsciously each time someone says "Another one?"
it nearly ALWAYS seems like a good idea. At least when the urge is upon you, as
they say. And so here is the correlation. Because once the decision has been
made, all too often the Greedy Algorithm kicks in, and it becomes the default
answer, without consideration of future decisions or consequences. O
dear.
And it does seem most
appropriate to mention this at the moment, since last Christmas (2010/11, that is) we had lunch
with some friends who do like a sherbet or two, or he does at least
(you know who you are!) following a champagne breakfast at home, and by the
time we got to our dinner engagement much later in the day, yours truly 'had a
head on' worthy of any dipsomaniac. Those who know me are acquainted with my
love of food, yet I regret to say that by the time we sat down for a
magnificent dinner lovingly prepared by our host's wife, I could only manage
about two bites before it was 'Er, think I might have a bit of a lie down'.
This was the entirely predictable ultimate result of a day's
unerring application of the Greedy Algorithm (or perhaps just The
Greedy Mark), and one marginally useful but unintended result was the hours of
entertainment I provided to the other dinner guests when I lay, elegantly
sprawled across the couch, mouth open in a very appealing way, and snored away
the evening, whilst they danced and partied around me. She was most
displeased, as you can imagine, although the opportunity to show me photographs
of this delightful sight later was also, I am sure, rather entertaining and
rewarding in its own way. Our host for that fateful night still delights in recounting
the story, especially to me.
So there you have it,
the relationship between The Greedy Algorithm and Dipsomania. A most
unfortunate one, for some, and an interesting way to view what in our society
is a increasingly prevalent problem. Because, you see, the only way to change
the undesirable behaviour is, as it is in software development, to re-code the
algorithm. We have to change our way of thinking. For most this happens
naturally as the digits describing our age grow larger, when theoretically
maturity and increasing self-determination begin to hold sway. For others, not
so much. Some, indeed, seem to never 'grow up'. This can be an endearing trait
for some behaviours, but this isn't one of them, most will agree.
The term Dipsomania
never caught on. The psychiatric folk decided it was all a matter of
self discipline, rather than any discernible disease. Spoken
like true academics, I think. Behaviour noted, theory developed, but practical
application? That's for others.
For me, well, I managed to get through Christmas this year without the Greedy Algorithm making an appearance, to the relief of all concerned, including me. I think it is a sign of things to come. She certainly hopes so - a Greedy Mark is bad enough.