예제 #1
0
파일: sim.py 프로젝트: momacs/pram
do_remove_file_sites = False
do_remove_file_groups = False

if do_remove_file_sites and os.path.isfile(fpath_sites):
    os.remove(fpath_sites)

if do_remove_file_groups and os.path.isfile(fpath_groups):
    os.remove(fpath_groups)

# ----------------------------------------------------------------------------------------------------------------------
# (1) Sites:

sites = Simulation.gen_sites_from_db(
    fpath_db_in, lambda fpath_db: {
        'hosp':
        Site.gen_from_db(fpath_db, 'hospitals', 'hosp_id', 'hospital',
                         ['workers', 'physicians', 'beds']),
        'home_gq':
        Site.gen_from_db(fpath_db, 'gq', 'sp_id', 'home',
                         ['gq_type', 'persons']),
        'home':
        Site.gen_from_db(fpath_db, 'households', 'sp_id', 'home',
                         ['hh_income']),
        'school':
        Site.gen_from_db(fpath_db, 'schools', 'sp_id', 'school', []),
        'work':
        Site.gen_from_db(fpath_db, 'workplaces', 'sp_id', 'work', [])
    }, fpath_sites)

site_home = Site('home')

# ----------------------------------------------------------------------------------------------------------------------
예제 #2
0
rand_seed = 1928

pragma_live_info = True
pragma_live_info_ts = False

fpath_db_in = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'data',
                           'allegheny-county', 'allegheny-students.sqlite3')

# ----------------------------------------------------------------------------------------------------------------------
# (1) Sites:

sites = Simulation.gen_sites_from_db(
    fpath_db_in,
    lambda fpath_db:
    {'school': Site.gen_from_db(fpath_db, 'schools', 'sp_id', 'school', [])},
    pragma_live_info=pragma_live_info,
    pragma_live_info_ts=pragma_live_info_ts)

site_home = Site('home')

# ----------------------------------------------------------------------------------------------------------------------
# (2) Probes:

# n_schools = 8
# few_schools = [sites['school'][k] for k in list(sites['school'].keys())[:n_schools]]
#
# probe_grp_size_few_schools = GroupSizeProbe('school', [GroupQry(rel={ Site.AT: s }) for s in few_schools], msg_mode=ProbeMsgMode.DISP)

fpath_db = os.path.join(os.path.dirname(__file__), 'out-test-03c.sqlite3')
예제 #3
0
do_remove_file_sites = False
do_remove_file_groups = False

if do_remove_file_sites and os.path.isfile(fpath_sites):
    os.remove(fpath_sites)

if do_remove_file_groups and os.path.isfile(fpath_groups):
    os.remove(fpath_groups)

# ----------------------------------------------------------------------------------------------------------------------
# (1) Sites:

sites = Simulation().gen_sites_from_db(
    fpath_db_in, lambda fpath_db: {
        'school': Site.gen_from_db(fpath_db, 'schools', 'sp_id', 'school', []),
        'work': Site.gen_from_db(fpath_db, 'workplaces', 'sp_id', 'work', [])
    }, fpath_sites)

site_home = Site('home')

# ----------------------------------------------------------------------------------------------------------------------
# (2) Probes:

fpath_db_out = os.path.join(dpath_cwd, 'sim.sqlite3')

if os.path.isfile(fpath_db_out):
    os.remove(fpath_db_out)

pp = ProbePersistenceDB(fpath_db_out, flush_every=1)