Barbershop Problem
This is a side project I am doing for fun while I have some spare time. It concerns the modeling of an economics problem that I learned about last semester. While I won't share my simulations just yet—I want to first do some meta-level analysis of the system as a whole—I'll share the problem statement here because I think it's interesting.
Simulating the Barbershop Problem
I've got a free Sunday, so I figured I'd try my best to go tackle a problem that's been itching the back of my mind since I first learned about it in last semester's microeconomics class. Imagine a town where there are two barbershops. The two barbershops are equal in every way, except location. As such, customers will always go to whichever is closer whenever they need a haircut. The owners of the barbershops wish to maximize their profits, meaning they need to maximize their number of customers.
The interesting part is that the barbershops are mobile. Once per time step, each barbershop may relocate itself one "step" in any direction. For example, consider the following one-dimensional town, which is just a long strip. Imagine that the barbershops start at either end of town. Then, each will attract half the customers of the town, which is homogeneous in population density:
[Barber 1]-----------------------------------------[halfway point]-----------------------------------------[Barber 2]Barber 2 will realize that, should she relocate one pace closer to the center of town, she'll move the midpoint a little to the left. Therefore she will capture a couple more customers, while still retaining those that are now located to her right:
[Barber 1]-----------------------------------------[halfway point]------------------------------------[Barber 2]-----Barber 1 will realize the same, and will relocate accordingly, moving the midpoint back to the center of town. Ultimately, the situation settles at a stable Nash equilibrium with both barbers setting up shop in the center of town. However, according to my econ professor, two agents is the only situation that gives us this easy, stable Nash equilibrium. Once you add a third, you end up with oscillating swings and chaos.
You can imagine this problem being applicable to many (less contrived) scenarios. For example, you might think of political candidates in a two-party system attempting to appeal to the median voter while remaining radical enough to satisfy the far ends of a one-dimensional political spectrum. Alternatively, you can think of two products of high-end and low-end quality/price, respectively, competing to be the go-to product for a median-income buyer.
In this notebook, I want to simulate this problem to make sense of that chaos. I plan to start with the simplest possible example—a discrete one-dimensional town with two barbers—and eventually expand into having arbitrary numbers of agents in a higher-dimensional continuous space, perhaps even exploring the possibility of "intelligent" agents who are willing to sacrifice short-term profits in exchange for the ability to push their competitors into suboptimal positions.
Animation from later in the notebook for the continuous two-dimensional case with six agents.
More to come on this side project later (dated 10/12/2026).