Bladeren bron

density probabilities

Florian 7 jaren geleden
bovenliggende
commit
481d4999e2
2 gewijzigde bestanden met toevoegingen van 15 en 4 verwijderingen
  1. 10 4
      plan_gen/plan_gen.py
  2. 5 0
      plan_gen/plan_gen_cli.py

+ 10 - 4
plan_gen/plan_gen.py

@@ -30,10 +30,7 @@ def parse_params(param_str):
     if param_str:
         for key_value_str in param_str.split(','):
             key, value = key_value_str.split('=')
-            if key in ['hc', 'wc']:
-                dict_params[key] = [file for file in value.split(':')]
-            else:
-                dict_params[key] = parse_value(value)
+            dict_params[key] = parse_value(value)
     return dict_params
 
 def get_seconds(time_str):
@@ -73,6 +70,15 @@ def make_clusters(nb_clusters, nodes):
         clusters[i][j] += [node]
     return clusters
 
+def make_densities(nb_clusters, radius, centers):
+    ''' make a list of gaussian probability densities '''
+    densities = np.zeros((nb_clusters, nb_clusters))
+    if centers is None:
+        return densities + 1
+    for n, c in enumerate(centers):
+        densities += make_gaussian(nb_clusters, radius=radius[n], center=c)
+    return densities
+
 # random generators
 # ------------------
 

+ 5 - 0
plan_gen/plan_gen_cli.py

@@ -6,6 +6,10 @@ 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
@@ -21,6 +25,7 @@ if __name__ == '__main__':
     # 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)]