12345678910111213141516171819202122232425262728293031323334353637 |
- #!/usr/bin/env python3
- ''' Python generator for MATSim plans. '''
- import sys
- import lxml.etree as etree
- import numpy as np
- import plan_gen.plan_gen as pg
- # TODO: make these constants as user params
- D_RADIUS = [10, 5]
- D_CENTERS = [(20, 20), (5,5)]
- if __name__ == '__main__':
- # command line arguments
- if len(sys.argv) != 2:
- print('usage:', sys.argv[0], '<params>')
- sys.exit(-1)
- DICT_PARAMS = pg.parse_params(sys.argv[1])
- NB_CLUSTERS = DICT_PARAMS['nc']
- NB_PERSONS = DICT_PARAMS['np']
- INPUT_NETWORK = DICT_PARAMS['nw']
- # prepare data
- NODES = pg.get_nodes(INPUT_NETWORK)
- CLUSTERS = pg.make_clusters(NB_CLUSTERS, NODES)
- D_CLUSTERS = pg.make_densities(NB_CLUSTERS, D_RADIUS, D_CENTERS)
- # # make xml
- # PERSONS = [pg.rand_person(NODES, HOME_CLUSTERS, WORK_CLUSTERS) for _ in range(NB_PERSONS)]
- # PLANS = pg.make_plans(PERSONS)
- # # print XML
- # print('<?xml version="1.0" ?>')
- # print('<!DOCTYPE plans SYSTEM "http://www.matsim.org/files/dtd/plans_v4.dtd">')
- # print(etree.tostring(PLANS, pretty_print=True).decode('utf-8'))
|