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): 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): 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_round_endowment(resource={'labor_endowment': 1}, product='labor') simulation.declare_perishable(good='labor') simulation.aggregate('household', possessions=[], # put a list of household possessions to track here variables=['count']) # put a list of household possessions to track here simulation.aggregate('firm', possessions=[], # put a list of household possessions to track here variables=['count']) # 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) messengers = simulation.build_agents(Messenger, 'messenger', 1) for r in simulation.next_round(): messengers.do('messaging') (firms+households).do('receive_message') firms.do('add_household') firms.do('add_firm') firms.do('print_id') households.do('print_id') # this instructs ABCE to save panel data as declared below (firms+households).do('aggregate') simulation.graphs()
def main(): all = ['buy', 'sell'] for parameters in simulation_parameters: s = Simulation(parameters) action_list = [ repeat([ (all, 'one'), (all, 'two'), (all, 'three'), (all, 'clean_up') ], 20000), ('all', 'all_tests_completed')] s.add_action_list(action_list) s.declare_round_endowment(resource='labor_endowment', units=5, product='labor') s.declare_round_endowment(resource='cow', units=10, product='milk') s.declare_perishable(good='labor') #s.panel('buy', variables=['price']) #s.declare_expiring('xcapital', 5) s.build_agents(Buy, 2) s.build_agents(Sell, 2) s.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(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(): for simulation_parameters in read_parameters('simulation_parameters.csv'): s = Simulation(simulation_parameters) action_list = [ repeat([ ('firm', 'one'), ('household', 'two'), ], simulation_parameters['trade_repetitions']), ('all', 'three') ] s.add_action_list(action_list) s.build_agents(Firm, 5) s.build_agents(Household, 5) s.declare_round_endowment( resource='labor_endowment', productivity=1, product='labor' ) s.declare_perishable(good='labor') s.panel_data('household') s.panel_data('firm') s.run()
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 = [('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(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): 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(parameters): simulation = Simulation(processes=1) simulation.declare_round_endowment(resource='adult', units=1, product='labor') simulation.declare_perishable(good='labor') firms = simulation.build_agents(Firm, 'firm', number=parameters['num_firms']) households = simulation.build_agents(Household, 'household', number=1, parameters=parameters) try: for rnd in range(parameters['rounds']): simulation.advance_round(rnd) households.sell_labor() firms.buy_labor() firms.production() firms.panel_log(possessions=['money', 'GOOD'], variables=['price', 'inventory']) firms.quotes() households.buy_goods() firms.sell_goods() households.agg_log(possessions=['money', 'GOOD'], variables=['current_utiliy']) households.consumption() firms.adjust_price() except Exception as e: print(e)
def main(): all = [ 'buy', 'sell', 'give', 'endowment', 'loggertest', 'productionmultifirm', 'productionfirm', 'utilityhousehold' ] for parameters in read_parameters('simulation_parameters.csv'): s = Simulation(parameters) action_list = [ repeat([(all, 'one'), (all, 'two'), (all, 'three'), (all, 'clean_up')], 60), #('buy', 'panel'), ('endowment', 'Iconsume'), ('productionmultifirm', 'production'), ('productionfirm', 'production'), ('utilityhousehold', 'consumption'), #('contractseller', 'make_offer'), #('contractseller', 'accept_offer'), #('contractseller', 'deliver_or_pay'), #('contractseller', 'control'), #('contractbuyer', 'request_offer'), #('contractbuyer', 'accept_offer'), #('contractbuyer', 'deliver_or_pay'), #('contractbuyer', 'control'), #('expiringcapital', 'go'), ('all', 'all_tests_completed') ] s.add_action_list(action_list) s.declare_round_endowment(resource='labor_endowment', units=5, product='labor') s.declare_round_endowment(resource='cow', units=10, product='milk') s.declare_perishable(good='labor') #s.panel('buy', variables=['price']) #s.declare_expiring('xcapital', 5) s.build_agents(Buy, 2) #s.build_agents(QuoteBuy, 2) s.build_agents(Sell, 2) s.build_agents(Give, 2) # tests give and messaging s.build_agents( Endowment, 2) # tests declare_round_endowment and declare_perishable s.build_agents(LoggerTest, 1) s.build_agents(ProductionMultifirm, 1) s.build_agents(ProductionFirm, 5) s.build_agents(UtilityHousehold, 5) #s.build_agents(ContractSeller, 2) #s.build_agents(ContractBuyer, 2) #s.build_agents(ExpiringCapital, 1) #s.build_agents(GiveExpiringCapital, 2) s.build_agents(BuyExpiringCapital, 2) s.run()
def main(): for simulation_parameters in read_parameters("simulation_parameters.csv"): s = Simulation(simulation_parameters) action_list = [ repeat([("firm", "selling", "parallel"), ("household", "buying"), ("household", "checking")], 60) ] s.add_action_list(action_list) s.declare_round_endowment("field", 60, "corn") s.declare_round_endowment("shares", 60, "money") s.build_agents(Firm, 1) s.build_agents(Household, 1) s.run()
def main(): for params in simulation_parameters: s = Simulation(params) s.declare_round_endowment('field', 60, 'corn') s.declare_round_endowment('shares', 60, 'money') f = s.build_agents(Firm, 'firm', 1) h = s.build_agents(Household, 'household', 1) for r in s.next_round(): for i in range(60): f.do('selling') h.do('buying') h.do('checking') s.run()
def main(): for params in simulation_parameters: s = Simulation(params) s.declare_round_endowment('field', 60, 'corn') s.declare_round_endowment('shares', 60, 'money') f = s.build_agents(Firm, 'firm', 1) h = s.build_agents(Household, 'household', 1) for r in s.next_round(): for i in range(60): f.do('selling') h.do('buying') h.do('checking') s.run()
def main(): for simulation_parameters in read_parameters('simulation_parameters.csv'): s = Simulation(simulation_parameters) action_list = [ repeat([ ('firm', 'selling', 'parallel'), ('household', 'buying'), ('household', 'checking') ], 60)] s.add_action_list(action_list) s.declare_round_endowment('field', 60, 'corn') s.declare_round_endowment('shares', 60, 'money') s.build_agents(Firm, 1) s.build_agents(Household, 1) s.run()
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( 'household', possessions=[], # put a list of household possessions to track here variables=['count' ]) # put a list of household possessions to track here simulation.aggregate( 'firm', possessions=[], # put a list of household possessions to track here variables=['count' ]) # 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) messengers = simulation.build_agents(Messenger, 'messenger', 1) for r in simulation.next_round(): messengers.do('messaging') (firms + households).do('receive_message') firms.do('add_household') firms.do('add_firm') firms.do('print_id') households.do('print_id') # this instructs ABCE to save panel data as declared below (firms + households).do('aggregate') simulation.graphs()
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): 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(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(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': 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(): for simulation_parameters in read_parameters('simulation_parameters.csv'): s = Simulation(simulation_parameters) action_list = [ repeat([ ('firm', 'one'), ('household', 'two'), ], simulation_parameters['trade_repetitions']), ('all', 'three') ] s.add_action_list(action_list) s.build_agents(Firm, 5) s.build_agents(Household, 5) s.declare_round_endowment(resource='labor_endowment', productivity=1, product='labor') s.declare_perishable(good='labor') s.panel_data('household') s.panel_data('firm') s.run()
def main(simulation_parameters): w = Simulation() w.declare_round_endowment(resource='labor_endowment', units=5, product='labor') w.declare_perishable(good='labor') firms = w.build_agents(Firm, 'firm', 2) households = w.build_agents(Household, 'household', 2) for r in range(simulation_parameters['rounds']): w.advance_round(r) # to access round, just get the value of w.round # to access its datetime version, use w._round # todo, better naming households.sell_labor() firms.buy_inputs() firms.production() firms.panel_log(possessions=['consumption_good', 'intermediate_good']) firms.sell_intermediary_goods() households.buy_intermediary_goods() households.panel_log(possessions=['consumption_good']) households.consumption() w.finalize()
def main(): all = ['buy', 'sell'] for parameters in simulation_parameters: s = Simulation(parameters) action_list = [ repeat([(all, 'one'), (all, 'two'), (all, 'three'), (all, 'clean_up')], 20000), ('all', 'all_tests_completed') ] s.add_action_list(action_list) s.declare_round_endowment(resource='labor_endowment', units=5, product='labor') s.declare_round_endowment(resource='cow', units=10, product='milk') s.declare_perishable(good='labor') #s.panel('buy', variables=['price']) #s.declare_expiring('xcapital', 5) s.build_agents(Buy, 2) s.build_agents(Sell, 2) 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(simulation_parameters): simulation = Simulation(rounds=simulation_parameters['rounds']) action_list = [('messenger', 'messaging'), (('firm', 'household'), 'receive_message'), ('firm', 'add_household'), ('firm', 'add_firm'), ('firm', 'print_id'), ('household', 'print_id'), (('firm', 'household'), 'aggregate')] # 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('household', possessions=[], # put a list of household possessions to track here variables=['count']) # put a list of household possessions to track here simulation.aggregate('firm', possessions=[], # put a list of household possessions to track here variables=['count']) # put a list of household possessions to track here simulation.build_agents(Firm, 'firm', number=simulation_parameters['firms'], parameters=simulation_parameters, expandable=True) simulation.build_agents(Household, 'household', number=simulation_parameters['households'], parameters=simulation_parameters, expandable=True) simulation.build_agents(Messenger, 'messenger', 1) simulation.run() simulation.graphs()
def main(processes, rounds): all = ['buy', 'sell', 'give', 'loggertest', 'utilityhousehold'] contractagents = ['contractbuyer', 'contractseller', 'contractbuyerstop', 'contractsellerstop'] s = Simulation(rounds=rounds, processes=processes) action_list = [ repeat([ (all, 'one'), (all, 'two'), (all, 'three'), (all, 'clean_up') ], 20), #('buy', 'panel'), ('endowment', 'Iconsume'), ('productionmultifirm', 'production'), ('productionfirm', 'production'), ('utilityhousehold', 'consumption'), (('messagea', 'messageb'), 'sendmsg'), (('messageb', 'messagea'), 'recvmsg'), (('contractbuyer','contractbuyerstop'), 'request_offer'), (('contractseller', 'contractsellerstop'), 'make_offer'), (contractagents, 'accept_offer'), (contractagents, 'deliver'), (contractagents, 'pay'), (contractagents, 'control'), ('killer', 'kill'), ('killer', 'send_message'), ('victim', 'am_I_dead'), #('expiringcapital', 'go'), (all, 'all_tests_completed'), ('addagent', 'add_agent')] s.add_action_list(action_list) s.declare_round_endowment(resource='labor_endowment', units=5, product='labor') s.declare_round_endowment(resource='cow', units=10, product='milk') s.declare_perishable(good='labor') #s.panel('buy', variables=['price']) #s.declare_expiring('xcapital', 5) print('build Buy') s.build_agents(Buy, 'buy', 1000, parameters={'rounds': rounds}) print('build Sell') #s.build_agents(QuoteBuy, 2) s.build_agents(Sell, 'sell', 1000, parameters={'rounds': rounds}) print('build Give') s.build_agents(Give, 'give', 2, parameters={'rounds': rounds}) # tests give and messaging print('build Endowment') s.build_agents(Endowment, 'endowment', 2, parameters={'rounds': rounds, 'creation': 0}) # tests declare_round_endowment and declare_perishable print('build LoggerTest') s.build_agents(LoggerTest, 'loggertest', 1, parameters={'rounds': rounds}) print('build ProductionMultifirm') s.build_agents(ProductionMultifirm, 'productionmultifirm', 1, parameters={'rounds': rounds}) print('build ProductionFirm') s.build_agents(ProductionFirm, 'productionfirm', 7, parameters={'rounds': rounds}) print('UtilityHousehold') s.build_agents(UtilityHousehold, 'utilityhousehold', 5, parameters={'rounds': rounds}) print('build ContractSeller') s.build_agents(ContractSeller, 'contractseller', 2, parameters={'rounds': rounds}) print('build ContractBuyer') s.build_agents(ContractBuyer, 'contractbuyer', 2, parameters={'rounds': rounds}) print('build ContractSellerStop') s.build_agents(ContractSellerStop, 'contractsellerstop', 2, parameters={'rounds': rounds}) print('build 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') s.build_agents(MessageA, 'messagea', 20, parameters={'rounds': rounds}) print('build MessageB') s.build_agents(MessageB, 'messageb', 20, parameters={'rounds': rounds}) print('build AddAgent') s.build_agents(AddAgent, 'addagent', 1, parameters={'rounds': rounds}) print('build Killer') s.build_agents(Killer, 'killer', 1, parameters={'rounds': rounds}) print('build Victim') s.build_agents(Victim, 'victim', rounds, parameters={'rounds': rounds}) print('build Victim loudvictim') s.build_agents(Victim, 'loudvictim', rounds, parameters={'rounds': rounds}) s.run()
def main(): all = ['buy', 'sell', 'give', 'endowment', 'loggertest', 'productionmultifirm', 'productionfirm', 'utilityhousehold'] for parameters in read_parameters('simulation_parameters.csv'): s = Simulation(parameters) action_list = [ repeat([ (all, 'one'), (all, 'two'), (all, 'three'), (all, 'clean_up') ], 60), #('buy', 'panel'), ('endowment', 'Iconsume'), ('productionmultifirm', 'production'), ('productionfirm', 'production'), ('utilityhousehold', 'consumption'), #('contractseller', 'make_offer'), #('contractseller', 'accept_offer'), #('contractseller', 'deliver_or_pay'), #('contractseller', 'control'), #('contractbuyer', 'request_offer'), #('contractbuyer', 'accept_offer'), #('contractbuyer', 'deliver_or_pay'), #('contractbuyer', 'control'), #('expiringcapital', 'go'), ('all', 'all_tests_completed')] s.add_action_list(action_list) s.declare_round_endowment(resource='labor_endowment', units=5, product='labor') s.declare_round_endowment(resource='cow', units=10, product='milk') s.declare_perishable(good='labor') #s.panel('buy', variables=['price']) #s.declare_expiring('xcapital', 5) s.build_agents(Buy, 2) #s.build_agents(QuoteBuy, 2) s.build_agents(Sell, 2) s.build_agents(Give, 2) # tests give and messaging s.build_agents(Endowment, 2) # tests declare_round_endowment and declare_perishable s.build_agents(LoggerTest, 1) s.build_agents(ProductionMultifirm, 1) s.build_agents(ProductionFirm, 5) s.build_agents(UtilityHousehold, 5) #s.build_agents(ContractSeller, 2) #s.build_agents(ContractBuyer, 2) #s.build_agents(ExpiringCapital, 1) #s.build_agents(GiveExpiringCapital, 2) s.build_agents(BuyExpiringCapital, 2) s.run()
from abce import Simulation, read_parameters, repeat for simulation_parameters in read_parameters('simulation_parameters.csv'): s = Simulation(simulation_parameters) action_list = [ repeat([ ('firm', 'one'), ('household', 'two'), ], simulation_parameters['trade_repetitions']), 'buy_log', ('all', 'three') ] s.add_action_list(action_list) s.build_agents(Firm, 5) s.build_agents(Household, 5) s.declare_round_endowment( resource='labor_endowment', productivity=1, product='labor' ) s.declare_perishable(good='labor') s.panel_data('household', command='buy_log') s.panel_data('firm', command='buy_log') s.run()
def main(processes, rounds): s = Simulation(processes=processes, name='unittest') s.declare_round_endowment(resource='labor_endowment', units=5, product='labor') s.declare_round_endowment(resource='cow', units=10, product='milk') s.declare_perishable(good='labor') # 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}) some = buy + sell + give + loggertest + utilityhousehold # contractagents = (contractbuyer + contractseller # + contractbuyerstop + contractsellerstop) for r in range(rounds): s.advance_round(r) for _ in range(5): buy.one() buy.two() buy.three() buy.clean_up() buy.panel_log(variables=['price']) for _ in range(5): sell.one() sell.two() sell.three() sell.clean_up() for _ in range(5): give.one() give.two() give.three() give.clean_up() for _ in range(5): loggertest.one() loggertest.two() loggertest.three() loggertest.clean_up() for _ in range(5): utilityhousehold.one() utilityhousehold.two() utilityhousehold.three() utilityhousehold.clean_up() endowment.Iconsume() productionmultifirm.production() productionfirm.production() utilityhousehold.consumption() (messagea + messageb).sendmsg() (messageb + messagea).recvmsg() # (contractbuyer + contractbuyerstop).request_offer() # (contractseller + contractsellerstop).make_offer() # contractagents.accept_offer() # contractagents.deliver() # contractagents.pay() # contractagents.control() some.all_tests_completed() s.finalize()
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()