예제 #1
0
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()
예제 #2
0
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()
예제 #3
0
파일: start.py 프로젝트: x0range/abce
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()
예제 #4
0
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()
예제 #5
0
파일: start.py 프로젝트: x0range/abce
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()
예제 #6
0
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')
예제 #7
0
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')
예제 #8
0
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')
예제 #9
0
파일: start.py 프로젝트: x0range/abce
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')
예제 #10
0
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')
예제 #11
0
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()
예제 #12
0
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()
예제 #13
0
파일: start.py 프로젝트: x0range/abce
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')
예제 #14
0
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')
예제 #15
0
파일: start.py 프로젝트: x0range/abce
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()
예제 #16
0
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')
예제 #17
0
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')
예제 #18
0
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')
예제 #19
0
파일: start.py 프로젝트: x0range/abce
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')
예제 #20
0
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()
예제 #21
0
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')
예제 #22
0
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')
예제 #23
0
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()