The basic model underlying the simulation is a model of supply and demand for each good in each of the cities. Demand for the jth good in the ith city, Dij, depends on the price of the good Pi and the population of the city Zi according to the equation:
Dij = 200 - (20/Zi)*Pij
As the city grows in population, the demand curve gets flatter, rotating around its fixed intercept of $200, leading to higher quantities demanded at any given price.
Supply of the jth good by the kth city to consumers in the ith city, Sijk, depends on price, population, the level of technology in the kth city, and the transaction costs for shipping between the two cities Cik, according to the equation:
Sijk = Tjk + (16/Zi)*(Pij - Cik)
where Tjk depends on the level of technology in the city and ranges from $100 (technology level 0) down to $5 (technology level 5). As the city improves its technology, its supply curve shifts down; as the city grows, its supply curve beomes flatter. Supply is constrained to be zero if Pij < (Tjk+Cik); that is, if the price in city i is not high enough to cover the production cost of the first unit of the good Tjk plus the shipping cost Cik. Note that production costs depend on Sijk (the quantity shipped between cities i and k) rather than on Sjk (the total quantity of good j produced by city k); this is done to simplify the mathematics of calculating the equilibrium prices. (It is consistent with a model in which the production technology has constant marginal costs but the shipping technology has increasing marginal costs.)
Equilibrium occurs when prices in each city, for each good, are such that demand in the city equals the total supply to that city by all cities (including itself). The program then calculates total gains from trade for each city (assigning consumer surplus to the demand city and producer surplus to each supplying city). The city's income is proportional to this surplus; population growth in each city is 5% plus or minus the percent by which its per capita surplus is above or below the average per capita surplus in all cities. Thus, those cities which consume and produce more goods will have higher incomes and faster population growth.