def main(): for parameters in read_parameters(): w = Simulation(parameters) action_list = [ ('household', 'sell_labor'), ('firm', 'buy_labor'), ('firm', 'production'), ('firm', 'panel'), ('firm', 'sell_goods'), ('household', 'buy_goods'), ('household', 'panel'), ('household', 'consumption') ] w.add_action_list(action_list) w.declare_round_endowment(resource='adult', units=1, product='labor') w.declare_perishable(good='labor') w.panel('household') w.panel('firm') w.build_agents(Firm, 1) w.build_agents(Household, 1) w.run()
def main(parameters): simulation = Simulation(rounds=parameters['rounds'], processes=1) simulation.declare_round_endowment(resource='adult', units=1, product='labor') simulation.declare_perishable(good='labor') simulation.aggregate('household', possessions=['money', 'GOOD'], variables=['current_utiliy']) simulation.panel('firm', possessions=['money', 'GOOD'], variables=['price', 'inventory']) firms = simulation.build_agents(Firm, 'firm', number=parameters['num_firms']) households = simulation.build_agents(Household, 'household', number=1, parameters=parameters) for r in simulation.next_round(): households.do('sell_labor') firms.do('buy_labor') firms.do('production') firms.do('panel') firms.do('quotes') households.do('buy_goods') firms.do('sell_goods') households.do('aggregate') households.do('consumption') firms.do('adjust_price') simulation.graphs()
def main(simulation_parameters): simulation = Simulation(rounds=simulation_parameters['rounds']) action_list = [('firm', 'one'), ('household', 'two'), ('all', 'three') ('household', 'panel')] # this instructs ABCE to save panel data as declared below simulation.add_action_list(action_list) simulation.declare_round_endowment(resource='labor_endowment', units=1, product='labor' ) simulation.declare_perishable(good='labor') simulation.panel('household', possessions=['good1', 'good2'], # put a list of household possessions to track here variables=['utility']) # put a list of household possessions to track here simulation.build_agents(Firm, 'firm', number=simulation_parameters['firms'], parameters=simulation_parameters) simulation.build_agents(Household, 'household', number=simulation_parameters['households'], parameters=simulation_parameters) simulation.run() simulation.graphs()
def main(parameters): w = Simulation(rounds=parameters['rounds']) action_list = [ ('household', 'sell_labor'), ('firm', 'buy_labor'), ('firm', 'production'), ('firm', 'panel'), ('firm', 'sell_goods'), ('household', 'buy_goods'), ('household', 'panel'), ('household', 'consumption') ] w.add_action_list(action_list) w.declare_round_endowment(resource='adult', units=1, product='labor') w.declare_perishable(good='labor') w.panel('household', possessions=['money', 'GOOD'], variables=['current_utiliy']) w.panel('firm', possessions=['money', 'GOOD']) w.build_agents(Firm, 'firm', 1) w.build_agents(Household, 'household', 1) w.run()
def main(simulation_parameters): simulation = Simulation(rounds=simulation_parameters['rounds']) simulation.declare_calendar(2000, 1, 1) simulation.panel('agent', possessions=['money']) simulation.aggregate('agent', possessions=['labor']) agents = simulation.build_agents(Agent, 'agent', number=1) for r in simulation.next_round(): date = simulation._round if date.weekday() == 2: agents.do('wednessday') if date.day == 1: agents.do('first') if date.month == 12 and date.day == 31: agents.do('newyearseve') if date.day <= 7 and date.weekday() == 4: agents.do('firstfriday') if date.month == 15: agents.do('fiveteens') if date.toordinal() % 3 == 0: agents.do('everythreedays') agents.do('panel') agents.do('aggregate') simulation.graphs()
def main(parameters): simulation = Simulation(rounds=parameters['rounds'], cores=1) action_list = [ ('household', 'sell_labor'), ('firm', 'buy_labor'), ('firm', 'production'), ('firm', 'panel'), ('firm', 'quotes'), ('household', 'buy_goods'), ('firm', 'sell_goods'), ('household', 'aggregate'), ('household', 'consumption'), ('firm', 'adjust_price')] simulation.add_action_list(action_list) simulation.declare_round_endowment(resource='adult', units=1, product='labor') simulation.declare_perishable(good='labor') simulation.aggregate('household', possessions=['money', 'GOOD'], variables=['current_utiliy']) simulation.panel('firm', possessions=['money', 'GOOD'], variables=['price', 'inventory']) simulation.build_agents(Firm, 'firm', number=parameters['num_firms']) simulation.build_agents(Household, 'household', number=1, parameters=parameters) simulation.run() simulation.graphs()
def main(simulation_parameters): simulation = Simulation(rounds=simulation_parameters['rounds']) action_list = [('killer', 'kill'), ('agent', 'am_I_dead'), ('killer', 'send_message'), ('agent', 'aggregate'), ('agent', 'panel')] # this instructs ABCE to save panel data as declared below simulation.add_action_list(action_list) simulation.declare_round_endowment(resource='labor_endowment', units=1, product='labor' ) simulation.declare_perishable(good='labor') simulation.aggregate('agent', possessions=[], variables=['count']) simulation.panel('agent', possessions=[], variables=['idn']) simulation.build_agents(Agent, 'agent', number=simulation_parameters['agents'], parameters=simulation_parameters) simulation.build_agents(Killer, 'killer', number=1, parameters=simulation_parameters) simulation.run() simulation.graphs()
def main(): for simulation_parameters in read_parameters('simulation_parameters.csv'): w = Simulation(simulation_parameters) action_list = [ ('household', 'sell_labor'), ('firm', 'buy_inputs'), ('firm', 'production'), ('firm', 'panel'), ('firm', 'sell_intermediary_goods'), ('household', 'buy_intermediary_goods'), ('household', 'panel'), ('household', 'consumption') ] w.add_action_list(action_list) w.declare_round_endowment(resource='labor_endowment', units=5, product='labor') w.declare_perishable(good='labor') w.panel('household') w.panel('firm') w.build_agents_from_file(Firm, parameters_file='agent_parameters.csv') w.build_agents_from_file(Household) w.run()
def main(simulation_parameters): simulation = Simulation(rounds=simulation_parameters['rounds']) action_list = [ ('firm', 'one'), ('household', 'two'), ('all', 'three')('household', 'panel') ] # this instructs ABCE to save panel data as declared below simulation.add_action_list(action_list) simulation.declare_round_endowment(resource='labor_endowment', units=1, product='labor') simulation.declare_perishable(good='labor') simulation.panel( 'household', possessions=['good1', 'good2' ], # put a list of household possessions to track here variables=['utility' ]) # put a list of household possessions to track here simulation.build_agents(Firm, 'firm', number=simulation_parameters['firms'], parameters=simulation_parameters) simulation.build_agents(Household, 'household', number=simulation_parameters['households'], parameters=simulation_parameters) simulation.run() simulation.graphs()
def main(simulation_parameters): simulation = Simulation(rounds=simulation_parameters['rounds']) simulation.declare_round_endowment(resource='labor_endowment', units=1, product='labor') simulation.declare_perishable(good='labor') simulation.aggregate('agent', possessions=[], variables=['count']) simulation.panel('agent', possessions=[], variables=['idn']) agents = simulation.build_agents(Agent, 'agent', number=simulation_parameters['agents'], parameters=simulation_parameters) killers = simulation.build_agents(Killer, 'killer', number=1, parameters=simulation_parameters) for r in simulation.next_round(): killers.do('kill') agents.do('am_I_dead') killers.do('send_message') agents.do('aggregate') agents.do('panel') simulation.graphs()
def main(simulation_parameters): s = Simulation(rounds=simulation_parameters['rounds']) s.panel('household', possessions=['cookies']) s.panel('firm', possessions=['cookies']) firms = s.build_agents(Firm, 'firm', 10) households = s.build_agents(Household, 'household', 10) for r in s.next_round(): firms.do('production') firms.do('panel') firms.do('quote') households.do('buying') firms.do('selling') households.do('panel') households.do('consumption')
def main(): for parameters in read_parameters(): w = Simulation(parameters) action_list = [('household', 'sell_labor'), ('firm', 'buy_labor'), ('firm', 'production'), ('firm', 'panel'), ('firm', 'sell_goods'), ('household', 'buy_goods'), ('household', 'panel'), ('household', 'consumption')] w.add_action_list(action_list) w.declare_round_endowment(resource='adult', units=1, product='labor') w.declare_perishable(good='labor') w.panel('household') w.panel('firm') w.build_agents(Firm, 1) w.build_agents(Household, 1) w.run()
def main(simulation_parameters): w = Simulation(rounds=simulation_parameters['rounds']) w.declare_round_endowment(resource='labor_endowment', units=5, product='labor') w.declare_perishable(good='labor') w.panel('household', possessions=['consumption_good']) w.panel('firm', possessions=['consumption_good', 'intermediate_good']) firms = w.build_agents(Firm, 'firm', 2) households = w.build_agents(Household, 'household', 2) for r in w.next_round(): # to access round, just get the value of w.round # to access its datetime version, use w._round # todo, better naming households.do('sell_labor') firms.do('buy_inputs') firms.do('production') firms.do('panel') firms.do('sell_intermediary_goods') households.do('buy_intermediary_goods') households.do('panel') households.do('consumption')
def main(parameters): w = Simulation(rounds=parameters['rounds']) w.declare_round_endowment(resource='adult', units=1, product='labor') w.declare_perishable(good='labor') w.panel('household', possessions=['money', 'GOOD'], variables=['current_utiliy']) w.panel('firm', possessions=['money', 'GOOD']) firms = w.build_agents(Firm, 'firm', 1) households = w.build_agents(Household, 'household', 1) for r in w.next_round(): households.do('sell_labor') firms.do('buy_labor') firms.do('production') firms.do('panel') firms.do('sell_goods') households.do('buy_goods') households.do('panel') households.do('consumption')
def main(parameters): w = Simulation(rounds=parameters['rounds']) w.declare_round_endowment(resource={'adult': 1}, product='labor') w.declare_perishable(good='labor') w.panel('household', possessions=['money', 'GOOD'], variables=['current_utiliy']) w.panel('firm', possessions=['money', 'GOOD']) firms = w.build_agents(Firm, 'firm', 1) households = w.build_agents(Household, 'household', 1) for r in w.next_round(): households.do('sell_labor') firms.do('buy_labor') # uses all labor that is available and produces # according to the set cobb_douglas function firms.do('produce_use_everything') firms.do('panel') firms.do('sell_goods') households.do('buy_goods') households.do('panel') households.do('consumption')
def main(simulation_parameters): s = Simulation(rounds=simulation_parameters['rounds']) action_list = [ ('firm', 'production'), ('firm', 'panel'), ('firm', 'quote'), ('household', 'buying'), ('firm', 'selling'), ('household', 'panel'), ('household', 'consumption') ] s.add_action_list(action_list) s.panel('household', possessions=['cookies']) s.panel('firm', possessions=['cookies']) s.build_agents(Firm, 'firm', 1) s.build_agents(Household, 'household', 10) s.run()
def main(): for simulation_parameters in read_parameters('simulation_parameters.csv'): s = Simulation(simulation_parameters) action_list = [ ('firm', 'production'), ('firm', 'panel'), ('firm', 'quote'), ('household', 'buying'), ('firm', 'selling'), ('household', 'panel'), ('household', 'consumption') ] s.add_action_list(action_list) s.panel('household') s.panel('firm') s.build_agents(Firm, 1) s.build_agents(Household, 10) s.run()
def main(simulation_parameters): simulation = Simulation(rounds=simulation_parameters['rounds'], name='ABCEsimulation_name') simulation.declare_round_endowment(resource='labor_endowment', units=1, product='labor') simulation.declare_perishable(good='labor') simulation.panel( 'household', possessions=['good1', 'good2' ], # put a list of household possessions to track here variables=['utility' ]) # put a list of household possessions to track here firms = simulation.build_agents(Firm, 'firm', number=simulation_parameters['firms'], parameters=simulation_parameters) households = simulation.build_agents( Household, 'household', number=simulation_parameters['households'], parameters=simulation_parameters) allagents = firms + households try: # makes sure that graphs are displayed even when the simulation fails for round_number in simulation.next_round(): firms.do('one') households.do('two') allagents.do('three') households.do('panel') except Exception as e: print(e) finally: simulation.graphs()
def main(simulation_parameters): w = Simulation(rounds=simulation_parameters['rounds']) action_list = [ ('household', 'sell_labor'), ('firm', 'buy_inputs'), ('firm', 'production'), ('firm', 'panel'), ('firm', 'sell_intermediary_goods'), ('household', 'buy_intermediary_goods'), ('household', 'panel'), ('household', 'consumption') ] w.add_action_list(action_list) w.declare_round_endowment(resource='labor_endowment', units=5, product='labor') w.declare_perishable(good='labor') w.panel('household', possessions=['consumption_good']) w.panel('firm', possessions=['consumption_good', 'intermediate_good']) w.build_agents(Firm, 'firm', 2) w.build_agents(Household, 'household', 2) w.run()
def main(processes, rounds): s = Simulation(processes=processes, name='unittest') s.declare_round_endowment(resource='labor_endowment', units=5, product='labor', groups=['all']) s.declare_round_endowment(resource='cow', units=10, product='milk', groups=['all']) s.declare_perishable(good='labor') s.panel('buy', variables=['price']) # s.declare_expiring('xcapital', 5) print('build Buy') buy = s.build_agents(Buy, 'buy', 1000, parameters={'rounds': rounds}) print('build Sell') # s.build_agents(QuoteBuy, 2) sell = s.build_agents(Sell, 'sell', 1000, parameters={'rounds': rounds}) print('build Give') give = s.build_agents(Give, 'give', 2, parameters={'rounds': rounds}) # tests give and messaging print('build Endowment') endowment = s.build_agents(Endowment, 'endowment', 2, parameters={ 'rounds': rounds, 'creation': 0 }) # tests declare_round_endowment and declare_perishable print('build LoggerTest') loggertest = s.build_agents(LoggerTest, 'loggertest', 1, parameters={'rounds': rounds}) print('build ProductionMultifirm') productionmultifirm = s.build_agents(ProductionMultifirm, 'productionmultifirm', 1, parameters={'rounds': rounds}) print('build ProductionFirm') productionfirm = s.build_agents(ProductionFirm, 'productionfirm', 7, parameters={'rounds': rounds}) print('build UtilityHousehold') utilityhousehold = s.build_agents(UtilityHousehold, 'utilityhousehold', 5, parameters={'rounds': rounds}) # print('build ContractSeller') # contractseller = s.build_agents(ContractSeller, 'contractseller', 2, # parameters={'rounds': rounds}) # print('build ContractBuyer') # contractbuyer = s.build_agents(ContractBuyer, 'contractbuyer', 2, # parameters={'rounds': rounds}) # print('build ContractSellerStop') # contractsellerstop = s.build_agents(ContractSellerStop, # 'contractsellerstop', 2, parameters={'rounds': rounds}) # print('build ContractBuyerStop') # contractbuyerstop = s.build_agents(ContractBuyerStop, # 'contractbuyerstop', 2, parameters={'rounds': rounds}) # s.build_agents(ExpiringCapital, 1) # s.build_agents(GiveExpiringCapital, 2) print('build BuyExpiringCapital') _ = s.build_agents(BuyExpiringCapital, 'buyexpiringcapital', 2, parameters={'rounds': rounds}) print('build MessageA') messagea = s.build_agents(MessageA, 'messagea', 20, parameters={'rounds': rounds}) print('build MessageB') messageb = s.build_agents(MessageB, 'messageb', 20, parameters={'rounds': rounds}) print('build Killer') killer = s.build_agents(Killer, 'killer', 1, parameters={'rounds': rounds}) print('build Victim') victim = s.build_agents(Victim, 'victim', rounds, parameters={'rounds': rounds}) print('build Victim loudvictim') _ = s.build_agents(Victim, 'loudvictim', rounds, parameters={'rounds': rounds}) some = buy + sell + give + loggertest + utilityhousehold # contractagents = (contractbuyer + contractseller # + contractbuyerstop + contractsellerstop) print('build AddAgent') addagent = s.build_agents(AddAgent, 'addagent', 0) for r in range(rounds): s.advance_round(r) for _ in range(5): buy.do('one') buy.do('two') buy.do('three') buy.do('clean_up') buy.do('panel') for _ in range(5): sell.do('one') sell.do('two') sell.do('three') sell.do('clean_up') for _ in range(5): give.do('one') give.do('two') give.do('three') give.do('clean_up') for _ in range(5): loggertest.do('one') loggertest.do('two') loggertest.do('three') loggertest.do('clean_up') for _ in range(5): utilityhousehold.do('one') utilityhousehold.do('two') utilityhousehold.do('three') utilityhousehold.do('clean_up') endowment.do('Iconsume') productionmultifirm.do('production') productionfirm.do('production') utilityhousehold.do('consumption') (messagea + messageb).do('sendmsg') (messageb + messagea).do('recvmsg') # (contractbuyer + contractbuyerstop).do('request_offer') # (contractseller + contractsellerstop).do('make_offer') # contractagents.do('accept_offer') # contractagents.do('deliver') # contractagents.do('pay') # contractagents.do('control') killer.do('kill') killer.do('send_message') victim.do('am_I_dead') some.do('all_tests_completed') addagent.do('add_agent') s.finalize()