*Disclaimer: The model doesn’t fully solve, as is the difficulty with general equilibrium models. Thought on how to proceed are greatly appreciated and will be implemented!

Price plays the role of equilibrating demand and supply so that all buyers who want to buy at the market price can, and similarly all sellers who want to sell at the going price also can, with no excess or shortages on either side. The extension from this partial equilibrium in a single market to general equilibrium reflects the idea that it may not be legitimate to speak of equilibrium with respect to a single commodity when supply and demand in that market depend on the prices of other goods. On this view, a coherent theory of the price system and the coordination of economic activity has to consider the simultaneous general equilibrium of all markets in the economy. The question of whether this equilibrium exists and what it’s properties are is answered by Walras’ general equilibrium theory. This article attempts to build a general equilibrium using an agent based numerical simulation, in order to identify where this approach has shortcomings.

To this end, consider the following model, and the model source code in python:

The agents’s problem

individuals ( ) in the economy and companies ( ) that produce goods during time every period. Individuals have the utility function: There areindividuals () in the economy andcompanies () that produce goods during timeevery period. Individuals have the utility function:

where l is leisure is the product of company and reflects the valuation has of the product of company . Each individual will maximize his/her utility with respect to a simple cost function, without endowment: For this very simple model we assume that all individuals are homogenous in skill. Maximization yields the first order conditions:

We can plug this last condition into the budget constraint in order to obtain leisure choice as a function of consumer preferences:

The firm’s problem

In the attempt to model an economy in equilibrium using a finite number of firms and agents, the firm solves a decision problem of it’s own. Consider the production technology of firm which takes labor as an input

The firm maximizes the profit function:

Maximization leads the first order condition:

We know that for the goods market to clear, the supply of good must equal demand for it. Thus the market clearing condition is:

From this, we can determine the price the firm will set in order to clear the market:

Obviously, the value of hard currency cannot be defined by ordinal weighting parameters. This requires the introduction of a numeraire good, the value of something in this world in order for all other prices to be relative to it. if we choose either any price we see , or we choose directly. For the simulation, I choose to set

Will the market’s clear?

import sys import random

Firstly, we define the company according to the equations specified above:

class Company: pass profit = 0 production = 0 product_price = 0 consumer_valuation = 0 def calc_profit(): pass def __init__(self, name, product_name, labor_weight, wage): self.name = name self.product = product_name self.labor_weight = labor_weight def produce(self, wage): self.production = self.labor**(self.labor_weight) self.varcosts = wage*self.labor self.profit = self.production*self.product_price - self.varcosts def comp_labor(self, wage): self.labor = (wage/(self.product_price*self.labor_weight))**(1/(self.labor_weight-1)) print(self.product_price) # self.labor = (wage/(self.product_price))**(1/(self.labor_weight-1)) def get_comp_price(self, wage, consumer_valuation): if self.labor_weight ==1: self.product_price == wage self.comp_labor(wage) self.produce(wage) else: elem1 = wage elem2 = (1/self.labor_weight)**(self.labor_weight) # elem2 = 1 elem3 = consumer_valuation**(1-self.labor_weight) self.product_price = elem1*elem2*elem3 self.comp_labor(wage) self.produce(wage) def __str__(self): return "%s produces %s" %(self.name, self.product)

Next we define the individual accoring to the equations, specified above

class Individual: time = 1000 ## assume s is determined through the rate of time preference wage = 0 baseline = 0 goods = {} goodprices = {} labortime = 0 def set_weights_manually(self, list_comp): ## takes as input a list made up of Companies that are producing something for comp in list_comp: weight = input("Please enter the weight for %s: " %(comp.name) ) self.compval[comp.name] = weight self.baseline = 0 for key, elem in self.compval.items(): val = elem self.baseline += float(val) self.baseline += self.leisure_weight def set_weights_random(self, list_comp): ## takes as input a list made up of Companies that are producing something for comp in list_comp: weight = random.randint(1,10)/10 self.compval[comp.name] = weight self.baseline = 0 for key, elem in self.compval.items(): val = elem self.baseline += float(val) self.baseline += self.leisure_weight # for key, elem in self.compval.items(): # comp = key # val = elem # self.compval[comp] = val/self.baseline # for key, elem in self.compval.items(): # val = elem # self.baseline += float(val) # self.baseline += self.leisure_weight def __init__(self, name, leisure_weight, wage): ## you are born with an endowment, passed down from previous generations self.name = name self.leisure_weight = leisure_weight self.compval = {} self.wage = wage def utility(self): pass def calc_demand(self, Company): price = Company.product_price self.goodprices[Company.name] = price try: consum = (self.wage*self.time/price)*self.compval[Company.name]/(self.baseline) #print(self.wage, self.time, price, self.compval[Company.name], self.baseline, consum) except: print("The company name was not in compval. Or the wage is not defined. Or the price isn't. Do something.") consum = 0 self.goods[Company.name] = consum return consum def calc_labor(self): total_expenditure = 0 for key, elem in self.goods.items(): quantity = elem price = self.goodprices[key] total_expenditure += quantity * price self.leisure = (self.leisure_weight/self.compval[key])*(quantity/price) self.labortime = self.time - self.leisure # Alternative: # self.labortime = total_expenditure/self.wage # self.leisure = self.time - self.labortime #print("Expenditure: ", total_expenditure, "My Labor Time: ", self.labortime, "My Leisure: ", self.leisure) def __str__(self): return "This is %s" %(self.name)

Once the individuals agents are defined, we need a function to aggregate the consumer valuations which are required to calculate demand.

def consumer_valuation(Company, individual_list): consumer_valuation = 0 relsum = 0 for indi in individual_list: rel = indi.compval[Company.name]/indi.baseline relsum += rel #print(rel, relsum) time = indi.time consumer_valuation = relsum*time return consumer_valuation

The code above is the basis for the actual model, which is outlined here. We initially choose the number of firms and individuals who will interact and let the market reach an equilibrium according to the equations developed above. I import the basis file as agbm

import agbm as agbm import random ### you need one price that all the others are relevenat to. You can pick one sector and pick the price. this will give you the wage in that ### sector. Or you can choose to make the wage the numeraire, directly. wage = 10 m = 5 n = 1000 comps = [] x = 0 while x<m: rand = random.randint(1,99)/100 print(rand) company1 = agbm.Company(x, "Joghurt", rand, wage) comps.append(company1) x += 1 lili = [] x = 0 while x < n: rand = random.randint(1,99)/100 print(rand) ind1 = agbm.Individual("Philipp", rand, wage) ind1.set_weights_random(comps) lili.append(ind1) x += 1 print(lili) def market(lili, comps, wage): for comp in comps: consumval = agbm.consumer_valuation(comp, lili) #print(consumval) comp.get_comp_price(wage, consumval) price = comp.product_price product = comp.production labor = comp.labor print("price: ", price, "product: " , product, "labortime: ",labor ) def demand(lili, comps, wage): demand = {} totalwork = 0 totallabortime = 0 for indiv in lili: for comp in comps: indiv.calc_demand(comp) value = indiv.goods[comp.name] try: demand[comp.name] = demand[comp.name] + value except: demand[comp.name] = value indiv.calc_labor() totallabortime += indiv.labortime #print(indiv.goods) for comp in comps: totalwork += comp.labor #print(comp.profit) print("Work statistics: " ,totallabortime, totalwork, totallabortime/totalwork) labormarketclear = totallabortime/totalwork print(demand) return labormarketclear market(lili, comps, wage) demand(lili, comps, wage)

The coefficients in this parameterization are randonmly determined, thus the result will vary sightly. However there is a clear pattern. Prices adjust in this model in a way to make supply equal demand in the good market but not in the labor market. From the print statements we know that:

Company Price Production Total Demand Labor Demand Firm 1 1470.53 1133.41 1133.41 101670.29 Firm 2 32.24 53411.84 53411.84 156749.48 Firm 3 32.24 53411.84 53411.84 111968.11 Firm 4 28.37 62073.87 62073.87 162062.88 Firm 5 27914.65 58.90 58.90 160838.85

Total labor demand is thus: 593289.61. However, total labor supply is 999999.99. Thus agents would have to work 1.68 times as many hours in order for the goods market to actually clear.

Why doesn’t the labor market clear?

In order for the market to clear, under the conditions laid out above, demand out to equal supply. This would be the case if:

For this market to reach equilibrium, the parameters would have to have a unique relationship, for it is not possible to solve this for any given parameters.

Thus, we cannot just derive the FOC for both the firm and the individual, for it is either not enough work, or not enough labor available if the labor market does not clear. The question arises ow to best internalize this restriction. I’m happy to receive feedback!