diff options
author | 2020-11-03 22:52:26 -0500 | |
---|---|---|
committer | 2020-11-03 22:52:26 -0500 | |
commit | 945f487a08b643392a5d5918c631640b9a0e4605 (patch) | |
tree | b537c456e395950ce98daaabb9468c7c17d5a72b /Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py | |
parent | Fix numeric-solver-at-end (diff) | |
download | VIATRA-Generator-945f487a08b643392a5d5918c631640b9a0e4605.tar.gz VIATRA-Generator-945f487a08b643392a5d5918c631640b9a0e4605.tar.zst VIATRA-Generator-945f487a08b643392a5d5918c631640b9a0e4605.zip |
add realistic solver
Diffstat (limited to 'Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py')
-rw-r--r-- | Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py b/Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py new file mode 100644 index 00000000..48d96ccc --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py | |||
@@ -0,0 +1,46 @@ | |||
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.nts = [] | ||
14 | self.name = name | ||
15 | self.tccs = [] | ||
16 | self.violations = [] | ||
17 | models = reader.readmultiplefiles(path, number, shouldShuffle) | ||
18 | print(len(models)) | ||
19 | self.size = len(models) | ||
20 | for i in range(len(models)): | ||
21 | contents, out_d, na, mpc = reader.getmetrics(models[i]) | ||
22 | self.out_ds.append(out_d) | ||
23 | self.nas.append(na) | ||
24 | self.mpcs.append(mpc) | ||
25 | if(constants.Node_TYPE_KEY in contents): | ||
26 | self.nts.append(contents[constants.Node_TYPE_KEY]) | ||
27 | if(constants.TCC_VALUE in contents): | ||
28 | self.tccs.append(contents[constants.TCC_VALUE]) | ||
29 | if(constants.VIOLATION in contents): | ||
30 | self.violations.append(contents[constants.VIOLATION][0]) | ||
31 | |||
32 | #Graph stat for one graph | ||
33 | class GraphStat: | ||
34 | # init with teh file name of the stat | ||
35 | def __init__(self, filename): | ||
36 | contents, self.out_d, self.na, self.mpc = reader.getmetrics(filename) | ||
37 | self.numNodes = np.array(contents[constants.NUMBER_NODES]) | ||
38 | if constants.STATE_ID in contents: | ||
39 | self.id = (contents[constants.STATE_ID])[0] | ||
40 | if constants.Node_TYPE_KEY in contents: | ||
41 | self.nodeTypeStat = contents[constants.Node_TYPE_KEY] | ||
42 | if constants.VIOLATION in contents: | ||
43 | self.violations = int(contents[constants.VIOLATION][0]) | ||
44 | if(constants.TCC_VALUE_KEY in contents): | ||
45 | self.tcc = contents[constants.TCC_VALUE_KEY] | ||
46 | |||