mesh-rb 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/ext/mesh/extconf.rb +22 -4
  4. data/ext/mesh/mesh.tar.gz +0 -0
  5. data/lib/mesh/version.rb +1 -1
  6. data/mesh.gemspec +3 -2
  7. metadata +4 -120
  8. data/ext/mesh/mesh/.bazelrc +0 -20
  9. data/ext/mesh/mesh/.bazelversion +0 -1
  10. data/ext/mesh/mesh/.clang-format +0 -15
  11. data/ext/mesh/mesh/.dockerignore +0 -5
  12. data/ext/mesh/mesh/.editorconfig +0 -16
  13. data/ext/mesh/mesh/.gitattributes +0 -4
  14. data/ext/mesh/mesh/.github/workflows/main.yml +0 -144
  15. data/ext/mesh/mesh/.gitignore +0 -51
  16. data/ext/mesh/mesh/AUTHORS +0 -5
  17. data/ext/mesh/mesh/CMakeLists.txt +0 -270
  18. data/ext/mesh/mesh/CODE_OF_CONDUCT.md +0 -77
  19. data/ext/mesh/mesh/Dockerfile +0 -30
  20. data/ext/mesh/mesh/LICENSE +0 -201
  21. data/ext/mesh/mesh/Makefile +0 -81
  22. data/ext/mesh/mesh/README.md +0 -97
  23. data/ext/mesh/mesh/WORKSPACE +0 -50
  24. data/ext/mesh/mesh/bazel +0 -350
  25. data/ext/mesh/mesh/mesh-pldi19-powers.pdf +0 -0
  26. data/ext/mesh/mesh/src/BUILD +0 -222
  27. data/ext/mesh/mesh/src/CMakeLists.txt +0 -85
  28. data/ext/mesh/mesh/src/bitmap.h +0 -590
  29. data/ext/mesh/mesh/src/cheap_heap.h +0 -170
  30. data/ext/mesh/mesh/src/common.h +0 -377
  31. data/ext/mesh/mesh/src/copts.bzl +0 -31
  32. data/ext/mesh/mesh/src/d_assert.cc +0 -75
  33. data/ext/mesh/mesh/src/fixed_array.h +0 -124
  34. data/ext/mesh/mesh/src/global_heap.cc +0 -547
  35. data/ext/mesh/mesh/src/global_heap.h +0 -569
  36. data/ext/mesh/mesh/src/gnu_wrapper.cc +0 -75
  37. data/ext/mesh/mesh/src/internal.h +0 -356
  38. data/ext/mesh/mesh/src/libmesh.cc +0 -239
  39. data/ext/mesh/mesh/src/mac_wrapper.cc +0 -528
  40. data/ext/mesh/mesh/src/measure_rss.cc +0 -44
  41. data/ext/mesh/mesh/src/measure_rss.h +0 -20
  42. data/ext/mesh/mesh/src/meshable_arena.cc +0 -776
  43. data/ext/mesh/mesh/src/meshable_arena.h +0 -309
  44. data/ext/mesh/mesh/src/meshing.h +0 -60
  45. data/ext/mesh/mesh/src/mini_heap.h +0 -532
  46. data/ext/mesh/mesh/src/mmap_heap.h +0 -104
  47. data/ext/mesh/mesh/src/one_way_mmap_heap.h +0 -77
  48. data/ext/mesh/mesh/src/partitioned_heap.h +0 -111
  49. data/ext/mesh/mesh/src/plasma/mesh.h +0 -33
  50. data/ext/mesh/mesh/src/real.cc +0 -52
  51. data/ext/mesh/mesh/src/real.h +0 -36
  52. data/ext/mesh/mesh/src/rng/mwc.h +0 -296
  53. data/ext/mesh/mesh/src/rng/mwc64.h +0 -58
  54. data/ext/mesh/mesh/src/rpl_printf.c +0 -1991
  55. data/ext/mesh/mesh/src/runtime.cc +0 -393
  56. data/ext/mesh/mesh/src/runtime.h +0 -114
  57. data/ext/mesh/mesh/src/shuffle_vector.h +0 -287
  58. data/ext/mesh/mesh/src/size_classes.def +0 -251
  59. data/ext/mesh/mesh/src/static/if.h +0 -36
  60. data/ext/mesh/mesh/src/static/log.h +0 -43
  61. data/ext/mesh/mesh/src/testing/benchmark/local_refill.cc +0 -103
  62. data/ext/mesh/mesh/src/testing/big-alloc.c +0 -28
  63. data/ext/mesh/mesh/src/testing/fragmenter.cc +0 -128
  64. data/ext/mesh/mesh/src/testing/global-large-stress.cc +0 -25
  65. data/ext/mesh/mesh/src/testing/local-alloc.c +0 -16
  66. data/ext/mesh/mesh/src/testing/meshing_benchmark.cc +0 -189
  67. data/ext/mesh/mesh/src/testing/thread.cc +0 -35
  68. data/ext/mesh/mesh/src/testing/unit/alignment.cc +0 -56
  69. data/ext/mesh/mesh/src/testing/unit/bitmap_test.cc +0 -274
  70. data/ext/mesh/mesh/src/testing/unit/concurrent_mesh_test.cc +0 -185
  71. data/ext/mesh/mesh/src/testing/unit/mesh_test.cc +0 -143
  72. data/ext/mesh/mesh/src/testing/unit/rng_test.cc +0 -22
  73. data/ext/mesh/mesh/src/testing/unit/size_class_test.cc +0 -66
  74. data/ext/mesh/mesh/src/testing/unit/triple_mesh_test.cc +0 -285
  75. data/ext/mesh/mesh/src/testing/userfaultfd-kernel-copy.cc +0 -164
  76. data/ext/mesh/mesh/src/thread_local_heap.cc +0 -163
  77. data/ext/mesh/mesh/src/thread_local_heap.h +0 -268
  78. data/ext/mesh/mesh/src/wrapper.cc +0 -433
  79. data/ext/mesh/mesh/support/export_mesh.cmake +0 -28
  80. data/ext/mesh/mesh/support/gen-size-classes +0 -57
  81. data/ext/mesh/mesh/support/install_all_configs +0 -33
  82. data/ext/mesh/mesh/support/remove_export_mesh.cmake +0 -48
  83. data/ext/mesh/mesh/support/update-bazelisk +0 -8
  84. data/ext/mesh/mesh/theory/32m80.png +0 -0
  85. data/ext/mesh/mesh/theory/64m80ind.png +0 -0
  86. data/ext/mesh/mesh/theory/bound_comparison.py +0 -67
  87. data/ext/mesh/mesh/theory/bounds/impdeg+1 +0 -135
  88. data/ext/mesh/mesh/theory/choose.py +0 -43
  89. data/ext/mesh/mesh/theory/common.py +0 -42
  90. data/ext/mesh/mesh/theory/compute_exp_Y.py +0 -134
  91. data/ext/mesh/mesh/theory/createRandomString.py +0 -69
  92. data/ext/mesh/mesh/theory/deg_bound_check.py +0 -100
  93. data/ext/mesh/mesh/theory/degcheck.py +0 -47
  94. data/ext/mesh/mesh/theory/dumps/32,1,80,dumb.txt +0 -81
  95. data/ext/mesh/mesh/theory/dumps/32,2,80,dumb.txt +0 -81
  96. data/ext/mesh/mesh/theory/dumps/32,3,80,dumb.txt +0 -81
  97. data/ext/mesh/mesh/theory/dumps/32,4,80,dumb.txt +0 -81
  98. data/ext/mesh/mesh/theory/dumps/32,5,80,dumb.txt +0 -81
  99. data/ext/mesh/mesh/theory/dumps/32,6,80,dumb.txt +0 -81
  100. data/ext/mesh/mesh/theory/dumps/32,7,80,dumb.txt +0 -81
  101. data/ext/mesh/mesh/theory/dumps/32,8,80,dumb.txt +0 -81
  102. data/ext/mesh/mesh/theory/dumps/32,9,80,dumb.txt +0 -81
  103. data/ext/mesh/mesh/theory/experiment.py +0 -303
  104. data/ext/mesh/mesh/theory/experiment_raw_results/.gitignore +0 -0
  105. data/ext/mesh/mesh/theory/greedy_experiment.py +0 -66
  106. data/ext/mesh/mesh/theory/greedy_experiment_copy.py +0 -46
  107. data/ext/mesh/mesh/theory/greedy_experiment_q.py +0 -75
  108. data/ext/mesh/mesh/theory/makeGraph.py +0 -64
  109. data/ext/mesh/mesh/theory/manyreps.png +0 -0
  110. data/ext/mesh/mesh/theory/manystrings.png +0 -0
  111. data/ext/mesh/mesh/theory/match_vs_color_experiment.py +0 -94
  112. data/ext/mesh/mesh/theory/maxmatch_vs_E[Y].py +0 -162
  113. data/ext/mesh/mesh/theory/maxmatch_vs_greedymatch.py +0 -96
  114. data/ext/mesh/mesh/theory/maxvdeg+1imp++32,80.png +0 -0
  115. data/ext/mesh/mesh/theory/mesh_util.py +0 -322
  116. data/ext/mesh/mesh/theory/meshers.py +0 -452
  117. data/ext/mesh/mesh/theory/meshingBenchmark.py +0 -96
  118. data/ext/mesh/mesh/theory/occupancyComparison.py +0 -133
  119. data/ext/mesh/mesh/theory/randmatch_vs_greedymatch.py +0 -97
  120. data/ext/mesh/mesh/theory/randmatch_vs_greedymatch_q.py +0 -103
  121. data/ext/mesh/mesh/theory/randmatch_vs_greedymatch_time.py +0 -117
  122. data/ext/mesh/mesh/theory/read_mesh_dump.py +0 -82
  123. data/ext/mesh/mesh/theory/test.py +0 -70
  124. data/ext/mesh/mesh/tools/bazel +0 -1
@@ -1,96 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created on Fri Feb 03 09:45:30 2017
4
-
5
- @author: devd
6
- """
7
-
8
- from __future__ import division
9
- from createRandomString import *
10
- from makeGraph import *
11
- from meshers import *
12
- import networkx as nx
13
- import numpy as np
14
- import os
15
-
16
-
17
- def dumpStrings(strings, length, occupancy, numStrings, meshingMethod, result):
18
- """Dumps the generated string set in a text file in a subdirectory."""
19
- if length == 0:
20
- file_name = 'provided,{}.txt'.format(meshingMethod)
21
- else:
22
- file_name = '{},{},{},{}.txt'.format(length, occupancy, numStrings, meshingMethod)
23
-
24
- script_dir = os.path.dirname(os.path.abspath(__file__))
25
- dest_dir = os.path.join(script_dir, 'dumps')
26
- try:
27
- os.makedirs(dest_dir)
28
- except OSError:
29
- pass # already exists
30
- path = os.path.join(dest_dir, file_name)
31
- output = open(path, 'wb')
32
- for s in strings:
33
- output.write('{}\n'.format(s))
34
- output.write('-{}'.format(result))
35
- output.close
36
-
37
-
38
- def experiment(length = 0, occupancy = 0, numStrings = 0, meshingMethod = "dumb", attempts = 0, stringList = None):
39
- """Produces a set of random binary strings with specified length and expected
40
- occupancy. Then meshes them using the specified meshing method and returns
41
- the percentage of total pages freed. Also dumps the generated string set
42
- to a text file for comparison with other implementations.
43
-
44
- Meshing methods:
45
- dumb = attempt to mesh string 1 w/ string 2 etc. 1 pass only.
46
- random = attempt to mesh 2 randomly chosen strings. specify total number of
47
- allowed attempts.
48
- maxMatching = converts string set to graph and computes the max matching of
49
- graph. This gives the optimal meshing assuming we only mesh pairs.
50
- optimal = converts string set to the graph and computes the minimum clique
51
- cover. This gives the optimal meshing without the "pairs only" constraint.
52
- """
53
-
54
- #note that occupancy is currently the number of ones expected per string, rather than a percentage.
55
- if stringList == None:
56
- if length == 0 or numStrings == 0:
57
- raise Exception('must give a string list or specify length, occupancy, numStrings for generation')
58
- strings = createIndependentRandomStrings(length, numStrings, numOnes = occupancy)
59
- else:
60
- strings = stringList
61
-
62
- if meshingMethod == "dumb":
63
- result = simpleMesher(strings)
64
-
65
- elif meshingMethod == "random":
66
- if attempts == 0:
67
- raise Exception('must specify number of attempts for random method')
68
- meshed = randomMesher(strings, attempts)
69
- result = int(len(meshed)/2)
70
-
71
- elif meshingMethod == "maxMatching":
72
- result = maxMatchingMesher(strings)
73
-
74
- elif meshingMethod == "optimal":
75
- result = optimalMesher(strings)
76
-
77
- else:
78
- print 'hi'
79
-
80
- dumpStrings(strings, length, occupancy, numStrings, meshingMethod, result)
81
-
82
-
83
-
84
- if __name__ == '__main__':
85
- # experiment(length = 10, occupancy = 3, numStrings = 10, meshingMethod = "random", attempts = 100)
86
- # experiment(stringList = ['0000000000','1111111111','0101010101','1010101010'])
87
-
88
- lengths = [32]
89
- occupancies = range(1,10)
90
- numsStrings = [80]
91
- for i in lengths:
92
- for j in occupancies:
93
- for k in numsStrings:
94
- experiment(length = i, occupancy = j, numStrings = k)
95
-
96
-
@@ -1,133 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created on Tue Jan 31 19:49:02 2017
4
-
5
- @author: devd
6
- """
7
-
8
- from __future__ import division
9
- from createRandomString import *
10
- from makeGraph import *
11
- #from greedyMesher import *
12
- import matplotlib.pyplot as plt
13
- import matplotlib.patches as mpatches
14
- import networkx as nx
15
- import numpy as np
16
- from compute_exp_Y import compute_exp_Y, compute_degree_bound, compute_isolated_edge_bound
17
- from choose import compute_q
18
-
19
- def experiment(length, ones_range_min, ones_range_max, reps, numStrings):
20
- constant_strings = []
21
- independent_strings = []
22
- ones = []
23
- constant_occupancy_avg = []
24
- constant_occupancy_std_dev = []
25
- indep_occupancy_avg = []
26
- indep_occupancy_std_dev = []
27
- qs = []
28
- constant_edges = []
29
- independent_edges = []
30
-
31
- for numOnes in range(ones_range_min, ones_range_max+1):
32
- ones.append(numOnes)
33
- q = compute_q(length, numOnes)
34
- qs.append(q)
35
- freed_pages_constant = []
36
- freed_pages_independent = []
37
- const_edges = []
38
- indep_edges = []
39
- for iterations in range (reps):
40
- for i in range(numStrings):
41
- constant_strings.append(createRandomString(length, numOnes))
42
-
43
- graph = makeGraph(constant_strings)
44
- const_edges.append(graph.number_of_edges())
45
- frdpgs_constant = len(nx.max_weight_matching(graph))/2
46
- perc = (frdpgs_constant/numStrings)*100
47
- freed_pages_constant.append(perc)
48
-
49
- #include only q or numOnes by name to choose which version of indep random strings you want
50
- # independent_strings = createIndependentRandomStrings(length, numStrings, q, numOnes)
51
- independent_strings = createIndependentRandomStrings(length, numStrings, numOnes = numOnes)
52
- graph = makeGraph(independent_strings)
53
- indep_edges.append(graph.number_of_edges())
54
- frdpgs_indep = len(nx.max_weight_matching(graph))/2
55
- perc = (frdpgs_indep/numStrings)*100
56
- freed_pages_independent.append(perc)
57
-
58
-
59
- constant_strings = []
60
- independent_strings = []
61
-
62
-
63
- m = np.asarray(freed_pages_constant)
64
- # raw.append(freed_pages_constant)
65
- m_a = np.mean(m)
66
- constant_occupancy_avg.append(m_a)
67
- m_s = np.std(m)
68
- constant_occupancy_std_dev.append(m_s)
69
-
70
- m = np.asarray(const_edges)
71
- constant_edges.append(np.mean(m))
72
-
73
- m = np.asarray(freed_pages_independent)
74
- # raw.append(freed_pages_constant)
75
- m_a = np.mean(m)
76
- indep_occupancy_avg.append(m_a)
77
- m_s = np.std(m)
78
- indep_occupancy_std_dev.append(m_s)
79
-
80
- m = np.asarray(indep_edges)
81
- independent_edges.append(np.mean(m))
82
-
83
- return ones, constant_occupancy_avg, constant_occupancy_std_dev, indep_occupancy_avg, indep_occupancy_std_dev, constant_edges, independent_edges, qs
84
-
85
-
86
- def plot_it(length, ones_range_min, ones_range_max, reps, numStrings):
87
- ones, constant_occupancy_avg, constant_occupancy_std_dev, indep_occupancy_avg, indep_occupancy_std_dev, constant_edges, independent_edges, qs = experiment(length, ones_range_min, ones_range_max, reps, numStrings)
88
-
89
- plt.errorbar(np.asarray(ones), np.asarray(constant_occupancy_avg), np.asarray(constant_occupancy_std_dev), markersize=3, lw=1, fmt='-o')
90
- plt.errorbar(np.asarray(ones), np.asarray(indep_occupancy_avg), np.asarray(indep_occupancy_std_dev), markersize=3, lw=1, fmt='-o')
91
- plt.ylim([0,60])
92
- # plt.xlim([10, 16])
93
- plt.ylabel('Percentage of pages freed')
94
- plt.xlabel('Number of objects per page')
95
- blue_patch = mpatches.Patch(color='blue', label='const occupancy')
96
- green_patch = mpatches.Patch(color = 'green', label = 'indep occupancy')
97
- # red_patch = mpatches.Patch(color = 'red', label = 'q')
98
- plt.legend(handles=[blue_patch, green_patch])
99
- # plt.legend(handles=[blue_patch, green_patch, red_patch])
100
- plt.title('CONSTANT VS INDEPENDENT OCCUPANCY \n{}-object pages, {} pages. p = n/b'.format(length, numStrings))
101
- plt.show()
102
- # plt.savefig('constvindep_{},{}'.format(length, numStrings) + '.png', dpi = 1000)
103
- plt.close()
104
-
105
- # plt.errorbar(np.asarray(ones), np.asarray(constant_edges), np.asarray(np.zeros(len(ones))), markersize=3, lw=1, fmt='-o')
106
- # plt.errorbar(np.asarray(ones), np.asarray(independent_edges), np.asarray(np.zeros(len(ones))), markersize=3, lw=1, fmt='-o')
107
- # plt.show()
108
-
109
-
110
- if __name__ == '__main__':
111
- #length = [32,64]
112
- length = [64]
113
- ones_range_min = 1
114
- ones_range_max = 32
115
- reps = 10
116
- #numStrings = [80,100,150,200]
117
- numStrings= [80]
118
-
119
-
120
- for l in length:
121
- for n in numStrings:
122
- plot_it(l, ones_range_min, int(l/2), reps, n)
123
- # plot_it(l, 10, 13, 10, n)
124
- print 'const v indep plot {},{} done'.format(l,n)
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
@@ -1,97 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created on Fri Apr 15 17:21:40 2016
4
-
5
- @author: devd
6
- """
7
-
8
- from __future__ import division
9
- from createRandomString import *
10
- from meshers import *
11
- import matplotlib.pyplot as plt
12
- import matplotlib.patches as mpatches
13
- import networkx as nx
14
- import numpy as np
15
- import time
16
- from math import log, floor, sqrt
17
-
18
- def experiment(length, ones_range_min, ones_range_max, reps, numStrings, attempts):
19
- strings = []
20
- ones = []
21
- randmatch_avg = []
22
- randmatch_std_dev = []
23
- greedymatch_avg = []
24
- greedymatch_std_dev = []
25
-
26
- for numOnes in range(ones_range_min, ones_range_max+1):
27
- ones.append(numOnes)
28
- freed_pages_randmatching = []
29
- freed_pages_greedymatching = []
30
- for iterations in range (reps):
31
- for i in range(numStrings):
32
- strings.append(createRandomString(length, numOnes))
33
-
34
- s = [x for x in strings]
35
- frdpgs_randmatching = len(randomMesher(s,attempts))/2
36
- perc = (frdpgs_randmatching/numStrings)*100
37
- freed_pages_randmatching.append(perc)
38
-
39
- b, unmatched = greedyMesher(strings)
40
- frdpgs_greedymatching = (numStrings - len(unmatched))/2
41
- perc = (frdpgs_greedymatching/numStrings)*100
42
- freed_pages_greedymatching.append(perc)
43
-
44
- strings = []
45
- m = np.asarray(freed_pages_randmatching)
46
- m_a = np.mean(m)
47
- randmatch_avg.append(m_a)
48
- m_s = np.std(m)
49
- randmatch_std_dev.append(m_s)
50
-
51
- c = np.asarray(freed_pages_greedymatching)
52
- c_a = np.mean(c)
53
- greedymatch_avg.append(c_a)
54
- c_s = np.std(c)
55
- greedymatch_std_dev.append(c_s)
56
-
57
- return ones, randmatch_avg, randmatch_std_dev, greedymatch_avg, greedymatch_std_dev
58
-
59
-
60
- def plot_it(length, ones_range_min, ones_range_max, reps, numStrings, attempts):
61
- ones, match_avg, match_std_dev, color_avg, color_std_dev = experiment(length, ones_range_min, ones_range_max, reps, numStrings, attempts)
62
-
63
- plt.errorbar(np.asarray(ones), np.asarray(match_avg), np.asarray(match_std_dev), markersize=3, lw=1, fmt='-o')
64
- plt.errorbar(np.asarray(ones), np.asarray(color_avg), np.asarray(color_std_dev), markersize=3, lw=1, fmt='-o')
65
- plt.ylim([0,60])
66
- plt.ylabel('Percentage of pages freed')
67
- plt.xlabel('Number of objects per page')
68
- blue_patch = mpatches.Patch(color='blue', label='random matching')
69
- green_patch = mpatches.Patch(color = 'green', label = 'greedy matching')
70
- plt.legend(handles=[blue_patch, green_patch])
71
- plt.title('RANDOM MATCHING VS GREEDY MATCHING MESHING RESULTS \n{}-object pages, {} pages, n^2 attempts'.format(length, numStrings))
72
- plt.show()
73
- # plt.savefig('randvgreedy{},{},n^2_attempts'.format(length, numStrings) + '.png', dpi = 1000)
74
- plt.close()
75
-
76
- #length = [32,64]
77
- length = [32]
78
- ones_range_min = 1
79
- ones_range_max = 32
80
- reps = 10
81
- #numStrings = [80,100,150,200]
82
- numStrings = [80]
83
-
84
-
85
- start = time.time()
86
- for l in length:
87
- for n in numStrings:
88
- #attempts = n
89
- #attempts = int(floor(n*log(n,2)))
90
- #attempts = int(floor(n*sqrt(n)))
91
- #attempts = int(floor(n**1.75))
92
- attempts = int(floor(n**2))
93
- print 'num attempts: {}'.format(attempts)
94
- plot_it(l, ones_range_min, int(l/2), reps, n, attempts)
95
- print 'rand match vs greedy match plot {},{} done'.format(l,n)
96
- end = time.time()
97
- print('making this took {} seconds'.format(end-start) )
@@ -1,103 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created on Fri Apr 15 17:21:40 2016
4
-
5
- @author: devd
6
- """
7
-
8
- from __future__ import division
9
- from createRandomString import *
10
- from meshers import *
11
- import matplotlib.pyplot as plt
12
- import matplotlib.patches as mpatches
13
- import networkx as nx
14
- import numpy as np
15
- import time
16
- from math import log, floor, sqrt, factorial
17
- from choose import compute_q
18
-
19
-
20
- def experiment(length, ones_range_min, ones_range_max, reps, numStrings, attempts):
21
- strings = []
22
- ones = []
23
- randmatch_avg = []
24
- randmatch_std_dev = []
25
- greedymatch_avg = []
26
- greedymatch_std_dev = []
27
-
28
- for numOnes in range(ones_range_min, ones_range_max+1):
29
- ones.append(numOnes)
30
- freed_pages_randmatching = []
31
- freed_pages_greedymatching = []
32
- for iterations in range (reps):
33
- for i in range(numStrings):
34
- strings.append(createRandomString(length, numOnes))
35
-
36
- s = [x for x in strings]
37
- frdpgs_randmatching = len(randomMesher(s,attempts))/2
38
- perc = (frdpgs_randmatching/numStrings)*100
39
- freed_pages_randmatching.append(perc)
40
-
41
- b, unmatched = greedyMesher(strings)
42
- frdpgs_greedymatching = (numStrings - len(unmatched))/2
43
- perc = (frdpgs_greedymatching/numStrings)*100
44
- freed_pages_greedymatching.append(perc)
45
-
46
- strings = []
47
- m = np.asarray(freed_pages_randmatching)
48
- m_a = np.mean(m)
49
- randmatch_avg.append(m_a)
50
- m_s = np.std(m)
51
- randmatch_std_dev.append(m_s)
52
-
53
- c = np.asarray(freed_pages_greedymatching)
54
- c_a = np.mean(c)
55
- greedymatch_avg.append(c_a)
56
- c_s = np.std(c)
57
- greedymatch_std_dev.append(c_s)
58
-
59
- return ones, randmatch_avg, randmatch_std_dev, greedymatch_avg, greedymatch_std_dev
60
-
61
-
62
- def plot_it(length, ones_range_min, ones_range_max, reps, numStrings, attempts):
63
- ones, match_avg, match_std_dev, color_avg, color_std_dev = experiment(length, ones_range_min, ones_range_max, reps, numStrings, attempts)
64
-
65
- q = [compute_q(length, x) for x in ones]
66
-
67
-
68
- plt.errorbar(np.asarray(q), np.asarray(match_avg), np.asarray(match_std_dev), markersize=3, lw=1, fmt='-o')
69
- plt.errorbar(np.asarray(q), np.asarray(color_avg), np.asarray(color_std_dev), markersize=3, lw=1, fmt='-o')
70
- plt.ylim([0,60])
71
- # plt.xlim([0,.2])
72
- plt.ylabel('Percentage of pages freed')
73
- plt.xlabel('q (probability of 2 pages meshing)')
74
- blue_patch = mpatches.Patch(color='blue', label='random matching')
75
- green_patch = mpatches.Patch(color = 'green', label = 'greedy matching')
76
- plt.legend(handles=[blue_patch, green_patch],bbox_to_anchor=(1, .3))
77
- plt.title('RANDOM MATCHING VS GREEDY MATCHING MESHING RESULTS \n{}-object pages, {} pages, n*log(n) attempts'.format(length, numStrings))
78
- plt.show()
79
- # plt.savefig('randvgreedy{},{},n^1.5_attempts'.format(length, numStrings) + '.png', dpi = 1000)
80
- plt.close()
81
-
82
- #length = [32,64]
83
- length = [32]
84
- ones_range_min = 1
85
- ones_range_max = 32
86
- reps = 10
87
- #numStrings = [80,100,150,200]
88
- numStrings = [80]
89
-
90
-
91
- start = time.time()
92
- for l in length:
93
- for n in numStrings:
94
- #attempts = n
95
- # attempts = int(floor(n*log(n,2)))
96
- attempts = int(floor(n*sqrt(n)))
97
- #attempts = int(floor(n**1.75))
98
- #attempts = int(floor(n**2))
99
- print 'num attempts: {}'.format(attempts)
100
- plot_it(l, ones_range_min, int(l/2), reps, n, attempts)
101
- print 'rand match vs greedy match plot {},{} done'.format(l,n)
102
- end = time.time()
103
- print('making this took {} seconds'.format(end-start) )
@@ -1,117 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created on Fri Apr 15 17:21:40 2016
4
-
5
- @author: devd
6
- """
7
-
8
- from __future__ import division
9
- from createRandomString import *
10
- from meshers import *
11
- import matplotlib.pyplot as plt
12
- import matplotlib.patches as mpatches
13
- import networkx as nx
14
- import numpy as np
15
- import time
16
- from math import log, floor, sqrt
17
-
18
- def experiment(length, ones_range_min, ones_range_max, reps, numStrings, attempts):
19
- strings = []
20
- ones = []
21
- randmatch_avg = []
22
- randmatch_std_dev = []
23
- greedymatch_avg = []
24
- greedymatch_std_dev = []
25
- rtimeavg = []
26
- rtimestd = []
27
- gtimeavg = []
28
- gtimestd = []
29
-
30
- for numOnes in range(ones_range_min, ones_range_max+1):
31
- ones.append(numOnes)
32
- freed_pages_randmatching = []
33
- freed_pages_greedymatching = []
34
- time_rand = []
35
- time_greedy = []
36
- for iterations in range (reps):
37
- for i in range(numStrings):
38
- strings.append(createRandomString(length, numOnes))
39
-
40
-
41
-
42
-
43
- rstart = time.time()
44
-
45
- s = [x for x in strings]
46
- # frdpgs_randmatching = len(randomMesher(s,attempts))/2
47
- frdpgs_randmatching = randomMesher(s,attempts)
48
- perc = (frdpgs_randmatching/numStrings)*100
49
- freed_pages_randmatching.append(perc)
50
-
51
- rend = time.time()
52
- time_rand.append(rend-rstart)
53
-
54
- gstart = time.time()
55
-
56
- b, unmatched = greedyMesher(strings)
57
- frdpgs_greedymatching = (numStrings - len(unmatched))/2
58
- perc = (frdpgs_greedymatching/numStrings)*100
59
- freed_pages_greedymatching.append(perc)
60
-
61
- gend = time.time()
62
- time_greedy.append(gend-gstart)
63
-
64
- strings = []
65
- m = np.asarray(time_rand)
66
- m_a = np.mean(m)
67
- randmatch_avg.append(m_a)
68
- m_s = np.std(m)
69
- randmatch_std_dev.append(m_s)
70
-
71
- c = np.asarray(time_greedy)
72
- c_a = np.mean(c)
73
- greedymatch_avg.append(c_a)
74
- c_s = np.std(c)
75
- greedymatch_std_dev.append(c_s)
76
-
77
- return ones, randmatch_avg, randmatch_std_dev, greedymatch_avg, greedymatch_std_dev
78
-
79
-
80
- def plot_it(length, ones_range_min, ones_range_max, reps, numStrings, attempts):
81
- ones, match_avg, match_std_dev, color_avg, color_std_dev = experiment(length, ones_range_min, ones_range_max, reps, numStrings, attempts)
82
-
83
- plt.errorbar(np.asarray(ones), np.asarray(match_avg), np.asarray(match_std_dev), markersize=3, lw=1, fmt='-o')
84
- plt.errorbar(np.asarray(ones), np.asarray(color_avg), np.asarray(color_std_dev), markersize=3, lw=1, fmt='-o')
85
- # plt.ylim([0,60])
86
- plt.ylabel('Time required to compute answer')
87
- plt.xlabel('Number of objects per page')
88
- blue_patch = mpatches.Patch(color='blue', label='random matching')
89
- green_patch = mpatches.Patch(color = 'green', label = 'greedy matching')
90
- plt.legend(handles=[blue_patch, green_patch])
91
- plt.title('RANDOM MATCHING VS GREEDY MATCHING MESHING TIME REQUIREMENTS \n{}-object pages, {} pages, n^2 attempts'.format(length, numStrings))
92
- plt.show()
93
- # plt.savefig('randvgreedytime{},{},n^2_attempts'.format(length, numStrings) + '.png', dpi = 1000)
94
- plt.close()
95
-
96
- #length = [32,64]
97
- length = [32]
98
- ones_range_min = 1
99
- ones_range_max = 32
100
- reps = 10
101
- #numStrings = [80,100,150,200]
102
- numStrings = [80]
103
-
104
-
105
- start = time.time()
106
- for l in length:
107
- for n in numStrings:
108
- #attempts = n
109
- #attempts = int(floor(n*log(n,2)))
110
- # attempts = int(floor(n*sqrt(n)))
111
- #attempts = int(floor(n**1.75))
112
- attempts = int(floor(n**2))
113
- print 'num attempts: {}'.format(attempts)
114
- plot_it(l, ones_range_min, int(l/2), reps, n, attempts)
115
- print 'rand match vs greedy match plot {},{} done'.format(l,n)
116
- end = time.time()
117
- print('making this took {} seconds'.format(end-start) )