Saturday, 20 December 2014

A Christmas tipple, statistically

Did you know that half Britain's adults have their first glass of wine on Christmas Day at 1:12pm?  It must be true - it is in a newspaper!

Leaving aside the silliness of recording such an item of data (I can't tell you to the nearest minute what time today I had any drinks, and I doubt if many of the readers of this can either), there is the interpretation of the data.  I suspect that what was meant was

half Britain's adults have started their first glass of wine on Christmas Day by at 1:12pm soon after 1pm

Cheers!  And Happy Christmas!

Everyday heuristics

Fifty-six years ago, a paper appeared in Operations Research (vol 6, p1-10) with the title: "Heuristic Problem Solving: The Next Advance in Operations Research".  Written by Herbert A. Simon and Allen Newell, it daringly proposed advances in the power of computers to solve problems by heuristic methods, and not by purely algorithmic methods.  It caused a flurry of discussion in the correspondence section of the journal. 

Since then, we have become accustomed to the use of heuristic methods as part of the tool-kit of O.R.  But we do not have one heuristic method for problem solving - we have many.  Some of them have developed into the well-established metaheuristics of simulated annealing, tabu search, genetic algorithms, ant-based algorithms, and many others.  A glance at the content pages of our journals, or (even better since it classifies papers) through the index of the International Abstracts in O.R., will show how often heuristics have been used to advantage in the "Science of Better".  Of course, heuristics are for finding "better" rather than "optimum", although there are many situations where the heuristics do find an optimum.

But it is salutary to look at the frequency of heuristics in the equipment we use in everyday life.  Usually the heuristic is hidden in some computer chip or electronic circuitry, and only by stopping to think about it do we recognise that someone, somewhere, has realised that a heuristic is needed and has programmed it.  One of the earliest papers on heuristics that I ever read (and I can't find a reference to it - any suggestions?) gave a list of simple, everyday heuristics.  "Use an old golf ball when there is water hazard".  "Order a new chequebook when you reach the reminder slip in your present one" and so on.  The second of these examples is now outdated with my bank; the bank's computer has a heuristic which recognises when I am nearing the end of the chequebook, and issues a new one without my need to remind the bank.  I wonder whether the heuristic also has a parameter based on the average number of cheques that I write each month.  So there is a heuristic that affects my life.  

What about others?  We replaced our old car with a newer model a few months ago.  This one has several heuristics built into its control electronics.  With the headlights set to an automatic setting, the lights come on when a sensor detects the ambient light levels to be too low.  That is wonderful - except that the headlights come on when we drive the car into or out of the garage.  They also come on in some Devon lanes, when the hedges or banks create a dark canyon.  The heuristic is good, but it isn't optimal.  The car has sensors for the drag on the windscreen wipers, so adjusts the sweep if there is light rain.  That heuristic can be disconcerting, if, like us, you are used to regular sweeps of the wipers.

The kitchen is another place where everyday life encounters heuristics.  The freezer pump switches on when it detects an internal temperature which is too high - but it is not so sensitive that it will switch on immediately the door is opened.  The oven has a thermostat which controls the heating elements and fan - according to a simple heuristic.  I was surprised to see an advert for an oven which claimed that it could be controlled to an accuracy of one degree Celsius.  None of the recipes that I use require such excessive accuracy.

The radio tunes when there is a signal of sufficient strength.  The mobile phone operates with numerous heuristics.  

So are these heuristics that solve problems part of the breakthrough that Simon and Newell anticipated?  Yes.  They are parts of the hidden application of O.R. in twenty-first century life.  And there are many, many more.

Tuesday, 16 December 2014

Choosing how to travel

When operational research was in its infancy, many O.R. teams prided themselves that they were interdisciplinary.  As the subject has matured, it has become increasingly specialised and a little distant from the idealism of the infant interdisciplinary pattern.  Before I am targeted by correspondents who do work in interdisciplinary or multidisciplinary teams, I know that there are many teams where insights from  biology, engineering, mathematics, physics, psychology and zoology are brought together to solve problems.  But for many people doing O.R., the impact of disciplines other than the corpus of operational research techniques only comes from the language of the client, whether the client is in advertising, production or finance.

What makes me think of this?  A friend was sent a U.K. government brochure, "Britain in 2014", subtitled "Your essential guide to the issues that matter" and produced by the U.K.'s Economic and Social Research Council (E.S.R.C.).  The contents describe a number of sponsored research programmes, without getting into technical detail.  There were many interdisciplinary programmes, and many were tackling the type of "What happens if?" questions that O.R. specialises in.

So I was both interested and disappointed to read an interesting article about commuting to work by bicycle, which has been using GIS data to study peoples commuting in several cities, and modelling behaviour using agent-based simulation.  (Actually, not many O.R. studies in the literature use agent-based simulation, which is also a shame.)  Interested, because throughout my career, I did commute to work by bicycle.  Disappointed, because it was an ideal piece of work for the skills of O.R. to have contributed to.  The link for the reports is here.   It was part of a wider study of transport options for the future in cities.   I wonder whether there were O.R. people who could have helped but for their own reasons did not.  From my own academic experience, it is difficult to work across academic departments; maybe we have dug our own compartments in the ivory tower?  And to write this is not to be critical of the researchers; they have done an excellent job;  it was a study that I would have loved to be part of.



Commuting patterns vary across the country.  London has a very high proportion of commuters.  Parking cars in the city is very expensive.  But the study draws in the GIS and usage data for the use of "Boris Bikes" (cheap hire bikes available across London) which show how many commuters are using these bicycles every day.  Their behaviour has changed because the bikes are available.  What would happen if similar hire bikes were made available in another city?  Agent-based simulation would help answer such a question.

The data for studying commuting falls into the current themes of "Big Data" and "Analytics"; but some of the modelling tools are well-known from the established O.R.corpus - network flow models, epidemiology, time series analysis, stochastic processes. etc.



So, here is a quote from the short report in "Britain in 2014":

The practice of cycling to work can change, with meanings, abilities and stuff all connected.
For example, in the 1980s, virtually no one wore a cycle helmet in the UK; now it is often seen as essential. But this supports cycling being seen as a dangerous activity requiring specialist gear (in high-cycling countries, people wear everyday clothes). The ‘stuff’ you need to cycle depends on what you think cycling means, and what others do. Similarly, the ‘abilities’ you need depend on the cycling environment, and the demands it places on users. 


The project team is developing a model that will represent these practices and how they change, as people interact with each other. The approach, agent-based modelling, represents decisions of individual cycle commuters (agents) who learn from and influence each other and their environments. An agent will only cycle to work if she/he thinks she has enough abilities and stuff to cycle, and on balance cycling has positive meanings for him or her. The stuff, skills and meanings that make up the practice of cycling will vary from place to place.
 

The project will then explore the medium term impacts* of policies, such as building cycle paths or providing cycle training, as they affect the stuff and skills people think are necessary or as they change the meanings associated with cycling. The impact is then played out through the social networks. For example, improving infrastructure might reduce the skills needed to cycle meaning a wider range of people feel able to cycle. Other people then see these different kinds of people cycling or hear about their experiences, changing the meanings of cycling.

* "What happens if?"

How do we make other researchers be aware of the skills that operational research might contribute to their programmes?  

I followed links from the project's webpage to find some splendid maps of transport in the UK, and - nothing to do with O.R. - interesting and amusing maps of London. 

Thursday, 4 December 2014

A change in UK stamp duty

Earlier this year, I posted about the step function tax on buying a house in the UK.  (See here)  The media referred to it as a "block" tax, but mathematicians would tend to think of it as a discontinuous step function on the integer line.

Happily, it was announced that this tax would cease from 00:01 today, to be replaced by a piecewise linear tax on the cost of a house.  So, instead of a tax on the whole price of a house, which meant that the tax on  a £250,000 house was £2500, and if the property costs one pound more, £250,001, the tax was  £7500.03p, there are a series of thresholds, where the tax rate changes, but only for the price in excess of that threshold.

I don't think that the government reads my blogs, but numerous other people have protested at the step function tax regime.  So I think that it is their influence which has swayed the government - that, and the prospect of an election in May 2015.  As this change was announced yesterday, today's media are full of reports of the effect.  One could plot the tax (stamp duty) paid as the dependent variable against house price under the old and new regimes, and find where the lines cross, but most of the media have simply opted to say that if the house costs less than £937,500, the tax will now be less than under the old scheme.  Well over 95% of houses in the UK sell for under that price, so lots of people will rejoice. 

There is an online calculator of stamp duty here.

I referred to the earlier scheme as a bit of game theory.  That no longer applies to the same extent.

Sunday, 23 November 2014

Hidden statistics and parameters of a harvest

My parents owned a large garden, and with it came several old trees from an orchard.  Among them was a large walnut tree, and my childhood memories include collecting the nuts in September and October, and then leaving them in wooden trays to dry.  Then, over Christmas, my parents, my brother and I would take it in turns with the nut-crackers, breaking the shells and extracting the edible nuts.  I don't know whether Christmas was the optimum time as far as the quality of the nuts was concerned; it was clearly a good time for keeping children quiet!  With hindsight, my father must have selected this time by trial and error.  Like so many decision variables, it is one dimensional - too short a time and the nuts will not be dry, too long and they will have lost their flavour.  A second variable, which wasn't changed, was the ambient temperature of the room where they were stored. 

Commercial nut growers face similar decisions, but on a much larger scale.  The crop will not be uniform in moisture content, so the time from harvest to marketing the edible nuts will depend on the weather at harvest time.  But they will have sophisticated instruments for monitoring the crops; my father only had his eyes and the sense of touch, coupled with the possibility of testing samples at intervals.

All this came to mind as I was dealing with some harvest from my own garden.  We grow climbing French beans, of a variety which is no longer available commercially.  The seeds were given to me by a heritage grower, and the beans they produce are delicious, and freeze well.  So, to maintain a crop, we must keep seed from one year's crop for the next.  At the end of the season, we leave a few bean pods on the vines to ripen, and then collect the pods, take them indoors, dry them, and remove the seeds.  Today was the day for extracting the seeds.  Most of the pods had dried out, but not all, and some had started to grow a mould, other had been so wet when they were collected that they had begun to rot - not ideal.  And not all the seeds are viable.  So, I have a box of seeds to plant in 2015.  And I have faced the same decision with them as my father had with the walnuts - how long to allow them to dry out.  For me, it was about one month.  One day, one week, even two weeks, would not have been enough.  Two months would probably have been too much - the rot could have affected them all.  (One year I made the mistake of leaving the pods to dry near the central heating boiler, and the seeds dried out and were cooked.  Fortunately, I had kept some seed from the previous year.) 

Seed merchants have this problem too - though many plants for seed are grown in warmer, dryer climates than my back garden.  And different plants have different characteristics; just ask a biologist.

So, next time you buy a packet of seeds, stop and think of the statistical and biological research that has meant that your seeds will be viable.  All of that research, hidden behind a colourful picture on the seed packet.

That walnut tree no longer stands.  A few years after we came to Exeter, there was a phone call from my father; "We are all right", he said, "but the walnut tree blew down in the night, and we have no electricity because the tree fell on the cable".  Power was restored after a day or two, and my parents had the tree cut up.  As a reminder, we have a wooden bowl, made by a wood turner using part of the trunk.

Harvesting the nuts led me into trouble at school.  The outer casing of walnuts is a soft green shell, which turns black and oozes a liquid which stains.  As a youngster, I would often collect the nuts, give my hands a cursory wash, and catch the bus to school.  I would arrive with my hands marked with a yellowish stain; since nobody in the family smoked, I didn't know about nicotine stains, but people at school did, and accused me of being a secret smoker.  As collecting walnuts is not in many schoolchldren's experience, nor that of many schoolteachers, my explanations were regarded as a way of disguising my misdemeanours.  The stain did wash away, but walnut skins are still used to produce natural dyes. 

Tuesday, 7 October 2014

Barrier functions

If you have searched for "Barrier functions" and are interested in one way of optimising a nonlinear function subject to constraints, look away now.  This blog entry is not about that topic, but I could not resist the joke.

Exeter is built on the River Exe - hence its name.  The river is prone to flooding, and just over fifty years ago, there were some disastrous floods which damaged a great deal of property.  As a consequence, flood relief channels were dug parallel to the river, to divert some water - in effect to make the river wider when the river flow peaked.  The Exe is a fairly short river (about 60 miles) and its flow reacts to rainfall quickly, so that a storm in its headwaters leads to flooding at Exeter within 12 to 24 hours.   After more floods in the last few winters, there are plans to deepen the flood relief channels, and work on one site is under way.

That is quite close to our house, and Tina and I have a convenient walk, from our home, down to the river across one bridge, along the footpath that is bordered by the flood channel, across a second bridge and back home.  If we don't stop, it takes 45 minutes, but we often do stop, to look at birds or to talk to friends we meet.  (We call it the "Sunday morning walk" because we used it to give us exercise when we were both working, and we could do it before going to church on Sunday.  When we went trekking in Nepal, we prepared for that journey by repeating the circuit as often as we could.)

The construction site is a large one, and the contractors have had to fence the area to keep out dogs and stray children.  But it must not be impenetrable in case any of these do manage to cross it.  There are no dangerous materials on the site, as they and the equipment are kept in a secure compound a short way away.  The fence acts as a deterrent, and is about 3500 feet long.  So, how would you design a fence at minimal cost for such a site? 

Off the shelf solutions:
  •  Rentable fencing panels;  idea rejected due to cost, aesthetic appeal (nil) and being more than is needed.
  •  Posts and plastic mesh fence; idea rejected due to being insufficient deterrent and lack of aesthetic appeal.
  •  Barbed wire fence; rejected because the footpath is well used by walkers and cyclists and the fence woul be too close to them.
  •  Post and rail fence; insufficient barrier and very expensive

So, the site workers have erected a fence with posts and wire mesh, topped with three strands of strong wire.  The wire mesh reaches from the ground to a height of about 800-900mm, and the parallel strands of wire are about 50mm, 150mm and 250mm above the top of the mesh.  The barrier is almost impenetrable for dogs and children, but an adult could cross - with a little difficulty - if it were necessary to retrieve a dog, a child, etc

I suspect the components are disposable in spite of the waste of material.  The wire mesh is probably a standard size, but someone has had to decide on the design, which is where Operational Research could be of value.  The design has these decision variables:
  • (a) mesh size (from manufacturer's range)
  • (b) mesh shape
  • (c) width of the mesh
  • (d) number of wire strands
  • (e) position of each wire strand
  • (f) separation of posts on straight runs

All of these were probably decided by rules of thumb (aka heuristics) but the sight of the site and its fence made our most recent walk more interesting as we thought about the decisions.


Wednesday, 17 September 2014

I hate mathematics (or, I am proud to be innumerate)

For some reason, many men and women are unashamed when they do not understand mathematics, and cannot cope with day to day mathematics.  As Operational Research is a discipline which uses mathematics as an everyday skill, it can be galling to meet such people.  I came across a book review which eloquently challenged adults with such an attitude to what should be an everyday skill.

For those who persist in blathering that "maths is not my thing", it is high time that they put away such philistine nonsense and allowed the fine and elegant art that exists at the mathematical end of the spectrum of knowledge to entertain and illuminate in ways that complement and give proper balance to the poetry, painting, theatre and theology at the other.

(This comes from a review of the book "Alex through the looking glass: How life reflects numbers and numbers reflect life" by Alex Bellos, reviewed in Third Way magazine by Kester Brewin (vol 37, no 7, p38))

Personally, I would argue against mathematics being at an end of the spectrum of knowledge (which is a bit of a cliché)