|
@@ -30,7 +30,13 @@ def parse_params(param_str):
|
|
if param_str:
|
|
if param_str:
|
|
for key_value_str in param_str.split(','):
|
|
for key_value_str in param_str.split(','):
|
|
key, value = key_value_str.split('=')
|
|
key, value = key_value_str.split('=')
|
|
- dict_params[key] = parse_value(value)
|
|
|
|
|
|
+ if key in ['hc', 'wc']:
|
|
|
|
+ coords = value.split('|')
|
|
|
|
+ dict_params[key] = [np.fromstring(str(x), dtype=int, sep=':') for x in coords]
|
|
|
|
+ elif key in ['hr', 'wr']:
|
|
|
|
+ dict_params[key] = np.fromstring(str(value), dtype=int, sep='|')
|
|
|
|
+ else:
|
|
|
|
+ dict_params[key] = parse_value(value)
|
|
return dict_params
|
|
return dict_params
|
|
|
|
|
|
def get_seconds(time_str):
|
|
def get_seconds(time_str):
|
|
@@ -91,13 +97,14 @@ def rand_time(low, high):
|
|
|
|
|
|
def rand_node_xy(nodes, clusters, densities):
|
|
def rand_node_xy(nodes, clusters, densities):
|
|
''' returns a random node coordinates from a random cluster '''
|
|
''' returns a random node coordinates from a random cluster '''
|
|
|
|
+ node = None
|
|
clusters = clusters.flatten()
|
|
clusters = clusters.flatten()
|
|
densities = densities.flatten()
|
|
densities = densities.flatten()
|
|
cluster = np.random.choice(clusters, p=densities/sum(densities))
|
|
cluster = np.random.choice(clusters, p=densities/sum(densities))
|
|
- if cluster is not None:
|
|
|
|
- node = cluster[np.random.randint(len(cluster))]
|
|
|
|
- else:
|
|
|
|
|
|
+ if cluster is None:
|
|
node = nodes[np.random.randint(len(nodes))]
|
|
node = nodes[np.random.randint(len(nodes))]
|
|
|
|
+ else:
|
|
|
|
+ node = cluster[np.random.randint(len(cluster))]
|
|
return (node.get('x'), node.get('y'))
|
|
return (node.get('x'), node.get('y'))
|
|
|
|
|
|
def rand_person(nodes, clusters, h_dens, w_dens):
|
|
def rand_person(nodes, clusters, h_dens, w_dens):
|