#!/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_CENTERS = [(27, 40), (32, 8)] D_RADIUS = [10, 10] if __name__ == '__main__': # command line arguments if len(sys.argv) != 2: print('usage:', sys.argv[0], '') 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) H_DENSITIES = pg.make_densities(NB_CLUSTERS, D_CENTERS, D_RADIUS) W_DENSITIES = pg.make_densities(NB_CLUSTERS) # make xml PERSONS = [pg.rand_person(NODES, CLUSTERS, H_DENSITIES, W_DENSITIES) for _ in range(NB_PERSONS)] PLANS = pg.make_plans(PERSONS) # print XML print('') print('') print(etree.tostring(PLANS, pretty_print=True).decode('utf-8'))