plan_gen_cli.py 1.1 KB

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