# How well might PID control work instead of Bid/Ask for a market?

I’ve been working on a basic simulation for market economics for a little game I’m putting together.

In the game, there’s commodities, and “villages” where people produce and consume commodities.

Let’s use rice for an example. The villagers make a certain amount of rice, which goes onto the market. A certain amount of rice is available in the storehouses of the village to be traded about. Villagers and outsiders buy rice and eat it, and villagers and outsides bring in new rice and sell it.

So you have three variables here : Rice_IN, Rice_Out, Rice_Stored.

Well, I thought about it, and realized that the village has a “setpoint” for how much rice the village should have in it’s storehouses at any given time. If it’s the start of winter, the village needs full storehouses, while at the end of winter they should be near empty, and during the growing season the setpoint should change according to a linear curve between the start and end of the growing season.

The “price” for rice is a signal for how much rice “should” be in the village’s stores. If the stores are low compared to the setpoint, the price should be high, and if the stores are high, the price should be low.

The way most economies work, all the buyers and sellers hold various auctions to determine the market price. But why determine the price this way?

Instead, decide on your “setpoint” for the total amount of goods that should be on hand. Use a PID control algorithm to determine the “price” most optimal for keeping that setpoint.

This should work reasonably well for my little game, but this got me thinking…

What would happen if you tried to control market prices in the real world this way? You don’t get the classic shortages and surpluses you get with normal “price controls”, because if there’s a shortage, the price will go up, and vice versa.

Technically it still uses people’s preferences in that demand at any given price will determine the actual flow of goods. I suspect that using the PID algorithm instead of bid/ask would remove some of the irrational things current markets do. For instance, if actual supplies of a given good are still plentiful, but there’s bad news for the future, the price would not skyrocket.

Isn’t that the road to hell, paved with good intentions, of centrally-planned economies?

Markets work with human nature – flawed and rough-edged and irrational – rather than against human nature by trying to be hyper-rational and neglecting the element of illusion in human assessment of value.

Markets pay the prices that people think are right. They work by mutual agreement. They satisfy desires.

They don’t actually meet needs; they meet what people perceive as needs.

Sure. Calling it a “centrally planned economy” isn’t quite accurate. If people want more of a given good, and are willing to pay for it, they get that good.

I suspect this is just a variant of the classic “market economy” that uses a control algorithm as a filter to reduce wild swings up and down in price.

You could build an auction house that worked this way. It’s pretty simple. Sellers give you goods for your house to sell within the next <time interval>. So now you’ve got a quantity of goods that needs to go out the door before the time interval expires. Buyers are buying goods at a certain rate.

If the rate is high enough that all goods will sell before time interval is over, the price is too low. And vice versa.

You’d use PID or some other control algorithm to determine the correct price for goods so that the entire consignment will sell by the end of the <time interval>. Of course sellers could specify a minimum price they are willing to accept.

From the perspective of buyers, when they walk into the auction house, the goods would be offered at a fixed price, just like they are now.

What’s irrational about raising prices in light of a future shortage?

Nothing, I’m saying that this mechanism might protect from catastrophic price spikes that are far in excess of the actual new price needed to match supply with demand.

I don’t understand how this is different from traditional market demand and supply. Your setpoints now represent demand, but those setpoints have to be set by people. You’re just abstracting that step and assuming that setpoints will not change to reflect demand, but, in fact, they will.

Well, there’s certainly precedent for regulated markets.

In the U.S., for instance, there are laws against price-gouging in emergencies. Say a big hurricane is about to hit the coast; there are laws that prohibit markets from suddenly jacking up the price of bottled water several hundred per cent. A perfectly “free” market would let the price go wherever the hell people would pay.

So, if all you really have is a free market with some regulations to prevent panics, that’s great! I’m all for it!

If I understand correctly, your system just decides what prices the village should enter the market at for buy/selling. It hasn’t actually taken away the auction component. A bunch of villages behaving like this are going to be competing in an auction-like fashion. Essentially you’re just imposing the “rational actor” constraint on all of the players, which planners and economists would love to be true. You haven’t constrained the market in which the players play.

If there’s a rice shortage, everyone is going to find more rice going out than coming in, so they’ll be raising their own buying price. Whoever raises their price highest will get people deliberately buying elsewhere and travelling to the village to sell rice.

In a real economy doing this the market will be distorted in all the usual ways. If a village thinks the price is too low, they may deliberately let their stockpile grow in the hope of a future shortage. Information about future shortages will encourage higher prices, and information about future gluts will encourage lower prices.

Before you know it villages will be trying to insure against gluts and shortages by putting in place fixed-price contracts based on their future needs and outputs, and there’ll be a full-blown futures market.

Thanks for this comment. You’re the first poster in the thread with some meaningful feedback. This is what I suspected was true - it’s still a market, with all the pros and cons, you’ve just simplified one of the variables by making the “sell” price be determined autonomously.

In your example, if current spot prices were artificially kept low, even in the light of expected shortages, you incentivize enterprising entrepreneurs to go acquire storage facilities, buy rice at the current low price and hold it until the shortages are realized and sell it when prices ultimately peak.

The problem is that the PID control system has to be replicated for each shop , in each street, in each suburb of each town… it would work if it was like that, but the free market is where the PID control is in the mind of the shop manager, so each shop on each street in each town in each state…

Further , chain stores and supermarkets are run on “JIT” which means that the PID controller has nothing to measure -there is never a build up of excesss stock, there is never a shortage of stock, well none that is related to changes in price vs demand…