本文整理汇总了Python中market.Market.tatonnement方法的典型用法代码示例。如果您正苦于以下问题:Python Market.tatonnement方法的具体用法?Python Market.tatonnement怎么用?Python Market.tatonnement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类market.Market
的用法示例。
在下文中一共展示了Market.tatonnement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sell_labour
# 需要导入模块: from market import Market [as 别名]
# 或者: from market.Market import tatonnement [as 别名]
def sell_labour(self, environment, time):
# First we find the market equilibrium price
# Important to note that this currently does
# not depend on the wealth of the buyers
# That is their demand may be higher than
# what they can actually buy, which may be ok
# We set the values necessary for tatonnement
# The list of sellers and their supply functions
sellers = []
for agent in environment.households:
sellers.append([agent, agent.supply_of_labour_solow])
# And the list of buyers and their demand functions
buyers = []
for agent in environment.firms:
buyers.append([agent, agent.demand_for_labour_solow])
# We may start the search for price at some specific point
# Here we pass 0, which means it'll start looking at a
# random point between 0 and 10
starting_price = 0.0
# We initialize the price
price = 0.0
# Import market clearing class
from market import Market
# Put the appropriate settings, i.e. desired identifier
market = Market("market")
# And we find the market price of labour
# given supply and demand of the agents
# and tolerance of error, resolution of search
# and amplification factor for exponential search
price = market.tatonnement(sellers, buyers, starting_price, 0.00000000001, 0.01, 1.1)
environment.variable_parameters["price_of_labour"] = price
# now we use rationing to find the actual transactions between agents
for_rationing = []
for household in environment.households:
for_rationing.append([household, household.supply_of_labour_solow(price)])
for firm in environment.firms:
for_rationing.append([firm, -firm.demand_for_labour_solow(price)])
# And we find the rationing, ie the amounts
# of goods sold between pairs of agents
rationed = market.rationing(for_rationing)
#
# A (from) L (to)
# bank loan deposit
# household deposit labour
# firm labour loan
#
for ration in rationed:
# The labour is an asset (production factor) for the firm
# and a liability (promise to work) for the household
environment.new_transaction("labour", "", ration[1].identifier, ration[0].identifier,
ration[2], 0, 0, -1)
random_bank = random.choice(environment.banks)
# Deposit is a liability of the bank
# and an asset of the household
environment.new_transaction("deposits", "", ration[0].identifier, random_bank.identifier,
ration[2]*price, random_bank.interest_rate_deposits, 0, -1)
# Loan is an asset of the bank
# and a liability of the firm
environment.new_transaction("loans", "", random_bank.identifier, ration[1].identifier,
ration[2]*price, random_bank.interest_rate_loans, 0, -1)
# We print the action of selling to the screen
print("%s sold %d units of labour at a price %f to %s at time %d.") % (ration[0].identifier,
ration[2], price, ration[1].identifier, time)
logging.info(" labour sold to firms on step: %s", time)