The diagram shown above illustrates the law of supply and demand with a set of interconnected stocks and flows. Stocks are represented by boxes and flows are represented by arrow-headed pipes with a faucet in the middle.
Without knowing the supply and demand curves, equilibrium price can be found by stabilizing the inventory of goods produced and consumed. Price is raised when the inventory decreases and it is decreased when the inventory increases, until equilibrium is reached.
The diagram can be translated into a system of first order differential equations as follows:
inv'[t]==sup[price[t]]-dem[price[t]],price'[t]==-0.2*inv'[t],price[0]==initprice,inv[0]==initinv
where:
sup[p_]:=p;dem[p_]:=20.-p
The equations can be interpreted as follows:
1
.The changes in the inventory (derivative of inventory) is equal to production (supply) less consumption (demand).
2
.Price is changed proportional to the changes in inventory.
3
.At time = 0, initial condition, price = initprice and the inventory is initinv
The graph shows changes in inventory and changes in price until equilibrium is reached.
In[]:=
Manipulate[Plot[Evaluate[{inv[t],price[t]}/.NDSolve[model[price0,lev0,lev],{inv,price},{t,0,50}],{t,0,25}],AxesOrigin{0,0},PlotRange{Automatic,{0,50}},PlotLegendsPlaced[{"Inventory level","Price"},Above],GridLinesAutomatic,ImageSizeLarge],{{price0,6.,"Initial price "},1.,15.,1.,Appearance"Labeled"},{{lev0,35.,"Initial inventory level "},1.,50.,1.,Appearance"Labeled"},ControlPlacementTop,Initialization(model[initprice_,initinv_,deslev_]:={inv'[t]sup[price[t]]-dem[price[t]],price'[t]-0.2*inv'[t],(*pricechangesinverselyproportionaltochangesininventory*)price[0]initprice,(*initialprice*)inv[0]initinv(*initiallevelofinventory*)};sup[p_]:=p;(*inverseofthesupplycurve.Quantitysuppliedorproducedbasedonprice*)dem[p_]:=20.-p(*inverseofthedemandcurve.Quantitydemandedorconsumedbasedonprice*))]
Out[]=
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
System dynamics and the law of supply and demand
by Ricardo MARTINEZ-LAGUNES
Wolfram Community, STAFF PICKS, June 4, 2025
https://community.wolfram.com/groups/-/m/t/3473763
by Ricardo MARTINEZ-LAGUNES
Wolfram Community, STAFF PICKS, June 4, 2025
https://community.wolfram.com/groups/-/m/t/3473763

