diff options
author | 20001LastOrder <boqi.chen@mail.mcgill.ca> | 2019-06-05 14:26:39 -0400 |
---|---|---|
committer | 20001LastOrder <boqi.chen@mail.mcgill.ca> | 2019-06-05 14:26:39 -0400 |
commit | bb6bb8c279e0db324efa11b28eb5d77d175aa8a9 (patch) | |
tree | 255a61ca4c8e84745d8cdd400093ee511d03dac3 /Metrics | |
parent | merge (diff) | |
download | VIATRA-Generator-bb6bb8c279e0db324efa11b28eb5d77d175aa8a9.tar.gz VIATRA-Generator-bb6bb8c279e0db324efa11b28eb5d77d175aa8a9.tar.zst VIATRA-Generator-bb6bb8c279e0db324efa11b28eb5d77d175aa8a9.zip |
clean up metric directory
Diffstat (limited to 'Metrics')
44 files changed, 423 insertions, 563 deletions
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/MPC.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/MPC.png deleted file mode 100644 index e660f3da..00000000 --- a/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/MPC.png +++ /dev/null | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/Node Activity.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/Node Activity.png deleted file mode 100644 index 92047e47..00000000 --- a/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/Node Activity.png +++ /dev/null | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/Out Degree.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/Out Degree.png deleted file mode 100644 index dad7483f..00000000 --- a/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/Out Degree.png +++ /dev/null | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Alloy (30 nodes)-/MPC.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Alloy (30 nodes)-/MPC.png index cd2af5ce..cd2af5ce 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Alloy (30 nodes)-/MPC.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Alloy (30 nodes)-/MPC.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Alloy (30 nodes)-/Node Activity.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Alloy (30 nodes)-/Node Activity.png index 2ce3672b..2ce3672b 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Alloy (30 nodes)-/Node Activity.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Alloy (30 nodes)-/Node Activity.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Alloy (30 nodes)-/Out Degree.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Alloy (30 nodes)-/Out Degree.png index d4d9afe1..d4d9afe1 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Alloy (30 nodes)-/Out Degree.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Alloy (30 nodes)-/Out Degree.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Random-/MPC.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Random-/MPC.png index 8d76fed9..8d76fed9 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Random-/MPC.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Random-/MPC.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Random-/Node Activity.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Random-/Node Activity.png index daa7929a..daa7929a 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Random-/Node Activity.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Random-/Node Activity.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Random-/Out Degree.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Random-/Out Degree.png index e56b1b6e..e56b1b6e 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Random-/Out Degree.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Random-/Out Degree.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Random-Viatra (100 nodes)-/MPC.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Random-Viatra (100 nodes)-/MPC.png index 8705cee2..8705cee2 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Random-Viatra (100 nodes)-/MPC.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Random-Viatra (100 nodes)-/MPC.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Random-Viatra (100 nodes)-/Node Activity.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Random-Viatra (100 nodes)-/Node Activity.png index bdab3741..bdab3741 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Random-Viatra (100 nodes)-/Node Activity.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Random-Viatra (100 nodes)-/Node Activity.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Random-Viatra (100 nodes)-/Out Degree.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Random-Viatra (100 nodes)-/Out Degree.png index e4269f6e..e4269f6e 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Random-Viatra (100 nodes)-/Out Degree.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Random-Viatra (100 nodes)-/Out Degree.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Viatra (60 nodes)-Viatra (100 nodes)-/MPC.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Viatra (60 nodes)-Viatra (100 nodes)-/MPC.png index e4b6b527..e4b6b527 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Viatra (60 nodes)-Viatra (100 nodes)-/MPC.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Viatra (60 nodes)-Viatra (100 nodes)-/MPC.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Viatra (60 nodes)-Viatra (100 nodes)-/Node Activity.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Viatra (60 nodes)-Viatra (100 nodes)-/Node Activity.png index e067ad66..e067ad66 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Viatra (60 nodes)-Viatra (100 nodes)-/Node Activity.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Viatra (60 nodes)-Viatra (100 nodes)-/Node Activity.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Viatra (60 nodes)-Viatra (100 nodes)-/Out Degree.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Viatra (60 nodes)-Viatra (100 nodes)-/Out Degree.png index 9b89e4f9..9b89e4f9 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/Human-Viatra (30 nodes)-Viatra (60 nodes)-Viatra (100 nodes)-/Out Degree.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-Viatra (60 nodes)-Viatra (100 nodes)-/Out Degree.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/real vs viatra vs alloy/MPC.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/real vs viatra vs alloy/MPC.png index 4f189578..4f189578 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/real vs viatra vs alloy/MPC.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/real vs viatra vs alloy/MPC.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/real vs viatra vs alloy/Node Activity.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/real vs viatra vs alloy/Node Activity.png index add3c0f8..add3c0f8 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/real vs viatra vs alloy/Node Activity.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/real vs viatra vs alloy/Node Activity.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/real vs viatra vs alloy/Out Degree.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/real vs viatra vs alloy/Out Degree.png index f4717a1a..f4717a1a 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/output/real vs viatra vs alloy/Out Degree.png +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/real vs viatra vs alloy/Out Degree.png | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/statistics/.gitignore b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/input/.gitignore index b3934b01..b3934b01 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/statistics/.gitignore +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/input/.gitignore | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/controled_viatra_with_mpc/Node Activity.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/controled_viatra_with_mpc/Node Activity.jpg new file mode 100644 index 00000000..d2dbd970 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/controled_viatra_with_mpc/Node Activity.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/controled_viatra_with_mpc/mpc.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/controled_viatra_with_mpc/mpc.jpg new file mode 100644 index 00000000..3ca2e0bc --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/controled_viatra_with_mpc/mpc.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/controled_viatra_with_mpc/out_degree.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/controled_viatra_with_mpc/out_degree.jpg new file mode 100644 index 00000000..5b623374 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/controled_viatra_with_mpc/out_degree.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf/mpc.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf/mpc.jpg new file mode 100644 index 00000000..7a744ea6 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf/mpc.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf/node activity.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf/node activity.jpg new file mode 100644 index 00000000..dfcc973e --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf/node activity.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf/out degree.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf/out degree.jpg new file mode 100644 index 00000000..b3f4f912 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf/out degree.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf_instantiator/Node Activity.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf_instantiator/Node Activity.jpg new file mode 100644 index 00000000..f0d09211 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf_instantiator/Node Activity.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf_instantiator/mpc.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf_instantiator/mpc.jpg new file mode 100644 index 00000000..94b070d4 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf_instantiator/mpc.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf_instantiator/out_degree.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf_instantiator/out_degree.jpg new file mode 100644 index 00000000..8d0151fa --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/random_emf_instantiator/out_degree.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_constraints/MPC.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_constraints/MPC.jpg new file mode 100644 index 00000000..b10d97e6 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_constraints/MPC.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_constraints/node activity.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_constraints/node activity.jpg new file mode 100644 index 00000000..e41c998b --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_constraints/node activity.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_constraints/out degree.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_constraints/out degree.jpg new file mode 100644 index 00000000..d2776bc8 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_constraints/out degree.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_no_constraints/MPC.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_no_constraints/MPC.jpg new file mode 100644 index 00000000..19feb5e8 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_no_constraints/MPC.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_no_constraints/node activity.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_no_constraints/node activity.jpg new file mode 100644 index 00000000..bc7a83fc --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_no_constraints/node activity.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_no_constraints/out degree.jpg b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_no_constraints/out degree.jpg new file mode 100644 index 00000000..13094840 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/output/viatra_no_constraints/out degree.jpg | |||
Binary files differ | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance.ipynb b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/src/metrics_distance.ipynb index 550e3978..550e3978 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance.ipynb +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/src/metrics_distance.ipynb | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance_with_selector.ipynb b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/src/metrics_distance_with_selector.ipynb index a0b0ad8d..4c7fecb3 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance_with_selector.ipynb +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/src/metrics_distance_with_selector.ipynb | |||
@@ -16,10 +16,13 @@ | |||
16 | }, | 16 | }, |
17 | { | 17 | { |
18 | "cell_type": "code", | 18 | "cell_type": "code", |
19 | "execution_count": 1, | 19 | "execution_count": 2, |
20 | "metadata": {}, | 20 | "metadata": {}, |
21 | "outputs": [], | 21 | "outputs": [], |
22 | "source": [ | 22 | "source": [ |
23 | "import os, sys\n", | ||
24 | "lib_path = os.path.abspath(os.path.join('..', '..', 'utils'))\n", | ||
25 | "sys.path.append(lib_path)\n", | ||
23 | "from GraphType import GraphStat\n", | 26 | "from GraphType import GraphStat\n", |
24 | "from GraphType import GraphCollection\n", | 27 | "from GraphType import GraphCollection\n", |
25 | "from scipy import stats\n", | 28 | "from scipy import stats\n", |
@@ -48,7 +51,7 @@ | |||
48 | }, | 51 | }, |
49 | { | 52 | { |
50 | "cell_type": "code", | 53 | "cell_type": "code", |
51 | "execution_count": 2, | 54 | "execution_count": 3, |
52 | "metadata": {}, | 55 | "metadata": {}, |
53 | "outputs": [], | 56 | "outputs": [], |
54 | "source": [ | 57 | "source": [ |
@@ -78,7 +81,7 @@ | |||
78 | }, | 81 | }, |
79 | { | 82 | { |
80 | "cell_type": "code", | 83 | "cell_type": "code", |
81 | "execution_count": 3, | 84 | "execution_count": 4, |
82 | "metadata": {}, | 85 | "metadata": {}, |
83 | "outputs": [], | 86 | "outputs": [], |
84 | "source": [ | 87 | "source": [ |
@@ -108,12 +111,12 @@ | |||
108 | }, | 111 | }, |
109 | { | 112 | { |
110 | "cell_type": "code", | 113 | "cell_type": "code", |
111 | "execution_count": 4, | 114 | "execution_count": 38, |
112 | "metadata": {}, | 115 | "metadata": {}, |
113 | "outputs": [], | 116 | "outputs": [], |
114 | "source": [ | 117 | "source": [ |
115 | "# metric_selector: GraphDistance -> float\n", | 118 | "# metric_selector: GraphDistance -> float\n", |
116 | "def plot(infos, lines, id, metric_selector,colors, title):\n", | 119 | "def plot(infos, lines, id, metric_selector,colors, title, foldername):\n", |
117 | " metric_distances = retrive_info_from_list(metric_selector, list(infos.values()))\n", | 120 | " metric_distances = retrive_info_from_list(metric_selector, list(infos.values()))\n", |
118 | " x = retrive_info_from_list(lambda a : a.graph.num_nodes, list(infos.values()))\n", | 121 | " x = retrive_info_from_list(lambda a : a.graph.num_nodes, list(infos.values()))\n", |
119 | " graph = plt.figure(id,figsize=(18, 10))\n", | 122 | " graph = plt.figure(id,figsize=(18, 10))\n", |
@@ -127,6 +130,8 @@ | |||
127 | " line_y = retrive_info_from_list(metric_selector, line_infos)\n", | 130 | " line_y = retrive_info_from_list(metric_selector, line_infos)\n", |
128 | " line_x = retrive_info_from_list(lambda a : a.graph.num_nodes, line_infos)\n", | 131 | " line_x = retrive_info_from_list(lambda a : a.graph.num_nodes, line_infos)\n", |
129 | " plt.plot(line_x, line_y, marker='o', color=colors[i])\n", | 132 | " plt.plot(line_x, line_y, marker='o', color=colors[i])\n", |
133 | " mkdir_p(foldername)\n", | ||
134 | " plt.savefig(fname = foldername+title+'.jpg', dpi=150)\n", | ||
130 | " #graph.show()" | 135 | " #graph.show()" |
131 | ] | 136 | ] |
132 | }, | 137 | }, |
@@ -139,7 +144,7 @@ | |||
139 | }, | 144 | }, |
140 | { | 145 | { |
141 | "cell_type": "code", | 146 | "cell_type": "code", |
142 | "execution_count": 5, | 147 | "execution_count": 6, |
143 | "metadata": {}, | 148 | "metadata": {}, |
144 | "outputs": [], | 149 | "outputs": [], |
145 | "source": [ | 150 | "source": [ |
@@ -149,7 +154,7 @@ | |||
149 | }, | 154 | }, |
150 | { | 155 | { |
151 | "cell_type": "code", | 156 | "cell_type": "code", |
152 | "execution_count": 6, | 157 | "execution_count": 7, |
153 | "metadata": {}, | 158 | "metadata": {}, |
154 | "outputs": [], | 159 | "outputs": [], |
155 | "source": [ | 160 | "source": [ |
@@ -163,7 +168,7 @@ | |||
163 | }, | 168 | }, |
164 | { | 169 | { |
165 | "cell_type": "code", | 170 | "cell_type": "code", |
166 | "execution_count": 7, | 171 | "execution_count": 8, |
167 | "metadata": {}, | 172 | "metadata": {}, |
168 | "outputs": [], | 173 | "outputs": [], |
169 | "source": [ | 174 | "source": [ |
@@ -176,15 +181,74 @@ | |||
176 | ] | 181 | ] |
177 | }, | 182 | }, |
178 | { | 183 | { |
184 | "cell_type": "code", | ||
185 | "execution_count": 25, | ||
186 | "metadata": {}, | ||
187 | "outputs": [], | ||
188 | "source": [ | ||
189 | "def createRandomColors(size):\n", | ||
190 | " #generate random color for each line\n", | ||
191 | " colors = []\n", | ||
192 | "\n", | ||
193 | " for i in range(0, size):\n", | ||
194 | " color = \"#%06x\" % random.randint(0, 0xFFFFFF)\n", | ||
195 | " colors.append(color)\n", | ||
196 | " return colors" | ||
197 | ] | ||
198 | }, | ||
199 | { | ||
200 | "cell_type": "code", | ||
201 | "execution_count": 43, | ||
202 | "metadata": {}, | ||
203 | "outputs": [], | ||
204 | "source": [ | ||
205 | "def createSelectionWidge(options):\n", | ||
206 | " w = widgets.SelectMultiple(\n", | ||
207 | " options = options,\n", | ||
208 | " value = [],\n", | ||
209 | " description='Trajectory:',\n", | ||
210 | " disabled=False,\n", | ||
211 | " )\n", | ||
212 | " return w" | ||
213 | ] | ||
214 | }, | ||
215 | { | ||
216 | "cell_type": "code", | ||
217 | "execution_count": 33, | ||
218 | "metadata": {}, | ||
219 | "outputs": [], | ||
220 | "source": [ | ||
221 | "def mkdir_p(mypath):\n", | ||
222 | " '''Creates a directory. equivalent to using mkdir -p on the command line'''\n", | ||
223 | "\n", | ||
224 | " from errno import EEXIST\n", | ||
225 | " from os import makedirs,path\n", | ||
226 | "\n", | ||
227 | " try:\n", | ||
228 | " makedirs(mypath)\n", | ||
229 | " except OSError as exc: # Python >2.5\n", | ||
230 | " if exc.errno == EEXIST and path.isdir(mypath):\n", | ||
231 | " pass\n", | ||
232 | " else: raise" | ||
233 | ] | ||
234 | }, | ||
235 | { | ||
236 | "cell_type": "markdown", | ||
237 | "metadata": {}, | ||
238 | "source": [ | ||
239 | "## Metrics During GenerationPlots" | ||
240 | ] | ||
241 | }, | ||
242 | { | ||
179 | "cell_type": "markdown", | 243 | "cell_type": "markdown", |
180 | "metadata": {}, | 244 | "metadata": {}, |
181 | "source": [ | 245 | "source": [ |
182 | "## Read Models" | 246 | "### Read Human Representatives" |
183 | ] | 247 | ] |
184 | }, | 248 | }, |
185 | { | 249 | { |
186 | "cell_type": "code", | 250 | "cell_type": "code", |
187 | "execution_count": 9, | 251 | "execution_count": 42, |
188 | "metadata": {}, | 252 | "metadata": {}, |
189 | "outputs": [], | 253 | "outputs": [], |
190 | "source": [ | 254 | "source": [ |
@@ -196,73 +260,55 @@ | |||
196 | "\n", | 260 | "\n", |
197 | "# assign rep distributions to human_rep\n", | 261 | "# assign rep distributions to human_rep\n", |
198 | "human_rep.na = human_na.na\n", | 262 | "human_rep.na = human_na.na\n", |
199 | "human_rep.mpc = human_mpc.mpc\n", | 263 | "human_rep.mpc = human_mpc.mpc" |
200 | "# Read generated models\n", | ||
201 | "viatra_no_con_stats = readStats('../statistics/viatra_nocon_output/', 5000)\n", | ||
202 | "viatra_con_stats = readStats('../statistics/viatra_con_output/',5000)\n", | ||
203 | "random_stats = readStats('../statistics/random_output/',5000)\n", | ||
204 | "con_viatra_stats = readStats('../statistics/controled_viatra/',300)" | ||
205 | ] | 264 | ] |
206 | }, | 265 | }, |
207 | { | 266 | { |
208 | "cell_type": "markdown", | 267 | "cell_type": "markdown", |
209 | "metadata": {}, | 268 | "metadata": {}, |
210 | "source": [ | 269 | "source": [ |
211 | "## calculate distribution distantces" | 270 | "## Viatra No Constraint" |
212 | ] | 271 | ] |
213 | }, | 272 | }, |
214 | { | 273 | { |
215 | "cell_type": "code", | 274 | "cell_type": "code", |
216 | "execution_count": 10, | 275 | "execution_count": 15, |
217 | "metadata": {}, | 276 | "metadata": {}, |
218 | "outputs": [], | 277 | "outputs": [], |
219 | "source": [ | 278 | "source": [ |
220 | "viatra_no_con_dic = calDistanceDic(viatra_no_con_stats, human_rep)\n", | 279 | "# Read generated models\n", |
221 | "viatra_con_dic = calDistanceDic(viatra_con_stats, human_rep)\n", | 280 | "viatra_no_con_stats = readStats('../input/viatra_nocon_output/', 5000)\n", |
222 | "random_dic = calDistanceDic(random_stats, human_rep)\n", | 281 | "viatra_no_con_dic = calDistanceDic(viatra_no_con_stats, human_rep)" |
223 | "con_viatra_dic = calDistanceDic(con_viatra_stats, human_rep)" | ||
224 | ] | 282 | ] |
225 | }, | 283 | }, |
226 | { | 284 | { |
227 | "cell_type": "code", | 285 | "cell_type": "code", |
228 | "execution_count": 11, | 286 | "execution_count": 46, |
229 | "metadata": {}, | 287 | "metadata": {}, |
230 | "outputs": [], | 288 | "outputs": [], |
231 | "source": [ | 289 | "source": [ |
232 | "filenames = reader.readmultiplefiles('../statistics/viatra_nocon_output/trajectories/', 15, False)\n", | 290 | "filenames = reader.readmultiplefiles('../input/viatra_nocon_output/trajectories/', 15, False)\n", |
233 | "trajectories = {}\n", | 291 | "trajectories = {}\n", |
234 | "for name in filenames:\n", | 292 | "for name in filenames:\n", |
235 | " trajectories[name] = reader.readTrajectory(name)\n", | 293 | " trajectories[name] = reader.readTrajectory(name)\n", |
236 | "\n", | 294 | "w = createSelectionWidge(trajectories)\n", |
237 | "w = widgets.SelectMultiple(\n", | 295 | "colors = createRandomColors(len(trajectories))" |
238 | " options = trajectories,\n", | ||
239 | " value = [trajectories[filenames[0]]],\n", | ||
240 | " description='Trajectory:',\n", | ||
241 | " disabled=False,\n", | ||
242 | ")\n", | ||
243 | "\n", | ||
244 | "#generate random color for each line\n", | ||
245 | "colors = []\n", | ||
246 | "\n", | ||
247 | "for i in range(0, len(trajectories)):\n", | ||
248 | " color = \"#%06x\" % random.randint(0, 0xFFFFFF)\n", | ||
249 | " colors.append(color)" | ||
250 | ] | 296 | ] |
251 | }, | 297 | }, |
252 | { | 298 | { |
253 | "cell_type": "code", | 299 | "cell_type": "code", |
254 | "execution_count": 12, | 300 | "execution_count": 77, |
255 | "metadata": {}, | 301 | "metadata": {}, |
256 | "outputs": [ | 302 | "outputs": [ |
257 | { | 303 | { |
258 | "data": { | 304 | "data": { |
259 | "application/vnd.jupyter.widget-view+json": { | 305 | "application/vnd.jupyter.widget-view+json": { |
260 | "model_id": "868a437468d24144926f1390cbf2acb8", | 306 | "model_id": "9519be563fbc41c28921c77ef6481b17", |
261 | "version_major": 2, | 307 | "version_major": 2, |
262 | "version_minor": 0 | 308 | "version_minor": 0 |
263 | }, | 309 | }, |
264 | "text/plain": [ | 310 | "text/plain": [ |
265 | "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/viatra_noc…" | 311 | "interactive(children=(SelectMultiple(description='Trajectory:', options={}, value=()), Output()), _dom_classes…" |
266 | ] | 312 | ] |
267 | }, | 313 | }, |
268 | "metadata": {}, | 314 | "metadata": {}, |
@@ -274,31 +320,31 @@ | |||
274 | "<function __main__.plot_out_degree(lines)>" | 320 | "<function __main__.plot_out_degree(lines)>" |
275 | ] | 321 | ] |
276 | }, | 322 | }, |
277 | "execution_count": 12, | 323 | "execution_count": 77, |
278 | "metadata": {}, | 324 | "metadata": {}, |
279 | "output_type": "execute_result" | 325 | "output_type": "execute_result" |
280 | } | 326 | } |
281 | ], | 327 | ], |
282 | "source": [ | 328 | "source": [ |
283 | "def plot_out_degree(lines):\n", | 329 | "def plot_out_degree(lines):\n", |
284 | " plot(viatra_no_con_dic, lines, 0, lambda a: a.out_d_distance, colors, 'out degree')\n", | 330 | " plot(viatra_no_con_dic, lines, 0, lambda a: a.out_d_distance, colors, 'out degree', '../output/viatra_no_constraints/')\n", |
285 | "interact(plot_out_degree, lines=w)" | 331 | "interact(plot_out_degree, lines=w)" |
286 | ] | 332 | ] |
287 | }, | 333 | }, |
288 | { | 334 | { |
289 | "cell_type": "code", | 335 | "cell_type": "code", |
290 | "execution_count": 13, | 336 | "execution_count": 78, |
291 | "metadata": {}, | 337 | "metadata": {}, |
292 | "outputs": [ | 338 | "outputs": [ |
293 | { | 339 | { |
294 | "data": { | 340 | "data": { |
295 | "application/vnd.jupyter.widget-view+json": { | 341 | "application/vnd.jupyter.widget-view+json": { |
296 | "model_id": "e8b74fe96a45445f8062468ddf2597bf", | 342 | "model_id": "c896725e542c4bf8a1bc76ba66819b20", |
297 | "version_major": 2, | 343 | "version_major": 2, |
298 | "version_minor": 0 | 344 | "version_minor": 0 |
299 | }, | 345 | }, |
300 | "text/plain": [ | 346 | "text/plain": [ |
301 | "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/viatra_noc…" | 347 | "interactive(children=(SelectMultiple(description='Trajectory:', options={}, value=()), Output()), _dom_classes…" |
302 | ] | 348 | ] |
303 | }, | 349 | }, |
304 | "metadata": {}, | 350 | "metadata": {}, |
@@ -310,31 +356,31 @@ | |||
310 | "<function __main__.plot_out_na(lines)>" | 356 | "<function __main__.plot_out_na(lines)>" |
311 | ] | 357 | ] |
312 | }, | 358 | }, |
313 | "execution_count": 13, | 359 | "execution_count": 78, |
314 | "metadata": {}, | 360 | "metadata": {}, |
315 | "output_type": "execute_result" | 361 | "output_type": "execute_result" |
316 | } | 362 | } |
317 | ], | 363 | ], |
318 | "source": [ | 364 | "source": [ |
319 | "def plot_out_na(lines):\n", | 365 | "def plot_out_na(lines):\n", |
320 | " plot(viatra_no_con_dic, lines, 0, lambda a: a.na_distance, colors, 'node activity')\n", | 366 | " plot(viatra_no_con_dic, lines, 0, lambda a: a.na_distance, colors, 'node activity', '../output/viatra_no_constraints/')\n", |
321 | "interact(plot_out_na, lines=w)" | 367 | "interact(plot_out_na, lines=w)" |
322 | ] | 368 | ] |
323 | }, | 369 | }, |
324 | { | 370 | { |
325 | "cell_type": "code", | 371 | "cell_type": "code", |
326 | "execution_count": 14, | 372 | "execution_count": 79, |
327 | "metadata": {}, | 373 | "metadata": {}, |
328 | "outputs": [ | 374 | "outputs": [ |
329 | { | 375 | { |
330 | "data": { | 376 | "data": { |
331 | "application/vnd.jupyter.widget-view+json": { | 377 | "application/vnd.jupyter.widget-view+json": { |
332 | "model_id": "c6e7e31f454a48169dac12c8aac70eef", | 378 | "model_id": "880410d675624545ab73977a463bb5c9", |
333 | "version_major": 2, | 379 | "version_major": 2, |
334 | "version_minor": 0 | 380 | "version_minor": 0 |
335 | }, | 381 | }, |
336 | "text/plain": [ | 382 | "text/plain": [ |
337 | "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/viatra_noc…" | 383 | "interactive(children=(SelectMultiple(description='Trajectory:', options={}, value=()), Output()), _dom_classes…" |
338 | ] | 384 | ] |
339 | }, | 385 | }, |
340 | "metadata": {}, | 386 | "metadata": {}, |
@@ -346,26 +392,48 @@ | |||
346 | "<function __main__.plot_out_mpc(lines)>" | 392 | "<function __main__.plot_out_mpc(lines)>" |
347 | ] | 393 | ] |
348 | }, | 394 | }, |
349 | "execution_count": 14, | 395 | "execution_count": 79, |
350 | "metadata": {}, | 396 | "metadata": {}, |
351 | "output_type": "execute_result" | 397 | "output_type": "execute_result" |
352 | } | 398 | } |
353 | ], | 399 | ], |
354 | "source": [ | 400 | "source": [ |
355 | "def plot_out_mpc(lines):\n", | 401 | "def plot_out_mpc(lines):\n", |
356 | " plot(viatra_no_con_dic, lines, 0, lambda a: a.mpc_distance, colors, 'MPC')\n", | 402 | " plot(viatra_no_con_dic, lines, 0, lambda a: a.mpc_distance, colors, 'MPC', '../output/viatra_no_constraints/')\n", |
357 | "interact(plot_out_mpc, lines=w)" | 403 | "interact(plot_out_mpc, lines=w)" |
358 | ] | 404 | ] |
359 | }, | 405 | }, |
360 | { | 406 | { |
407 | "cell_type": "markdown", | ||
408 | "metadata": {}, | ||
409 | "source": [ | ||
410 | "## Viatra with constraints" | ||
411 | ] | ||
412 | }, | ||
413 | { | ||
361 | "cell_type": "code", | 414 | "cell_type": "code", |
362 | "execution_count": 15, | 415 | "execution_count": 50, |
416 | "metadata": {}, | ||
417 | "outputs": [], | ||
418 | "source": [ | ||
419 | "viatra_con_stats = readStats('../input/viatra_con_output/',5000)\n", | ||
420 | "viatra_con_dic = calDistanceDic(viatra_con_stats, human_rep)\n", | ||
421 | "\n", | ||
422 | "# trajectories and colors\n", | ||
423 | "trajectories = {}\n", | ||
424 | "w = createSelectionWidge(trajectories)\n", | ||
425 | "colors = createRandomColors(len(trajectories))" | ||
426 | ] | ||
427 | }, | ||
428 | { | ||
429 | "cell_type": "code", | ||
430 | "execution_count": 51, | ||
363 | "metadata": {}, | 431 | "metadata": {}, |
364 | "outputs": [ | 432 | "outputs": [ |
365 | { | 433 | { |
366 | "data": { | 434 | "data": { |
367 | "application/vnd.jupyter.widget-view+json": { | 435 | "application/vnd.jupyter.widget-view+json": { |
368 | "model_id": "cebc359548f74cc8b7540ecc3876c9ee", | 436 | "model_id": "0d04d6db770a49f4a160ff55cc7131f6", |
369 | "version_major": 2, | 437 | "version_major": 2, |
370 | "version_minor": 0 | 438 | "version_minor": 0 |
371 | }, | 439 | }, |
@@ -382,26 +450,26 @@ | |||
382 | "<function __main__.plot_out_degree(lines)>" | 450 | "<function __main__.plot_out_degree(lines)>" |
383 | ] | 451 | ] |
384 | }, | 452 | }, |
385 | "execution_count": 15, | 453 | "execution_count": 51, |
386 | "metadata": {}, | 454 | "metadata": {}, |
387 | "output_type": "execute_result" | 455 | "output_type": "execute_result" |
388 | } | 456 | } |
389 | ], | 457 | ], |
390 | "source": [ | 458 | "source": [ |
391 | "def plot_out_degree(lines):\n", | 459 | "def plot_out_degree(lines):\n", |
392 | " plot(viatra_con_dic, lines, 0, lambda a: a.out_d_distance, colors, 'out degree')\n", | 460 | " plot(viatra_con_dic, lines, 0, lambda a: a.out_d_distance, colors, 'out degree', '../output/viatra_constraints/')\n", |
393 | "interact(plot_out_degree, lines=[[]])" | 461 | "interact(plot_out_degree, lines=[[]])" |
394 | ] | 462 | ] |
395 | }, | 463 | }, |
396 | { | 464 | { |
397 | "cell_type": "code", | 465 | "cell_type": "code", |
398 | "execution_count": 16, | 466 | "execution_count": 52, |
399 | "metadata": {}, | 467 | "metadata": {}, |
400 | "outputs": [ | 468 | "outputs": [ |
401 | { | 469 | { |
402 | "data": { | 470 | "data": { |
403 | "application/vnd.jupyter.widget-view+json": { | 471 | "application/vnd.jupyter.widget-view+json": { |
404 | "model_id": "682beae42eef4676b11b6fe23127a44e", | 472 | "model_id": "96eebad1f6274d79ad377c8c54b44615", |
405 | "version_major": 2, | 473 | "version_major": 2, |
406 | "version_minor": 0 | 474 | "version_minor": 0 |
407 | }, | 475 | }, |
@@ -418,26 +486,26 @@ | |||
418 | "<function __main__.plot_na(lines)>" | 486 | "<function __main__.plot_na(lines)>" |
419 | ] | 487 | ] |
420 | }, | 488 | }, |
421 | "execution_count": 16, | 489 | "execution_count": 52, |
422 | "metadata": {}, | 490 | "metadata": {}, |
423 | "output_type": "execute_result" | 491 | "output_type": "execute_result" |
424 | } | 492 | } |
425 | ], | 493 | ], |
426 | "source": [ | 494 | "source": [ |
427 | "def plot_na(lines):\n", | 495 | "def plot_na(lines):\n", |
428 | " plot(viatra_con_dic, lines, 0, lambda a: a.na_distance, colors, 'node activity')\n", | 496 | " plot(viatra_con_dic, lines, 0, lambda a: a.na_distance, colors, 'node activity', '../output/viatra_constraints/')\n", |
429 | "interact(plot_na, lines=[[]])" | 497 | "interact(plot_na, lines=[[]])" |
430 | ] | 498 | ] |
431 | }, | 499 | }, |
432 | { | 500 | { |
433 | "cell_type": "code", | 501 | "cell_type": "code", |
434 | "execution_count": 17, | 502 | "execution_count": 53, |
435 | "metadata": {}, | 503 | "metadata": {}, |
436 | "outputs": [ | 504 | "outputs": [ |
437 | { | 505 | { |
438 | "data": { | 506 | "data": { |
439 | "application/vnd.jupyter.widget-view+json": { | 507 | "application/vnd.jupyter.widget-view+json": { |
440 | "model_id": "6893b8c6e03441f89fc35bf784992ae9", | 508 | "model_id": "4fc2714a3cd3440daf5014bb4b942b9a", |
441 | "version_major": 2, | 509 | "version_major": 2, |
442 | "version_minor": 0 | 510 | "version_minor": 0 |
443 | }, | 511 | }, |
@@ -454,26 +522,48 @@ | |||
454 | "<function __main__.plot_mpc(lines)>" | 522 | "<function __main__.plot_mpc(lines)>" |
455 | ] | 523 | ] |
456 | }, | 524 | }, |
457 | "execution_count": 17, | 525 | "execution_count": 53, |
458 | "metadata": {}, | 526 | "metadata": {}, |
459 | "output_type": "execute_result" | 527 | "output_type": "execute_result" |
460 | } | 528 | } |
461 | ], | 529 | ], |
462 | "source": [ | 530 | "source": [ |
463 | "def plot_mpc(lines):\n", | 531 | "def plot_mpc(lines):\n", |
464 | " plot(viatra_con_dic, lines, 0, lambda a: a.mpc_distance, colors, 'MPC')\n", | 532 | " plot(viatra_con_dic, lines, 0, lambda a: a.mpc_distance, colors, 'MPC', '../output/viatra_constraints/')\n", |
465 | "interact(plot_mpc, lines=[[]])" | 533 | "interact(plot_mpc, lines=[[]])" |
466 | ] | 534 | ] |
467 | }, | 535 | }, |
468 | { | 536 | { |
537 | "cell_type": "markdown", | ||
538 | "metadata": {}, | ||
539 | "source": [ | ||
540 | "## Controlled RandomEMF" | ||
541 | ] | ||
542 | }, | ||
543 | { | ||
469 | "cell_type": "code", | 544 | "cell_type": "code", |
470 | "execution_count": 18, | 545 | "execution_count": 59, |
546 | "metadata": {}, | ||
547 | "outputs": [], | ||
548 | "source": [ | ||
549 | "random_emf_stats = readStats('../input/random_emf_output/',5000)\n", | ||
550 | "random_emf_dic = calDistanceDic(random_emf_stats, human_rep)\n", | ||
551 | "\n", | ||
552 | "# trajectories and colors\n", | ||
553 | "trajectories = {}\n", | ||
554 | "w = createSelectionWidge(trajectories)\n", | ||
555 | "colors = createRandomColors(len(trajectories))" | ||
556 | ] | ||
557 | }, | ||
558 | { | ||
559 | "cell_type": "code", | ||
560 | "execution_count": 60, | ||
471 | "metadata": {}, | 561 | "metadata": {}, |
472 | "outputs": [ | 562 | "outputs": [ |
473 | { | 563 | { |
474 | "data": { | 564 | "data": { |
475 | "application/vnd.jupyter.widget-view+json": { | 565 | "application/vnd.jupyter.widget-view+json": { |
476 | "model_id": "ff0e1991c69a4d77a40f57225f90295a", | 566 | "model_id": "4401931533b5497f864f146d7b4dcd3c", |
477 | "version_major": 2, | 567 | "version_major": 2, |
478 | "version_minor": 0 | 568 | "version_minor": 0 |
479 | }, | 569 | }, |
@@ -490,26 +580,26 @@ | |||
490 | "<function __main__.plot_out_degree(lines)>" | 580 | "<function __main__.plot_out_degree(lines)>" |
491 | ] | 581 | ] |
492 | }, | 582 | }, |
493 | "execution_count": 18, | 583 | "execution_count": 60, |
494 | "metadata": {}, | 584 | "metadata": {}, |
495 | "output_type": "execute_result" | 585 | "output_type": "execute_result" |
496 | } | 586 | } |
497 | ], | 587 | ], |
498 | "source": [ | 588 | "source": [ |
499 | "def plot_out_degree(lines):\n", | 589 | "def plot_out_degree(lines):\n", |
500 | " plot(random_dic, lines, 0, lambda a: a.out_d_distance, colors, 'out degree')\n", | 590 | " plot(random_emf_dic, lines, 0, lambda a: a.out_d_distance, colors, 'out degree', '../output/random_emf/')\n", |
501 | "interact(plot_out_degree, lines=[[]])" | 591 | "interact(plot_out_degree, lines=[[]])" |
502 | ] | 592 | ] |
503 | }, | 593 | }, |
504 | { | 594 | { |
505 | "cell_type": "code", | 595 | "cell_type": "code", |
506 | "execution_count": 19, | 596 | "execution_count": 61, |
507 | "metadata": {}, | 597 | "metadata": {}, |
508 | "outputs": [ | 598 | "outputs": [ |
509 | { | 599 | { |
510 | "data": { | 600 | "data": { |
511 | "application/vnd.jupyter.widget-view+json": { | 601 | "application/vnd.jupyter.widget-view+json": { |
512 | "model_id": "838570f20bed4d8d9c618305984d19ef", | 602 | "model_id": "fb7bdedff841420bb8f817013f565020", |
513 | "version_major": 2, | 603 | "version_major": 2, |
514 | "version_minor": 0 | 604 | "version_minor": 0 |
515 | }, | 605 | }, |
@@ -523,29 +613,29 @@ | |||
523 | { | 613 | { |
524 | "data": { | 614 | "data": { |
525 | "text/plain": [ | 615 | "text/plain": [ |
526 | "<function __main__.plot_out_degree(lines)>" | 616 | "<function __main__.plot_node_activity(lines)>" |
527 | ] | 617 | ] |
528 | }, | 618 | }, |
529 | "execution_count": 19, | 619 | "execution_count": 61, |
530 | "metadata": {}, | 620 | "metadata": {}, |
531 | "output_type": "execute_result" | 621 | "output_type": "execute_result" |
532 | } | 622 | } |
533 | ], | 623 | ], |
534 | "source": [ | 624 | "source": [ |
535 | "def plot_out_degree(lines):\n", | 625 | "def plot_node_activity(lines):\n", |
536 | " plot(random_dic, lines, 0, lambda a: a.na_distance, colors, 'out degree')\n", | 626 | " plot(random_emf_dic, lines, 0, lambda a: a.na_distance, colors, 'node activity', '../output/random_emf/')\n", |
537 | "interact(plot_out_degree, lines=[[]])" | 627 | "interact(plot_node_activity, lines=[[]])" |
538 | ] | 628 | ] |
539 | }, | 629 | }, |
540 | { | 630 | { |
541 | "cell_type": "code", | 631 | "cell_type": "code", |
542 | "execution_count": 20, | 632 | "execution_count": 62, |
543 | "metadata": {}, | 633 | "metadata": {}, |
544 | "outputs": [ | 634 | "outputs": [ |
545 | { | 635 | { |
546 | "data": { | 636 | "data": { |
547 | "application/vnd.jupyter.widget-view+json": { | 637 | "application/vnd.jupyter.widget-view+json": { |
548 | "model_id": "f4825f6257a74bce9dd22aac8a98effa", | 638 | "model_id": "6b0c349c4a3b4813825513f739ea30da", |
549 | "version_major": 2, | 639 | "version_major": 2, |
550 | "version_minor": 0 | 640 | "version_minor": 0 |
551 | }, | 641 | }, |
@@ -559,70 +649,56 @@ | |||
559 | { | 649 | { |
560 | "data": { | 650 | "data": { |
561 | "text/plain": [ | 651 | "text/plain": [ |
562 | "<function __main__.plot_out_degree(lines)>" | 652 | "<function __main__.plot_mpc(lines)>" |
563 | ] | 653 | ] |
564 | }, | 654 | }, |
565 | "execution_count": 20, | 655 | "execution_count": 62, |
566 | "metadata": {}, | 656 | "metadata": {}, |
567 | "output_type": "execute_result" | 657 | "output_type": "execute_result" |
568 | } | 658 | } |
569 | ], | 659 | ], |
570 | "source": [ | 660 | "source": [ |
571 | "def plot_out_degree(lines):\n", | 661 | "def plot_mpc(lines):\n", |
572 | " plot(random_dic, lines, 0, lambda a: a.mpc_distance, colors, 'out degree')\n", | 662 | " plot(random_emf_dic, lines, 0, lambda a: a.mpc_distance, colors, 'mpc', '../output/random_emf/')\n", |
573 | "interact(plot_out_degree, lines=[[]])" | 663 | "interact(plot_mpc, lines=[[]])" |
574 | ] | ||
575 | }, | ||
576 | { | ||
577 | "cell_type": "code", | ||
578 | "execution_count": 54, | ||
579 | "metadata": {}, | ||
580 | "outputs": [], | ||
581 | "source": [ | ||
582 | "con_viatra_stats = readStats('../statistics/controled_viatra/',5000)\n", | ||
583 | "con_viatra_dic = calDistanceDic(con_viatra_stats, human_rep)" | ||
584 | ] | 664 | ] |
585 | }, | 665 | }, |
586 | { | 666 | { |
587 | "cell_type": "markdown", | 667 | "cell_type": "markdown", |
588 | "metadata": {}, | 668 | "metadata": {}, |
589 | "source": [ | 669 | "source": [ |
590 | "## Trajectories for controlled viatra solver" | 670 | "## Controlled Viatra with MPC" |
591 | ] | 671 | ] |
592 | }, | 672 | }, |
593 | { | 673 | { |
594 | "cell_type": "code", | 674 | "cell_type": "code", |
595 | "execution_count": 56, | 675 | "execution_count": 67, |
596 | "metadata": {}, | 676 | "metadata": {}, |
597 | "outputs": [], | 677 | "outputs": [], |
598 | "source": [ | 678 | "source": [ |
599 | "filenames = reader.readmultiplefiles('../statistics/controled_viatra/trajectories/', 25, False)\n", | 679 | "con_viatra_stats = readStats('../input/controled_viatra_mpc/',5000)\n", |
600 | "trajectories = {}\n", | 680 | "con_viatra_dic = calDistanceDic(con_viatra_stats, human_rep)\n", |
601 | "for name in filenames:\n", | ||
602 | " trajectories[name] = reader.readTrajectory(name)\n", | ||
603 | "\n", | 681 | "\n", |
604 | "w = widgets.SelectMultiple(\n", | 682 | "# trajectories and colors\n", |
605 | " options = trajectories,\n", | 683 | "trajectories = {}\n", |
606 | " value = [trajectories[filenames[0]]],\n", | 684 | "w = createSelectionWidge(trajectories)\n", |
607 | " description='Trajectory:',\n", | 685 | "colors = createRandomColors(len(trajectories))" |
608 | " disabled=False,\n", | ||
609 | ")" | ||
610 | ] | 686 | ] |
611 | }, | 687 | }, |
612 | { | 688 | { |
613 | "cell_type": "code", | 689 | "cell_type": "code", |
614 | "execution_count": 57, | 690 | "execution_count": 74, |
615 | "metadata": {}, | 691 | "metadata": {}, |
616 | "outputs": [ | 692 | "outputs": [ |
617 | { | 693 | { |
618 | "data": { | 694 | "data": { |
619 | "application/vnd.jupyter.widget-view+json": { | 695 | "application/vnd.jupyter.widget-view+json": { |
620 | "model_id": "4b60ae3859e343299badf29272f67d21", | 696 | "model_id": "b76901ba9d44433984032e0dc5679fa9", |
621 | "version_major": 2, | 697 | "version_major": 2, |
622 | "version_minor": 0 | 698 | "version_minor": 0 |
623 | }, | 699 | }, |
624 | "text/plain": [ | 700 | "text/plain": [ |
625 | "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/controled_…" | 701 | "interactive(children=(SelectMultiple(description='Trajectory:', options={}, value=()), Output()), _dom_classes…" |
626 | ] | 702 | ] |
627 | }, | 703 | }, |
628 | "metadata": {}, | 704 | "metadata": {}, |
@@ -634,31 +710,31 @@ | |||
634 | "<function __main__.plot_out_degree(lines)>" | 710 | "<function __main__.plot_out_degree(lines)>" |
635 | ] | 711 | ] |
636 | }, | 712 | }, |
637 | "execution_count": 57, | 713 | "execution_count": 74, |
638 | "metadata": {}, | 714 | "metadata": {}, |
639 | "output_type": "execute_result" | 715 | "output_type": "execute_result" |
640 | } | 716 | } |
641 | ], | 717 | ], |
642 | "source": [ | 718 | "source": [ |
643 | "def plot_out_degree(lines):\n", | 719 | "def plot_out_degree(lines):\n", |
644 | " plot(con_viatra_dic, lines, 0, lambda a: a.out_d_distance, colors, 'out_degree')\n", | 720 | " plot(con_viatra_dic, lines, 0, lambda a: a.out_d_distance, colors, 'out_degree', '../output/controled_viatra_with_mpc/')\n", |
645 | "interact(plot_out_degree, lines=w)" | 721 | "interact(plot_out_degree, lines=w)" |
646 | ] | 722 | ] |
647 | }, | 723 | }, |
648 | { | 724 | { |
649 | "cell_type": "code", | 725 | "cell_type": "code", |
650 | "execution_count": 58, | 726 | "execution_count": 75, |
651 | "metadata": {}, | 727 | "metadata": {}, |
652 | "outputs": [ | 728 | "outputs": [ |
653 | { | 729 | { |
654 | "data": { | 730 | "data": { |
655 | "application/vnd.jupyter.widget-view+json": { | 731 | "application/vnd.jupyter.widget-view+json": { |
656 | "model_id": "8e7965d793a146d4bbc268554262eb58", | 732 | "model_id": "9e0d61e29b02467cb52618860a1bde7f", |
657 | "version_major": 2, | 733 | "version_major": 2, |
658 | "version_minor": 0 | 734 | "version_minor": 0 |
659 | }, | 735 | }, |
660 | "text/plain": [ | 736 | "text/plain": [ |
661 | "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/controled_…" | 737 | "interactive(children=(SelectMultiple(description='Trajectory:', options={}, value=()), Output()), _dom_classes…" |
662 | ] | 738 | ] |
663 | }, | 739 | }, |
664 | "metadata": {}, | 740 | "metadata": {}, |
@@ -670,31 +746,31 @@ | |||
670 | "<function __main__.plot_na(lines)>" | 746 | "<function __main__.plot_na(lines)>" |
671 | ] | 747 | ] |
672 | }, | 748 | }, |
673 | "execution_count": 58, | 749 | "execution_count": 75, |
674 | "metadata": {}, | 750 | "metadata": {}, |
675 | "output_type": "execute_result" | 751 | "output_type": "execute_result" |
676 | } | 752 | } |
677 | ], | 753 | ], |
678 | "source": [ | 754 | "source": [ |
679 | "def plot_na(lines):\n", | 755 | "def plot_na(lines):\n", |
680 | " plot(con_viatra_dic, lines, 0, lambda a: a.na_distance, colors, 'Node Activity')\n", | 756 | " plot(con_viatra_dic, lines, 0, lambda a: a.na_distance, colors, 'Node Activity', '../output/controled_viatra_with_mpc/')\n", |
681 | "interact(plot_na, lines=w)" | 757 | "interact(plot_na, lines=w)" |
682 | ] | 758 | ] |
683 | }, | 759 | }, |
684 | { | 760 | { |
685 | "cell_type": "code", | 761 | "cell_type": "code", |
686 | "execution_count": 59, | 762 | "execution_count": 76, |
687 | "metadata": {}, | 763 | "metadata": {}, |
688 | "outputs": [ | 764 | "outputs": [ |
689 | { | 765 | { |
690 | "data": { | 766 | "data": { |
691 | "application/vnd.jupyter.widget-view+json": { | 767 | "application/vnd.jupyter.widget-view+json": { |
692 | "model_id": "55a1209d0b924a39b4729228e81ee3ab", | 768 | "model_id": "70074805fee44a1aa5b9ccb3770b5c0c", |
693 | "version_major": 2, | 769 | "version_major": 2, |
694 | "version_minor": 0 | 770 | "version_minor": 0 |
695 | }, | 771 | }, |
696 | "text/plain": [ | 772 | "text/plain": [ |
697 | "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/controled_…" | 773 | "interactive(children=(SelectMultiple(description='Trajectory:', options={}, value=()), Output()), _dom_classes…" |
698 | ] | 774 | ] |
699 | }, | 775 | }, |
700 | "metadata": {}, | 776 | "metadata": {}, |
@@ -706,30 +782,146 @@ | |||
706 | "<function __main__.plot_mpc(lines)>" | 782 | "<function __main__.plot_mpc(lines)>" |
707 | ] | 783 | ] |
708 | }, | 784 | }, |
709 | "execution_count": 59, | 785 | "execution_count": 76, |
710 | "metadata": {}, | 786 | "metadata": {}, |
711 | "output_type": "execute_result" | 787 | "output_type": "execute_result" |
712 | } | 788 | } |
713 | ], | 789 | ], |
714 | "source": [ | 790 | "source": [ |
715 | "def plot_mpc(lines):\n", | 791 | "def plot_mpc(lines):\n", |
716 | " plot(con_viatra_dic, lines, 0, lambda a: a.mpc_distance, colors, 'mpc')\n", | 792 | " plot(con_viatra_dic, lines, 0, lambda a: a.mpc_distance, colors, 'mpc', '../output/controled_viatra_with_mpc/')\n", |
717 | "interact(plot_mpc, lines=w)" | 793 | "interact(plot_mpc, lines=w)" |
718 | ] | 794 | ] |
719 | }, | 795 | }, |
720 | { | 796 | { |
797 | "cell_type": "markdown", | ||
798 | "metadata": {}, | ||
799 | "source": [ | ||
800 | "## (Pseudo) Random EMF instantiator" | ||
801 | ] | ||
802 | }, | ||
803 | { | ||
721 | "cell_type": "code", | 804 | "cell_type": "code", |
722 | "execution_count": null, | 805 | "execution_count": 80, |
723 | "metadata": {}, | 806 | "metadata": {}, |
724 | "outputs": [], | 807 | "outputs": [], |
725 | "source": [] | 808 | "source": [ |
809 | "random_emf_stats = readStats('../input/real_random_output/',5000)\n", | ||
810 | "random_emf_dic = calDistanceDic(random_emf_stats, human_rep)\n", | ||
811 | "\n", | ||
812 | "# trajectories and colors\n", | ||
813 | "trajectories = {}\n", | ||
814 | "w = createSelectionWidge(trajectories)\n", | ||
815 | "colors = createRandomColors(len(trajectories))" | ||
816 | ] | ||
726 | }, | 817 | }, |
727 | { | 818 | { |
728 | "cell_type": "code", | 819 | "cell_type": "code", |
729 | "execution_count": null, | 820 | "execution_count": 82, |
730 | "metadata": {}, | 821 | "metadata": {}, |
731 | "outputs": [], | 822 | "outputs": [ |
732 | "source": [] | 823 | { |
824 | "data": { | ||
825 | "application/vnd.jupyter.widget-view+json": { | ||
826 | "model_id": "912ba2fdfd7c46848065f174aa6177e0", | ||
827 | "version_major": 2, | ||
828 | "version_minor": 0 | ||
829 | }, | ||
830 | "text/plain": [ | ||
831 | "interactive(children=(SelectMultiple(description='Trajectory:', options={}, value=()), Output()), _dom_classes…" | ||
832 | ] | ||
833 | }, | ||
834 | "metadata": {}, | ||
835 | "output_type": "display_data" | ||
836 | }, | ||
837 | { | ||
838 | "data": { | ||
839 | "text/plain": [ | ||
840 | "<function __main__.plot_out_degree(lines)>" | ||
841 | ] | ||
842 | }, | ||
843 | "execution_count": 82, | ||
844 | "metadata": {}, | ||
845 | "output_type": "execute_result" | ||
846 | } | ||
847 | ], | ||
848 | "source": [ | ||
849 | "def plot_out_degree(lines):\n", | ||
850 | " plot(random_emf_dic, lines, 0, lambda a: a.out_d_distance, colors, 'out_degree', '../output/random_emf_instantiator/')\n", | ||
851 | "interact(plot_out_degree, lines=w)" | ||
852 | ] | ||
853 | }, | ||
854 | { | ||
855 | "cell_type": "code", | ||
856 | "execution_count": 83, | ||
857 | "metadata": {}, | ||
858 | "outputs": [ | ||
859 | { | ||
860 | "data": { | ||
861 | "application/vnd.jupyter.widget-view+json": { | ||
862 | "model_id": "0ba621dd0e7d4957aaff2cf209bba165", | ||
863 | "version_major": 2, | ||
864 | "version_minor": 0 | ||
865 | }, | ||
866 | "text/plain": [ | ||
867 | "interactive(children=(SelectMultiple(description='Trajectory:', options={}, value=()), Output()), _dom_classes…" | ||
868 | ] | ||
869 | }, | ||
870 | "metadata": {}, | ||
871 | "output_type": "display_data" | ||
872 | }, | ||
873 | { | ||
874 | "data": { | ||
875 | "text/plain": [ | ||
876 | "<function __main__.plot_na(lines)>" | ||
877 | ] | ||
878 | }, | ||
879 | "execution_count": 83, | ||
880 | "metadata": {}, | ||
881 | "output_type": "execute_result" | ||
882 | } | ||
883 | ], | ||
884 | "source": [ | ||
885 | "def plot_na(lines):\n", | ||
886 | " plot(random_emf_dic, lines, 0, lambda a: a.na_distance, colors, 'Node Activity', '../output/random_emf_instantiator/')\n", | ||
887 | "interact(plot_na, lines=w)" | ||
888 | ] | ||
889 | }, | ||
890 | { | ||
891 | "cell_type": "code", | ||
892 | "execution_count": 84, | ||
893 | "metadata": {}, | ||
894 | "outputs": [ | ||
895 | { | ||
896 | "data": { | ||
897 | "application/vnd.jupyter.widget-view+json": { | ||
898 | "model_id": "d432bbae1c6f48c3acd1767f2e2b13c7", | ||
899 | "version_major": 2, | ||
900 | "version_minor": 0 | ||
901 | }, | ||
902 | "text/plain": [ | ||
903 | "interactive(children=(SelectMultiple(description='Trajectory:', options={}, value=()), Output()), _dom_classes…" | ||
904 | ] | ||
905 | }, | ||
906 | "metadata": {}, | ||
907 | "output_type": "display_data" | ||
908 | }, | ||
909 | { | ||
910 | "data": { | ||
911 | "text/plain": [ | ||
912 | "<function __main__.plot_mpc(lines)>" | ||
913 | ] | ||
914 | }, | ||
915 | "execution_count": 84, | ||
916 | "metadata": {}, | ||
917 | "output_type": "execute_result" | ||
918 | } | ||
919 | ], | ||
920 | "source": [ | ||
921 | "def plot_mpc(lines):\n", | ||
922 | " plot(random_emf_dic, lines, 0, lambda a: a.mpc_distance, colors, 'mpc', '../output/random_emf_instantiator/')\n", | ||
923 | "interact(plot_mpc, lines=w)" | ||
924 | ] | ||
733 | }, | 925 | }, |
734 | { | 926 | { |
735 | "cell_type": "code", | 927 | "cell_type": "code", |
diff --git a/Metrics/Metrics-Calculation/metrics_plot/src/representative_selector .ipynb b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/src/representative_selector .ipynb index 4886c215..9653b2a0 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/src/representative_selector .ipynb +++ b/Metrics/Metrics-Calculation/metrics_plot/model_evolve_comparison/src/representative_selector .ipynb | |||
@@ -20,6 +20,9 @@ | |||
20 | "metadata": {}, | 20 | "metadata": {}, |
21 | "outputs": [], | 21 | "outputs": [], |
22 | "source": [ | 22 | "source": [ |
23 | "import os, sys\n", | ||
24 | "lib_path = os.path.abspath(os.path.join('..', '..', 'utils'))\n", | ||
25 | "sys.path.append(lib_path)\n", | ||
23 | "from GraphType import GraphStat\n", | 26 | "from GraphType import GraphStat\n", |
24 | "import readCSV as reader\n", | 27 | "import readCSV as reader\n", |
25 | "from scipy import stats\n", | 28 | "from scipy import stats\n", |
@@ -60,7 +63,7 @@ | |||
60 | }, | 63 | }, |
61 | { | 64 | { |
62 | "cell_type": "code", | 65 | "cell_type": "code", |
63 | "execution_count": 3, | 66 | "execution_count": 4, |
64 | "metadata": {}, | 67 | "metadata": {}, |
65 | "outputs": [ | 68 | "outputs": [ |
66 | { | 69 | { |
@@ -69,7 +72,7 @@ | |||
69 | "1253" | 72 | "1253" |
70 | ] | 73 | ] |
71 | }, | 74 | }, |
72 | "execution_count": 3, | 75 | "execution_count": 4, |
73 | "metadata": {}, | 76 | "metadata": {}, |
74 | "output_type": "execute_result" | 77 | "output_type": "execute_result" |
75 | } | 78 | } |
@@ -87,7 +90,7 @@ | |||
87 | ")\n", | 90 | ")\n", |
88 | "\n", | 91 | "\n", |
89 | "\n", | 92 | "\n", |
90 | "humanFiles = reader.readmultiplefiles('../statistics/humanOutput/', 1300, False)\n", | 93 | "humanFiles = reader.readmultiplefiles('../input/humanOutput/', 1300, False)\n", |
91 | "modelToFileName = {}\n", | 94 | "modelToFileName = {}\n", |
92 | "for name in humanFiles:\n", | 95 | "for name in humanFiles:\n", |
93 | " modelToFileName[GraphStat(name)] = name\n", | 96 | " modelToFileName[GraphStat(name)] = name\n", |
@@ -112,7 +115,7 @@ | |||
112 | }, | 115 | }, |
113 | { | 116 | { |
114 | "cell_type": "code", | 117 | "cell_type": "code", |
115 | "execution_count": 7, | 118 | "execution_count": 5, |
116 | "metadata": {}, | 119 | "metadata": {}, |
117 | "outputs": [], | 120 | "outputs": [], |
118 | "source": [ | 121 | "source": [ |
@@ -138,16 +141,24 @@ | |||
138 | ] | 141 | ] |
139 | }, | 142 | }, |
140 | { | 143 | { |
144 | "cell_type": "markdown", | ||
145 | "metadata": {}, | ||
146 | "source": [ | ||
147 | "* the rep found is ../input/humanOutput\\R_20158_run_1.csv\n", | ||
148 | "* the average distance between it and others is 0.05515988287586802" | ||
149 | ] | ||
150 | }, | ||
151 | { | ||
141 | "cell_type": "code", | 152 | "cell_type": "code", |
142 | "execution_count": 8, | 153 | "execution_count": 6, |
143 | "metadata": {}, | 154 | "metadata": {}, |
144 | "outputs": [ | 155 | "outputs": [ |
145 | { | 156 | { |
146 | "name": "stdout", | 157 | "name": "stdout", |
147 | "output_type": "stream", | 158 | "output_type": "stream", |
148 | "text": [ | 159 | "text": [ |
149 | "../statistics/humanOutput\\R_20158_run_1.csv\n", | 160 | "../input/humanOutput\\R_20158_run_1.csv\n", |
150 | "../statistics/humanOutput\\R_20158_run_1.csv\n" | 161 | "../input/humanOutput\\R_20158_run_1.csv\n" |
151 | ] | 162 | ] |
152 | } | 163 | } |
153 | ], | 164 | ], |
@@ -159,6 +170,27 @@ | |||
159 | ] | 170 | ] |
160 | }, | 171 | }, |
161 | { | 172 | { |
173 | "cell_type": "code", | ||
174 | "execution_count": 19, | ||
175 | "metadata": {}, | ||
176 | "outputs": [ | ||
177 | { | ||
178 | "name": "stdout", | ||
179 | "output_type": "stream", | ||
180 | "text": [ | ||
181 | "0.05515988287586802\n" | ||
182 | ] | ||
183 | } | ||
184 | ], | ||
185 | "source": [ | ||
186 | "total_distance = 0\n", | ||
187 | "count = 0\n", | ||
188 | "for model in models:\n", | ||
189 | " total_distance += ks_value(od_rep_model.out_d, model.out_d)\n", | ||
190 | "print(total_distance / len(models))" | ||
191 | ] | ||
192 | }, | ||
193 | { | ||
162 | "cell_type": "markdown", | 194 | "cell_type": "markdown", |
163 | "metadata": {}, | 195 | "metadata": {}, |
164 | "source": [ | 196 | "source": [ |
@@ -166,47 +198,53 @@ | |||
166 | ] | 198 | ] |
167 | }, | 199 | }, |
168 | { | 200 | { |
201 | "cell_type": "markdown", | ||
202 | "metadata": {}, | ||
203 | "source": [ | ||
204 | "* the rep found is ../input/humanOutput\\R_2016176_run_1.csv\n", | ||
205 | "* the average distance between it and others is 0.05275267434589047" | ||
206 | ] | ||
207 | }, | ||
208 | { | ||
169 | "cell_type": "code", | 209 | "cell_type": "code", |
170 | "execution_count": 9, | 210 | "execution_count": 7, |
171 | "metadata": {}, | 211 | "metadata": {}, |
172 | "outputs": [ | 212 | "outputs": [ |
173 | { | 213 | { |
174 | "ename": "NameError", | 214 | "name": "stdout", |
175 | "evalue": "name 'na_rep_index' is not defined", | 215 | "output_type": "stream", |
176 | "output_type": "error", | 216 | "text": [ |
177 | "traceback": [ | 217 | "../input/humanOutput\\R_2016176_run_1.csv\n", |
178 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", | 218 | "../input/humanOutput\\R_2016176_run_1.csv\n" |
179 | "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", | ||
180 | "\u001b[1;32m<ipython-input-9-7899480190c8>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[0mna_rp_index\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mfindRep\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmodels\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;32mlambda\u001b[0m \u001b[0mm\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mm\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mna\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmodelToFileName\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mna_rep_index\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m \u001b[0mna_rep_model\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmodels\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mna_rep_index\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmodelToFileName\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mna_rep_model\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | ||
181 | "\u001b[1;31mNameError\u001b[0m: name 'na_rep_index' is not defined" | ||
182 | ] | 219 | ] |
183 | } | 220 | } |
184 | ], | 221 | ], |
185 | "source": [ | 222 | "source": [ |
186 | "na_rep_index = findRep(models, lambda m: m.na)\n", | 223 | "total_distance = 0\n", |
187 | "print(list(modelToFileName.values())[na_rep_index])\n", | 224 | "for model in models:\n", |
188 | "na_rep_model = models[na_rep_index]\n", | 225 | " total_distance += ks_value(od_rep_model.mpc, model.mpc)\n", |
189 | "print(modelToFileName[na_rep_model])" | 226 | "print(total_distance / len(models))" |
190 | ] | 227 | ] |
191 | }, | 228 | }, |
192 | { | 229 | { |
193 | "cell_type": "code", | 230 | "cell_type": "code", |
194 | "execution_count": 11, | 231 | "execution_count": 18, |
195 | "metadata": {}, | 232 | "metadata": {}, |
196 | "outputs": [ | 233 | "outputs": [ |
197 | { | 234 | { |
198 | "name": "stdout", | 235 | "name": "stdout", |
199 | "output_type": "stream", | 236 | "output_type": "stream", |
200 | "text": [ | 237 | "text": [ |
201 | "../statistics/humanOutput\\R_2016176_run_1.csv\n", | 238 | "0.05275267434589047\n" |
202 | "../statistics/humanOutput\\R_2016176_run_1.csv\n" | ||
203 | ] | 239 | ] |
204 | } | 240 | } |
205 | ], | 241 | ], |
206 | "source": [ | 242 | "source": [ |
207 | "print(list(modelToFileName.values())[na_rp_index])\n", | 243 | "total_distance = 0\n", |
208 | "na_rep_model = models[na_rp_index]\n", | 244 | "count = 0\n", |
209 | "print(modelToFileName[na_rep_model])" | 245 | "for model in models:\n", |
246 | " total_distance += ks_value(od_rep_model.na, model.na)\n", | ||
247 | "print(total_distance / len(models))" | ||
210 | ] | 248 | ] |
211 | }, | 249 | }, |
212 | { | 250 | { |
@@ -217,16 +255,24 @@ | |||
217 | ] | 255 | ] |
218 | }, | 256 | }, |
219 | { | 257 | { |
258 | "cell_type": "markdown", | ||
259 | "metadata": {}, | ||
260 | "source": [ | ||
261 | "* the rep found is ../input/humanOutput\\R_2015246_run_1.csv\n", | ||
262 | "* the average distance between it and others is 0.08556632702185384" | ||
263 | ] | ||
264 | }, | ||
265 | { | ||
220 | "cell_type": "code", | 266 | "cell_type": "code", |
221 | "execution_count": 12, | 267 | "execution_count": 8, |
222 | "metadata": {}, | 268 | "metadata": {}, |
223 | "outputs": [ | 269 | "outputs": [ |
224 | { | 270 | { |
225 | "name": "stdout", | 271 | "name": "stdout", |
226 | "output_type": "stream", | 272 | "output_type": "stream", |
227 | "text": [ | 273 | "text": [ |
228 | "../statistics/humanOutput\\R_2015246_run_1.csv\n", | 274 | "../input/humanOutput\\R_2015246_run_1.csv\n", |
229 | "../statistics/humanOutput\\R_2015246_run_1.csv\n" | 275 | "../input/humanOutput\\R_2015246_run_1.csv\n" |
230 | ] | 276 | ] |
231 | } | 277 | } |
232 | ], | 278 | ], |
@@ -236,6 +282,34 @@ | |||
236 | "mpc_rep_model = models[mpc_rep_index]\n", | 282 | "mpc_rep_model = models[mpc_rep_index]\n", |
237 | "print(modelToFileName[mpc_rep_model])" | 283 | "print(modelToFileName[mpc_rep_model])" |
238 | ] | 284 | ] |
285 | }, | ||
286 | { | ||
287 | "cell_type": "code", | ||
288 | "execution_count": 20, | ||
289 | "metadata": {}, | ||
290 | "outputs": [ | ||
291 | { | ||
292 | "name": "stdout", | ||
293 | "output_type": "stream", | ||
294 | "text": [ | ||
295 | "0.08556632702185384\n" | ||
296 | ] | ||
297 | } | ||
298 | ], | ||
299 | "source": [ | ||
300 | "total_distance = 0\n", | ||
301 | "count = 0\n", | ||
302 | "for model in models:\n", | ||
303 | " total_distance += ks_value(od_rep_model.mpc, model.mpc)\n", | ||
304 | "print(total_distance / len(models))" | ||
305 | ] | ||
306 | }, | ||
307 | { | ||
308 | "cell_type": "code", | ||
309 | "execution_count": null, | ||
310 | "metadata": {}, | ||
311 | "outputs": [], | ||
312 | "source": [] | ||
239 | } | 313 | } |
240 | ], | 314 | ], |
241 | "metadata": { | 315 | "metadata": { |
diff --git a/Metrics/Metrics-Calculation/metrics_plot/src/GraphType.py b/Metrics/Metrics-Calculation/metrics_plot/src/GraphType.py deleted file mode 100644 index eb35aba3..00000000 --- a/Metrics/Metrics-Calculation/metrics_plot/src/GraphType.py +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | import readCSV as reader | ||
2 | import constants | ||
3 | import numpy as np | ||
4 | |||
5 | # graph stats for a collection of graphs | ||
6 | class GraphCollection: | ||
7 | |||
8 | # init with path contrain files and number of files to read reader is imported from (readCSV) | ||
9 | def __init__(self, path, number, name, shouldShuffle = True): | ||
10 | self.out_ds = [] | ||
11 | self.nas = [] | ||
12 | self.mpcs = [] | ||
13 | self.name = name | ||
14 | models = reader.readmultiplefiles(path, number, shouldShuffle) | ||
15 | for i in range(len(models)): | ||
16 | contents, out_d, na, mpc = reader.getmetrics(models[i]) | ||
17 | self.out_ds.append(out_d) | ||
18 | self.nas.append(na) | ||
19 | self.mpcs.append(mpc) | ||
20 | |||
21 | #Graph stat for one graph | ||
22 | class GraphStat: | ||
23 | # init with teh file name of the stat | ||
24 | def __init__(self, filename): | ||
25 | contents, self.out_d, self.na, self.mpc = reader.getmetrics(filename) | ||
26 | self.num_nodes = np.array(contents[constants.NUMBER_NODES]) | ||
27 | if constants.STATE_ID in contents: | ||
28 | self.id = (contents[constants.STATE_ID])[0] | ||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/src/average_ks_plot.py b/Metrics/Metrics-Calculation/metrics_plot/src/average_ks_plot.py deleted file mode 100644 index e949a729..00000000 --- a/Metrics/Metrics-Calculation/metrics_plot/src/average_ks_plot.py +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | from GraphType import GraphStat | ||
2 | from GraphType import GraphCollection | ||
3 | from scipy import stats | ||
4 | import readCSV as reader | ||
5 | import matplotlib.pyplot as plt | ||
6 | |||
7 | class GraphDistance: | ||
8 | #init with a graph stat and a collection of graph stats | ||
9 | def __init__(self, graphStat, collection): | ||
10 | self.graph = graphStat | ||
11 | self.collection = collection | ||
12 | print('calculating for %d' %(self.graph.id)) | ||
13 | self.out_d_distance = average_ks_distance(collection.out_ds, graphStat.out_d) | ||
14 | self.na_distance = average_ks_distance(collection.nas, graphStat.na) | ||
15 | self.mpc_distance = average_ks_distance(collection.mpcs, graphStat.mpc) | ||
16 | |||
17 | def average_ks_distance(targets, sample): | ||
18 | distance = 0.0 | ||
19 | for target in targets: | ||
20 | value, p = stats.ks_2samp(target, sample) | ||
21 | distance += value | ||
22 | |||
23 | distance = distance / len(targets) | ||
24 | return distance | ||
25 | |||
26 | # metric_selector: GraphDistance -> float | ||
27 | def plot(infos, lines, id, metric_selector, title): | ||
28 | metric_distances = retrive_info_from_list(metric_selector, list(infos.values())) | ||
29 | x = retrive_info_from_list(lambda a : a.graph.num_nodes, list(infos.values)) | ||
30 | graph = plt.figure(id) | ||
31 | plt.title(title) | ||
32 | |||
33 | for line in lines: | ||
34 | line_infos = retrive_info_from_list(lambda a: infos[a], line) | ||
35 | line_y = retrive_info_from_list(metric_selector, line_infos) | ||
36 | line_x = retrive_info_from_list(lambda a : a.graph.num_nodes, list(infos.values)) | ||
37 | plt.plot(line_x, line_y, color='blue') | ||
38 | plt.plot(x, metric_distances, color='red', linestyle='', marker='o',alpha=0.7) | ||
39 | graph.show() | ||
40 | |||
41 | def retrive_info_from_list(selector, distances): | ||
42 | return list(map(selector, list(infos.values))) | ||
43 | |||
44 | human = GraphCollection('../statistics/humanOutput/', 300, 'Human') | ||
45 | file_names = reader.readmultiplefiles('../statistics/viatraEvolve/', 500, False) | ||
46 | |||
47 | infos = [] | ||
48 | # read all files | ||
49 | for name in file_names: | ||
50 | infos.append(GraphStat(name)) | ||
51 | |||
52 | infos = list(map(lambda s: GraphDistance(s, human), infos)) | ||
53 | |||
54 | info_dic = {} | ||
55 | for info in infos: | ||
56 | info_dic[info.graph.id] = info | ||
57 | |||
58 | plot(info_dic, [[1,2,3,4,5,6,7,8,9,10]], 0, lambda a: a.out_d_distance, 'out degree') | ||
59 | # plot(info_dic, 1, lambda a: a.na_distance, 'node activity') | ||
60 | # plot(info_dic, 2, lambda a: a.mpc_distance, 'mpc') | ||
61 | |||
62 | input() \ No newline at end of file | ||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/src/constants.py b/Metrics/Metrics-Calculation/metrics_plot/src/constants.py deleted file mode 100644 index 803bae2e..00000000 --- a/Metrics/Metrics-Calculation/metrics_plot/src/constants.py +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | NUMBER_EDGE_TYPES = 'Number of Edge types' | ||
2 | |||
3 | NUMBER_NODES = 'Number Of Nodes' | ||
4 | |||
5 | OUT_DEGREE_COUNT = 'OutDegreeCount' | ||
6 | |||
7 | OUT_DEGREE_VALUE = 'OutDegreeValue' | ||
8 | |||
9 | NA_COUNT = 'NACount' | ||
10 | |||
11 | NA_VALUE = 'NAValue' | ||
12 | |||
13 | MPC_VALUE = 'MPCValue' | ||
14 | |||
15 | MPC_COUNT = 'MPCCount' | ||
16 | |||
17 | METAMODEL = 'Meta Mode' | ||
18 | |||
19 | STATE_ID = 'State Id' | ||
20 | |||
21 | HUMAN_OUT_D_REP = '../statistics/humanOutput/R_20158_run_1.csv' | ||
22 | |||
23 | HUMAN_MPC_REP = '../statistics/humanOutput/R_2015246_run_1.csv' | ||
24 | |||
25 | HUMAN_NA_REP = '../statistics/humanOutput/R_2016176_run_1.csv' | ||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/src/plot_ks_stats.py b/Metrics/Metrics-Calculation/metrics_plot/src/plot_ks_stats.py deleted file mode 100644 index ad72a4a1..00000000 --- a/Metrics/Metrics-Calculation/metrics_plot/src/plot_ks_stats.py +++ /dev/null | |||
@@ -1,90 +0,0 @@ | |||
1 | import glob | ||
2 | import random | ||
3 | from sklearn.manifold import MDS | ||
4 | import matplotlib.pyplot as plt | ||
5 | from scipy import stats | ||
6 | import numpy as np | ||
7 | from GraphType import GraphCollection | ||
8 | |||
9 | def calculateKSMatrix(dists): | ||
10 | dist = [] | ||
11 | |||
12 | for i in range(len(dists)): | ||
13 | dist = dist + dists[i] | ||
14 | matrix = np.empty((len(dist),len(dist))) | ||
15 | |||
16 | for i in range(len(dist)): | ||
17 | matrix[i,i] = 0 | ||
18 | for j in range(i+1, len(dist)): | ||
19 | value, p = stats.ks_2samp(dist[i], dist[j]) | ||
20 | matrix[i, j] = value | ||
21 | matrix[j, i] = value | ||
22 | return matrix | ||
23 | |||
24 | |||
25 | def calculateMDS(dissimilarities): | ||
26 | embedding = MDS(n_components=2, dissimilarity='precomputed') | ||
27 | trans = embedding.fit_transform(X=dissimilarities) | ||
28 | return trans | ||
29 | |||
30 | def plot(graphTypes, coords, title='',index = 0, savePath = ''): | ||
31 | half_length = int(coords.shape[0] / len(graphTypes)) | ||
32 | color = ['blue', 'red', 'green', 'yellow'] | ||
33 | lineStyle = ['', '-'] | ||
34 | plt.figure(index, figsize=(7, 4)) | ||
35 | plt.title(title) | ||
36 | for i in range(len(graphTypes)): | ||
37 | x = (coords[(i*half_length):((i+1)*half_length), 0].tolist()) | ||
38 | y = (coords[(i*half_length):((i+1)*half_length), 1].tolist()) | ||
39 | plt.plot(x, y, color=color[i], marker='o', label = graphTypes[i].name, linestyle=lineStyle[i], alpha=0.7) | ||
40 | plt.legend(loc='upper right') | ||
41 | plt.savefig(fname = savePath, dpi=150) | ||
42 | #graph.show() | ||
43 | |||
44 | def mkdir_p(mypath): | ||
45 | '''Creates a directory. equivalent to using mkdir -p on the command line''' | ||
46 | |||
47 | from errno import EEXIST | ||
48 | from os import makedirs,path | ||
49 | |||
50 | try: | ||
51 | makedirs(mypath) | ||
52 | except OSError as exc: # Python >2.5 | ||
53 | if exc.errno == EEXIST and path.isdir(mypath): | ||
54 | pass | ||
55 | else: raise | ||
56 | |||
57 | def metricStat(graphTypes, metricName, metric, graphIndex): | ||
58 | metrics = [] | ||
59 | foldName = '../output/' | ||
60 | for graph in graphTypes: | ||
61 | metrics.append(metric(graph)) | ||
62 | foldName = foldName + graph.name + '-' | ||
63 | print('calculate' + metricName +' for ' + foldName) | ||
64 | mkdir_p(foldName) | ||
65 | out_d_coords = calculateMDS(calculateKSMatrix(metrics)) | ||
66 | plot(graphTypes, out_d_coords, metricName, graphIndex,foldName + '/'+ metricName+'.png') | ||
67 | |||
68 | def nodeActivity(graphType): | ||
69 | return graphType.nas | ||
70 | |||
71 | def outDegree(graphType): | ||
72 | return graphType.out_ds | ||
73 | |||
74 | def mpc(graphType): | ||
75 | return graphType.mpcs | ||
76 | |||
77 | |||
78 | # read models | ||
79 | human = GraphCollection('../statistics/humanOutput/', 500, 'Human') | ||
80 | # viatra30 = GraphCollection('../statistics/viatraOutput30/', 500, 'Viatra (30 nodes)') | ||
81 | # viatra60 = GraphCollection('../statistics/viatraOutput60/', 500, 'Viatra (60 nodes)') | ||
82 | # viatra100 = GraphCollection('../statistics/viatraOutput100/', 500, 'Viatra (100 nodes)') | ||
83 | # random = GraphCollection('../statistics/randomOutput/', 500, 'Random') | ||
84 | # alloy = GraphCollection('../statistics/alloyOutput/', 500, 'Alloy (30 nodes)') | ||
85 | viatraEvolve = GraphCollection('../statistics/viatraEvolve/', 130, 'viatraEvolve', shouldShuffle = False) | ||
86 | |||
87 | #calculate metrics | ||
88 | metricStat([human, viatraEvolve], 'Node Activity', nodeActivity, 0) | ||
89 | metricStat([human, viatraEvolve], 'Out Degree', outDegree, 1) | ||
90 | metricStat([human, viatraEvolve], 'MPC', mpc, 2) \ No newline at end of file | ||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/src/readCSV.py b/Metrics/Metrics-Calculation/metrics_plot/src/readCSV.py deleted file mode 100644 index e0402519..00000000 --- a/Metrics/Metrics-Calculation/metrics_plot/src/readCSV.py +++ /dev/null | |||
@@ -1,169 +0,0 @@ | |||
1 | import numpy as np | ||
2 | import matplotlib.pyplot as plt | ||
3 | from scipy import stats | ||
4 | import glob | ||
5 | import random | ||
6 | import constants | ||
7 | |||
8 | # | ||
9 | # read csvfile returns outdegree, node activity, mpc | ||
10 | # as matrix with the first row of values and second row of count | ||
11 | # | ||
12 | def readcsvfile(filename): | ||
13 | |||
14 | contents = {} | ||
15 | with open(filename) as f: | ||
16 | for i, line in enumerate(f): | ||
17 | arr = line.split(',') | ||
18 | # if there is no element in the line, continue | ||
19 | if len(line) < 0: continue | ||
20 | # else check for contents | ||
21 | # if it is MPC then use float | ||
22 | if arr[0] == constants.MPC_VALUE: | ||
23 | contents[constants.MPC_VALUE] = list(map(float, arr[1:])) | ||
24 | # meta models are string | ||
25 | elif(arr[0] == constants.METAMODEL): | ||
26 | contents[constants.METAMODEL] = arr[1:] | ||
27 | # all other contants are integer | ||
28 | else: | ||
29 | contents[arr[0]] = list(map(int, arr[1:])) | ||
30 | f.close() | ||
31 | return contents | ||
32 | |||
33 | def checkAndReshape(arr): | ||
34 | if len(arr.shape) < 2: | ||
35 | arr = np.reshape(arr, (arr.shape[0],1)) | ||
36 | return arr | ||
37 | |||
38 | def readTrajectory(filename): | ||
39 | state_codes = [] | ||
40 | with open(filename) as f: | ||
41 | for i, line in enumerate(f): | ||
42 | if(line == ''): continue | ||
43 | state_codes.append(int(line)) | ||
44 | return state_codes | ||
45 | # | ||
46 | # take a matrix as input | ||
47 | # return the sample array | ||
48 | # | ||
49 | def getsample(dataMatrix): | ||
50 | data = [] | ||
51 | value = dataMatrix[0, :] | ||
52 | count = dataMatrix[1, :] | ||
53 | for i, v in enumerate(value): | ||
54 | for x in range(0, int(count[i])): | ||
55 | data.append(v) | ||
56 | return data | ||
57 | |||
58 | def reproduceSample(values, counts): | ||
59 | arr = np.array([values, counts]) | ||
60 | return getsample(arr) | ||
61 | |||
62 | # | ||
63 | # take an array of filenames as input | ||
64 | # return the samples of outdegree, na, mpc | ||
65 | # | ||
66 | def getmetrics(filename): | ||
67 | contents = readcsvfile(filename) | ||
68 | outdegree_sample = reproduceSample(contents[constants.OUT_DEGREE_VALUE], contents[constants.OUT_DEGREE_COUNT]) | ||
69 | na_sample = reproduceSample(contents[constants.NA_VALUE], contents[constants.NA_COUNT]) | ||
70 | mpc_sample = reproduceSample(contents[constants.MPC_VALUE], contents[constants.MPC_COUNT]) | ||
71 | return contents,outdegree_sample, na_sample, mpc_sample | ||
72 | |||
73 | # | ||
74 | # read number of files in the given path RANDOMLY | ||
75 | # | ||
76 | def readmultiplefiles(dirName, maxNumberOfFiles, shouldShuffle = True): | ||
77 | list_of_files = glob.glob(dirName + '*.csv') # create the list of file | ||
78 | if shouldShuffle: | ||
79 | random.shuffle(list_of_files) | ||
80 | #if the number of files is out of bound then just give the whole list | ||
81 | file_names = list_of_files[:maxNumberOfFiles] | ||
82 | # print(file_names) | ||
83 | return file_names | ||
84 | |||
85 | |||
86 | def plotlines(x, y, ax): | ||
87 | l1, = ax.plot(x, y) | ||
88 | |||
89 | |||
90 | def testgetsamplesfromfiles(): | ||
91 | files = readmultiplefiles('../statistics/viatraOutput/', 2) | ||
92 | for file in files: | ||
93 | getmetrics(file) | ||
94 | |||
95 | def probability(data): | ||
96 | sum = np.sum(data) | ||
97 | probabilityList = [] | ||
98 | for d in data: | ||
99 | p = d/sum | ||
100 | probabilityList.append(p) | ||
101 | a = np.array(probabilityList) | ||
102 | return a | ||
103 | |||
104 | |||
105 | def cumulativeProbability(p): | ||
106 | cdf = np.cumsum(p) | ||
107 | return cdf | ||
108 | |||
109 | |||
110 | def plot(): | ||
111 | fig, ax = plt.subplots() | ||
112 | fig, ax1 = plt.subplots() | ||
113 | fig, ax2 = plt.subplots() | ||
114 | fig, ax3 = plt.subplots() | ||
115 | fig, ax4 = plt.subplots() | ||
116 | fig, ax5 = plt.subplots() | ||
117 | list_of_files = readmultiplefiles('../statistics/iatraOutput/') | ||
118 | for file_name in list_of_files: | ||
119 | contents = readcsvfile(file_name) | ||
120 | outdegree = [contents[constants.OUT_DEGREE_VALUE], contents[constants.OUT_DEGREE_COUNT]] | ||
121 | na = [contents[constants.NA_VALUE], contents[constants.NA_COUNT]] | ||
122 | mpc = [contents[constants.MPC_VALUE], contents[constants.MPC_COUNT]] | ||
123 | outV = outdegree[0, :] | ||
124 | outC = outdegree[1, :] | ||
125 | outP = probability(outC) | ||
126 | outCumP = cumulativeProbability(outP) | ||
127 | plotlines(outV, outP, ax) | ||
128 | naV = na[0, :] | ||
129 | naC = na[1, :] | ||
130 | naP = probability(naC) | ||
131 | naCumP = cumulativeProbability(naP) | ||
132 | plotlines(naV, naP, ax1) | ||
133 | mpcV = mpc[0, :] | ||
134 | mpcC = mpc[1, :] | ||
135 | mpcP = probability(mpcC) | ||
136 | mpcCumP = cumulativeProbability(mpcP) | ||
137 | plotlines(mpcV, mpcP, ax2) | ||
138 | plotlines(outV, outCumP, ax3) | ||
139 | plotlines(naV, naCumP, ax4) | ||
140 | plotlines(mpcV, mpcCumP, ax5) | ||
141 | ax.set_xlabel('ourdegree') | ||
142 | ax.set_ylabel('pdf') | ||
143 | ax.grid() | ||
144 | |||
145 | ax1.set_xlabel('node activity') | ||
146 | ax1.set_ylabel('pdf') | ||
147 | ax1.grid() | ||
148 | |||
149 | ax2.set_xlabel('multiplex participation coefficient') | ||
150 | ax2.set_ylabel('pdf') | ||
151 | ax2.grid() | ||
152 | |||
153 | ax3.set_xlabel('ourdegree') | ||
154 | ax3.set_ylabel('cdf') | ||
155 | ax3.grid() | ||
156 | |||
157 | ax4.set_xlabel('node activity') | ||
158 | ax4.set_ylabel('cdf') | ||
159 | ax4.grid() | ||
160 | |||
161 | ax5.set_xlabel('multiplex participation coefficient') | ||
162 | ax5.set_ylabel('cdf') | ||
163 | ax5.grid() | ||
164 | |||
165 | plt.show() | ||
166 | |||
167 | |||
168 | # plot() | ||
169 | |||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/src/test.py b/Metrics/Metrics-Calculation/metrics_plot/src/test.py deleted file mode 100644 index 0212cc2a..00000000 --- a/Metrics/Metrics-Calculation/metrics_plot/src/test.py +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | from pyclustering.cluster.kmedoids import kmedoids | ||
2 | from pyclustering.utils import read_sample | ||
3 | from pyclustering.samples.definitions import FCPS_SAMPLES | ||
4 | from pyclustering.utils.metric import distance_metric, type_metric | ||
5 | import matplotlib.pyplot as plt | ||
6 | |||
7 | # metric = distance_metric(type_metric.MINKOWSKI, degree=2) | ||
8 | # print(metric([1,1], [2,2])) | ||
9 | |||
10 | # Load list of points for cluster analysis. | ||
11 | sample = [[1,1,1], [2,2,2],[3,3,3]] | ||
12 | |||
13 | # Set random initial medoids. | ||
14 | initial_medoids = [1, 1 ,1] | ||
15 | # Create instance of K-Medoids algorithm. | ||
16 | kmedoids_instance = kmedoids(sample, initial_medoids) | ||
17 | # Run cluster analysis and obtain results. | ||
18 | kmedoids_instance.process() | ||
19 | centoids = kmedoids_instance.get_medoids() | ||
20 | clusters = kmedoids_instance.get_clusters() | ||
21 | # Show allocated clusters. | ||
22 | for cluster_id in range(len(clusters)): | ||
23 | for index in clusters[cluster_id]: | ||
24 | if(cluster_id == 0): | ||
25 | plt.plot(sample[index][0], sample[index][1], 'ro') | ||
26 | print(sample[index][0]) | ||
27 | else: | ||
28 | plt.plot(sample[index][0], sample[index][1], 'bo') | ||
29 | |||
30 | plt.plot(sample[centoids[0]][0], sample[centoids[0]][1], 'bo') | ||
31 | # plt.plot(sample[centoids[1]][0], sample[centoids[1]][1], 'ro') | ||
32 | plt.show() \ No newline at end of file | ||
diff --git a/Metrics/Metrics-Calculation/metrics_plot/utils/constants.py b/Metrics/Metrics-Calculation/metrics_plot/utils/constants.py index 58ca7549..ce9d4255 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/utils/constants.py +++ b/Metrics/Metrics-Calculation/metrics_plot/utils/constants.py | |||
@@ -18,8 +18,8 @@ METAMODEL = 'Meta Mode' | |||
18 | 18 | ||
19 | STATE_ID = 'State Id' | 19 | STATE_ID = 'State Id' |
20 | 20 | ||
21 | HUMAN_OUT_D_REP = '../statistics/humanOutput\R_20158_run_1.csv' | 21 | HUMAN_OUT_D_REP = '../input/humanOutput/R_20158_run_1.csv' |
22 | 22 | ||
23 | HUMAN_MPC_REP = '../statistics/humanOutput\R_2015246_run_1.csv' | 23 | HUMAN_MPC_REP = '../input/humanOutput/R_2015246_run_1.csv' |
24 | 24 | ||
25 | HUMAN_NA_REP = '../statistics/humanOutput\R_2016176_run_1.csv' | 25 | HUMAN_NA_REP = '../input/humanOutput/R_2016176_run_1.csv' |