Friday, March 19, 2010

Buddhism in a Nutshell

I'm reading Richard Gombrich's What the Buddha Thought (Equinox 2009), and just came upon this wonderful nugget (p. 74):
You cannot see things straight because you are blinded by passion, and you allow your emotions to control you because you do not see things as they are.

Wednesday, March 10, 2010

Automotive Black Boxes

The problems that Toyota is having with stuck accelerators needn't be chalked up entirely to shoddy engineering or corporate greed. Modern cars are very complicated systems which are very difficult to design flawlessly or to diagnose when failures occur. And it's not just cars that are getting more and more complicated!

This rise in complexity is in part due to the pull of rapidly advancing digital electronic technology. Compute power is so cheap, it becomes the optimum way to provide what the customer demands: performance and economy. And customers do demand ever more performance and economy, whether it's due to constraints or worries about the environment, or just because it's what they're conditioned to expect by automotive advertising.

Improvements in safety and efficiency seem entirely positive, but if the cost in complexity brings new risks from rare but catastrophic failures, the gain is not so entire. If 95% of customers have an improved experience, but 0.1% suffer dreadful consequences, the trade-off is not obviously worth pursuing.

But if manufacturers of such complex but safety-critical products could more effectively address the risks of rare but catastrophic failure, so the failure rate could be reduced dramatically, the gains in routine safety and efficiency could be enjoyed with much less risk.

One important such mechanism is already in widespread use in the airplane industry: the black box. It may now be time for the introduction of black boxes into automobiles. Something like a flash drive could record perhaps a half hour's worth of data - the movements of the steering wheel and the pedals, together with engine and wheel speeds, at the very least. Key data from various subsystems should also be included - whatever information could best help engineers diagnose the cause of whatever catastrophic failure might occur.

There are also tools available to help designers find and fix rare design flaws, so they never escape to the field to cause failures. But it is unreasonable to expect activities like driving cars and flying airplanes to be perfectly safe. Reality always has more tricks in reserve than any design team can anticipate.

While engineers certainly must work diligently to eliminate flaws, the real key to progress is to learn from whatever failures occur despite one's best efforts. Modern cars have become so complex that the gross evidence of tire skid marks and observers' memories are insufficient to enable diagnosis of rare failures. Black boxes in automobiles could provide an economical and effective way to learn from those failures so the problems can be fixed before more lives are risked.

Tuesday, January 19, 2010

Luck

Where are these spikes coming from?

A quick review: I am simulating the evolution of strategies for playing Prisoner's Dilemma. I have a parameterized version of the classic strategy TIT FOR TAT. At each generation, I have 100 strategies, i.e. 100 different combinations of values of the four parameters that define a strategy. Each strategy is played against every other strategy for 100 or 300 iterations. Each strategy accumulates a total score across all these iterations and opponents. After all the play of one generation, the lowest scoring half the the strategies are eliminated. The remaining strategies, that scored in the top half, are then combined in a randomized way to generate enough new strategies to bring the total back to 100, and a new round of play is begun.

The graph above is a plot of the numbers of defect-defect, defect-cooperate, and cooperate-cooperate moves for each generation. For this experiment I let each pair of strategies play each other for a run of 300 iterations, instead of 100. The frequency of spikes is thereby reduced.

The most interesting parameter seems to be - given that the opponent has been defecting recently, with what probability should the current strategy cooperate? This probability appears to settle slowly down to around 0.05, then jump rapidly at irregular intervals to around 0.2.

I ran a strategy with this "unwarranted cooperation" parameter set to 0.1, against the classical TIT FOR TAT, for 100 runs, each of which was 100 iterations long. TIT FOR TAT never won a run of 100 iterations - at best it tied. The 20th through 80th percentile runs had the 0.1 strategy winning by 5 points. The best the 0.1 strategy did against TIT FOR TAT was to win by 15 points.

I then played a 0.2 strategy against the 0.1 strategy. the 0.1 strategy generally won - the best it did was to win by 110 points. The median margin was 45 points. 80 percent of the time it won by at least 25 point. But the 0.2 strategy did win at least once, by 25 points.

I think this explains the spikes, or at least starts to. The results of the playing at each generation are not well determined - the distribution of results has some significant range. There is a general drift toward defection, but now and again there is enough lucky cooperation that the cooperating strategies can survive and reproduce.

Another source of randomness is the creation of the new strategies to be added to play in the next generation. Each new strategy is constructed from two randomly chosen surviving strategies from the current generation. If by chance two relatively cooperative strategies are chosen, their child is sure also to be cooperative. The more strategies there are that are cooperative, the more they have the opportunity to increase their scores through mutual cooperation.



Monday, January 18, 2010

backwards

Oops! Reviewing my code... I see that I had the logic backwards. The probability that keeps spiking is actually that of an unwarranted cooperation! Here is a plot with the total numbers of defect-defect, defect-cooperate, and cooperate-cooperate rounds of the game. There are 100 strategies, so that is 4950 pairs, and each pair is run for 100 iterations. Thus the total across all three categories should be 495, 000. Whew! Looks like a match!

Sunday, January 17, 2010

Elimination Rate


Each generation, I am saving the best strategies to run again in the next generation. There is no limit to how long a strategy can be kept - as long as it doesn't get eliminated, it will be kept.

However many strategies are eliminated, I will create the same number of new strategies, so that in each round of play there are the same number of strategies, 100, competing. Each new strategy is created by combining two existing strategies. These two strategies are picked at random from the strategies that scored well enough to be kept for the next generation.

Now I am sorting the scores on each round of play, so I can control the fraction of strategies I eliminate. Here is the graph of evolution of the probability of unprovoked defection, when I eliminate the bottom scoring half of the strategies in each generation:
I have added a couple new lines to this graph - now I am plotting the smallest and the largest values across the 100 strategies, along with the 20th and 80th percentiles, and the median.

If instead I only eliminate the bottom scoring 20% of the strategies, here is how things evolve:

Details, Details

Here's the evolution of the probability of unprovoked defection, when I reduce the level of mutation allowed to 3% instead of 5%. The spikes are certainly much less prominent and their onset is less abrupt.

There is another factor that I am not controlling very carefully - the fraction of strategies that is eliminated in each generation. What I am currently doing is just taking the midpoint between the highest score and the lowest score. The strategies that score below the midpoint are eliminated. Sometimes that might eliminated 40% of the strategies, sometimes 60%. I need to control that fraction more carefully, and to investigate how the pattern of evolution varies and the fraction changes.

Saturday, January 16, 2010

The Literature

OK, I do need to see what others have discovered - this game is quite classical by now, so there must be a considerable literature.

Robert Hoffmann's paper "The Ecology of Cooperation" looks really good for a starting point:

http://www.nottingham.ac.uk/~lizrh2/papers.html