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(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(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(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']) 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(): 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(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'] 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']) 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']) 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']) 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 = { 'name': 'direct_optimization', 'random_seed': None, 'rounds': 500, 'trade_logging': 'off', 'num_firms': 250, 'alpha': 0.3, 'gamma': 0.8, 'price_stickiness': 0.0, 'network_weight_stickiness': 0.0, 'wage_stickiness': 0.0, 'dividends_percent': 0.0, 'percentage_beneficiaries': 0.25, 'percentage_injection': 0.25, 'time_of_intervention': 250 } s = Simulation(name=simulation_parameters['name']) s.declare_service('labor_endowment', 1, 'labor') network = create_network(simulation_parameters['num_firms']) network = [ network.neighbors(neighbor) for neighbor in range(simulation_parameters['num_firms']) ] firms = s.build_agents(Firm, 'firm', parameters=simulation_parameters, agent_parameters=network) household = s.build_agents(Household, 'household', 1, parameters=simulation_parameters) centralbank = s.build_agents(CentralBank, 'centralbank', 1, parameters=simulation_parameters) for rnd in range(simulation_parameters['rounds']): s.advance_round(rnd) (firms + household).send_demand() (firms + household).selling() (firms + household).buying() firms.production() firms.dividends() household.consuming() firms.change_weights() firms.stats() centralbank.intervention() household.agg_log(possessions=['money'], variables=['utility', 'rationing']) firms.agg_log(possessions=['money'], variables=[ 'produced', 'profit', 'price', 'dead', 'inventory', 'rationing' ]) s.graphs()
def main(): parameters = {'name': 'name', 'rounds': 300} s = Simulation(rounds=parameters['rounds'], processes=8) myagents = s.build_agents(MyAgent, 'myagent', 50000) youragents = s.build_agents(YourAgent, 'youragent', 50000) for r in s.next_round(): #(myagents+youragents).do('compute') youragents.do('s') myagents.do('g')
def main(simulation_parameters): s = Simulation(rounds=simulation_parameters['rounds']) firms = s.build_agents(Firm, 'firm', parameters=simulation_parameters, number=1) market = s.build_agents(Market, 'market', parameters=simulation_parameters, number=1) for r in s.next_round(): firms.do('my_production') firms.do('selling') market.do('buying') firms.do('adjust_price') firms.do('adjust_quantity') market.do('consumption')
def main(): s = Simulation(processes=8) myagents = s.build_agents(MyAgent, 'myagent', 50000) youragents = s.build_agents(YourAgent, 'youragent', 50000) for r in range(100): s.advance_round(r) # (myagents+youragents).do('compute') youragents.s() myagents.g() s.finalize()
def main(): parameters = {'name': 'name', 'rounds': 300} s = Simulation(rounds=parameters['rounds'], cores=8) action_list = [ # (('myagent', 'youragent'), 'compute'), ('youragent', 's'), ('myagent', 'g') ] s.add_action_list(action_list) s.build_agents(MyAgent, 50000) s.build_agents(YourAgent, 50000) s.run()
def main(): parameters = { 'name': 'name', 'rounds': 300 } s = Simulation(rounds=parameters['rounds'], processes=8) myagents = s.build_agents(MyAgent, 'myagent', 50000) youragents = s.build_agents(YourAgent, 'youragent', 50000) for r in s.next_round(): #(myagents+youragents).do('compute') youragents.do('s') myagents.do('g')
def main(simulation_parameters): s = Simulation() firms = s.build_agents(Firm, 'firm', 10) households = s.build_agents(Household, 'household', 10) for r in range(int(simulation_parameters['rounds'])): s.advance_round(r) firms.panel_log(possessions=['cookies']) firms.quote() households.buying() firms.selling() households.panel_log(possessions=['cookies']) households.consumption() s.finalize()
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 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 simulation_parameters in read_parameters('simulation_parameters.csv'): s = Simulation(simulation_parameters) action_list = [('firm', 'my_production'), ('firm', 'selling'), ('market', 'buying'), ('firm', 'adjust_price', 'serial'), ('firm', 'adjust_quantity', 'serial'), ('market', 'consumption')] s.add_action_list(action_list) s.build_agents(Firm, 1) s.build_agents(Market, 1) s.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 = { 'name': 'name', 'num_rounds': 10 } s = Simulation(parameters) action_list = [ # (('myagent', 'youragent'), 'compute'), ('youragent', 's'), ('myagent', 'g')] s.add_action_list(action_list) s.build_agents(MyAgent, 50000) s.build_agents(YourAgent, 50000) s.run(parallel=True)
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(): parameters = { 'name': 'name', 'rounds': 300 } s = Simulation(rounds=parameters['rounds'], cores=8) action_list = [#(('myagent', 'youragent'), 'compute'), ('youragent', 's'), ('myagent', 'g')] s.add_action_list(action_list) s.build_agents(MyAgent, 'myagent', 50000) s.build_agents(YourAgent, 'youragent', 50000) s.run()
def main(): """ Demonstration of the simulation.advance_round function, which can take arbitrary values """ simulation = Simulation() agents = simulation.build_agents(Agent, 'agent', number=1) weekday = 0 for year in range(2000, 2010): for month in range(12): for day in range(30): simulation.advance_round((year, month, day)) weekday = (weekday + 1) % 7 print(weekday) if weekday == 3: agents.wednessday() if day == 1: agents.first() if month == 12 and day == 31: agents.newyearseve() if day <= 7 and weekday == 5: agents.firstfriday() if day == 15: agents.fiveteens() agents.panel_log(possessions=['money']) agents.agg_log(possessions=['labor']) simulation.finalize()
def main(simulation_parameters): s = Simulation() firms = s.build_agents( Firm, 'firm', parameters=simulation_parameters, number=1) market = s.build_agents( Market, 'market', parameters=simulation_parameters, number=1) for r in range(simulation_parameters['rounds']): s.advance_round(r) firms.my_production() firms.selling() market.buying() firms.adjust_price() firms.adjust_quantity() market.consumption() s.finalize()
def main(simulation_parameters): s = Simulation(**simulation_parameters) s.declare_perishable('labor') firms = s.build_agents(Firm, 'firm', 1) market = s.build_agents(Market, 'market', 1) labormarket = s.build_agents(LaborMarket, 'labormarket', 1) for r in s.next_round(): firms.do('quote_hire') labormarket.do('accepting') firms.do('hire') firms.do('my_production') firms.do('selling') market.do('buying') firms.do('adjust_price') firms.do('adjust_quantity') market.do('consumption')
def main(simulation_parameters): s = Simulation(rounds=simulation_parameters['rounds']) action_list = [ ('firm', 'my_production'), ('firm', 'selling'), ('market', 'buying'), ('firm', 'adjust_price'), ('firm', 'adjust_quantity'), ('market', 'consumption') ] s.add_action_list(action_list) s.build_agents(Firm, 'firm', parameters=simulation_parameters, number=1) s.build_agents(Market, 'market', parameters=simulation_parameters, number=1) s.run()
def main(): s = Simulation() a = s.build_agents(MyAgent, 'myagent', 10000) for r in range(50): s.advance_round(r) a.do("compute") s.finalize()
def main(): for simulation_parameters in read_parameters('simulation_parameters.csv'): s = Simulation(simulation_parameters) action_list = [ ('firm', 'my_production'), ('firm', 'selling'), ('market', 'buying'), ('firm', 'adjust_price', 'serial'), ('firm', 'adjust_quantity', 'serial'), ('market', 'consumption') ] s.add_action_list(action_list) s.build_agents(Firm, 1) s.build_agents(Market, 1) 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(): s = Simulation(name='Sticky Prices Microfoundations') s.declare_perishable('labor') firms = s.build_agents(Firm, 'firm', 1) market = s.build_agents(Market, 'market', 1) labormarket = s.build_agents(LaborMarket, 'labormarket', 1) for r in range(20): s.advance_round(r) firms.do('quote_hire') labormarket.do('accepting') firms.do('hire') firms.do('my_production') firms.do('selling') market.do('buying') firms.do('adjust_price') firms.do('adjust_quantity') market.do('consumption')
def main(): s = Simulation() buy = s.build_agents(Buy, group_name='buy', number=2, parameters=simulation_parameters) sell = s.build_agents(Sell, group_name='sell', number=2, parameters=simulation_parameters) all = buy + sell for r in range(simulation_parameters['num_rounds']): s.advance_round(r) for r in range(20000): all.one() all.two() all.three() all.clean_up() all.all_tests_completed()
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(simulation_parameters): s = Simulation(name=simulation_parameters['name']) s.declare_service('labor_endowment', 1, 'labor') network = create_network(simulation_parameters['num_firms']) network = [ network.neighbors(neighbor) for neighbor in range(simulation_parameters['num_firms']) ] firms = s.build_agents(Firm, 'firm', parameters=simulation_parameters, agent_parameters=network) household = s.build_agents(Household, 'household', 1, parameters=simulation_parameters) centralbank = s.build_agents(CentralBank, 'centralbank', 1, parameters=simulation_parameters) for rnd in range(simulation_parameters['rounds']): s.advance_round(rnd) (firms + household).send_demand() (firms + household).selling() (firms + household).buying() firms.production() firms.dividends() household.consuming() firms.change_weights() firms.stats() centralbank.intervention() household.agg_log(possessions=['money'], variables=['utility', 'rationing']) firms.agg_log(possessions=['money'], variables=[ 'produced', 'profit', 'price', 'dead', 'inventory', 'rationing' ]) s.finalize()
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): simulation = Simulation(rounds=simulation_parameters['rounds'], processes=2) 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) for round in simulation.next_round(): print('one') (firms + households).do('one') #pprint({k: str(v) for k, v in simulation.mlist.items()}) print('two') (firms + households).do('two')
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(processes, rounds): s = Simulation(processes=processes, name='unittest') print('build Buy') buy = s.build_agents(Buy, 'buy', 1000, rounds=rounds) print('build Sell') sell = s.build_agents(Sell, 'sell', 1000, rounds=rounds) print('build Give') give = s.build_agents(Give, 'give', 2, rounds=rounds) print('build LoggerTest') loggertest = s.build_agents(LoggerTest, 'loggertest', 1, rounds=rounds) all = buy + sell + give + loggertest 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() all.all_tests_completed() s.finalize()
def main(simulation_parameters): simulation = Simulation(rounds=simulation_parameters['scheduledEndTime'], processes=1) insurancefirms = simulation.build_agents( InsuranceFirm, 'insurancefirm', number=simulation_parameters['numberOfInsurers'], parameters=simulation_parameters) insurancecustomers = simulation.build_agents( InsuranceCustomer, 'insurancecustomer', number=simulation_parameters['numberOfRiskholders'], parameters=simulation_parameters) allagents = insurancefirms + insurancecustomers #pdb.set_trace() events = defaultdict(list) for round in simulation.next_round(): new_events = insurancecustomers.do('randomAddRisk') for risk in events[round]: new_events += [risk.explode(round)] for event_time, risk in new_events: if event_time is not None: event_time = math.ceil(event_time) events[event_time].append(risk) assert isinstance(event_time, int) assert risk is not None assert event_time >= round (insurancefirms + insurancecustomers).do('mature_contracts') insurancefirms.do('quote') insurancecustomers.do('subscribe_coverage') insurancefirms.do('add_contract') allagents.do('filobl') insurancecustomers.do('check_risk') simulation.graphs()
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(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(): 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): 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(): for simulation_parameters in read_parameters('simulation_parameters.csv'): s = Simulation(simulation_parameters) action_list = [ ('firm', 'quote_hire'), ('labormarket', 'accepting'), ('firm', 'hire'), ('firm', 'my_production'), ('firm', 'selling'), ('market', 'buying'), ('firm', 'adjust_price'), ('firm', 'adjust_quantity'), ('market', 'consumption') ] s.add_action_list(action_list) s.declare_perishable('labor') s.build_agents(Firm, 1) s.build_agents(Market, 1) s.build_agents(LaborMarket, 1) s.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(): 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(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()