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,81 +0,0 @@
1
- 00000000000001000010000000001010
2
- 10100100000010010011000000001010
3
- 10000000011101100011001000000011
4
- 00101000000001000000000100000000
5
- 01001000000100001110110000110100
6
- 00000001101001010000000001010000
7
- 00111111100001000000100110001000
8
- 01000101000101000000000000000010
9
- 00000000100100100010000010000000
10
- 00101100000001000101000000010000
11
- 10100000000001000000000101000011
12
- 01000101110100001000100001000100
13
- 01010000101011100000001000001000
14
- 00001000000000100000100100000111
15
- 00001000100100001100000101101000
16
- 00000000000110000100000011100111
17
- 00000000000001010110011100000100
18
- 10001000001100110011010011101000
19
- 00001001000001110000001000100000
20
- 01000001000100000000000001010000
21
- 00000000100000001010000101000000
22
- 00000000110101010101000000011010
23
- 00100000011000000000000000100100
24
- 00010001110001001000010100000001
25
- 01011000111011010001011100011110
26
- 00000000000010110011000000001010
27
- 10001100000000001000000010000110
28
- 00000000011000001000011011000001
29
- 00100000110000000000001110101101
30
- 00110000010101100011000010100000
31
- 11110010010010000100100000000000
32
- 00000010001001010010010111000000
33
- 01000010010001110000010001000010
34
- 11101010001100100101010001100100
35
- 10000011001010000110100010010100
36
- 00011100000000001110100000100010
37
- 11100000001001100001000000000000
38
- 01010100001010010000000000001010
39
- 00011010110000010100100001100010
40
- 10011010001000000011100010000011
41
- 00010000111001000000000000100100
42
- 10101010100000011101011001000100
43
- 10001111000010000000011100000101
44
- 11000100001000100010000000100010
45
- 10000010100010000100000001010000
46
- 11011011000100100111110000001000
47
- 00000001000000100100010000001000
48
- 00001000000000000001000100001000
49
- 11001001101000100000000001000000
50
- 10000100001100101010000000001111
51
- 11100010110000101010110101000000
52
- 00101000000000000001010000100100
53
- 01100010001100000001001010000010
54
- 01001000100001100101000000000000
55
- 00100000010001101010011000010100
56
- 10101000010000100000001100100001
57
- 00110000011010100000100010001001
58
- 01011001101000100100010100101000
59
- 00010010000001100000100101000111
60
- 00000010001000101000001010001010
61
- 00010010001000000000000111100100
62
- 00000110100010000000001000110000
63
- 00001001000000010000000001001000
64
- 00001000000001100111101101000000
65
- 10000110010000000011000001100000
66
- 10000000111000100000010001010100
67
- 01000010000000110010000000000000
68
- 10001010000001100100011011001000
69
- 00000001000000000001100010101000
70
- 00001000000011001100011110000000
71
- 00000000001100000000101000001010
72
- 00001010000100000101010100100000
73
- 00011000100001100000011000010000
74
- 00010000011011000100000100000000
75
- 00001000110000110001000100001001
76
- 10001000000000100000000011000000
77
- 01100100000000000100000000101100
78
- 00001000001000100010000000000111
79
- 00000110100100001000001010100110
80
- 00100010001100110000001000100111
81
- -1
@@ -1,303 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created on Wed May 31 14:55:29 2017
4
-
5
- @author: devd
6
- """
7
-
8
- import meshers
9
- import createRandomString
10
- import compute_exp_Y
11
- import functools
12
- import numpy as np
13
- import matplotlib.pyplot as plt
14
- import matplotlib.patches as mpatches
15
- import time as t
16
- import datetime
17
- import pickle
18
-
19
- def stringSetManager(stringSet, length, numStrings, numOnes, q, filename):
20
- """Converts a identifying string into a string set generating function with the proper parameters."""
21
- if stringSet == "random":
22
- if numOnes != -1:
23
- gen = lambda: createRandomString.createIndependentRandomStrings(length, numStrings, numOnes = numOnes)
24
- elif q != -1:
25
- gen = lambda: createRandomString.createIndependentRandomStrings(length, numStrings, q = q)
26
- else:
27
- raise Exception("must specify numOnes or q")
28
- elif stringSet == "const":
29
- if numOnes != -1:
30
- gen = lambda: createRandomString.createConstRandomStrings(length, numStrings, numOnes = numOnes)
31
- else:
32
- raise Exception("must specify numOnes")
33
- elif stringSet == "provided":
34
- raise Exception("not yet implemented")
35
- else:
36
- raise Exception("stringSet value {} not defined".format(stringSet))
37
- return gen
38
-
39
- def mesherManager(meshingList):
40
- """Converts indentifying strings into meshing function objects with corresponding
41
- partial argument values."""
42
- mesherList = []
43
- for bundle in meshingList:
44
- identifier = bundle[0]
45
- kwargs = bundle[1]
46
- func = meshers.mesherRetrieve(identifier)
47
- prepped_mesher = functools.partial(func, **kwargs)
48
- mesherList.append(prepped_mesher)
49
- return mesherList
50
-
51
- def boundGenerator(boundList):
52
- """Looks up the appropriate bound function from a given identifying string
53
- and returns it."""
54
- bounds = []
55
- for b in boundList:
56
- bounds.append(compute_exp_Y.boundRetrieve(b))
57
- return bounds
58
-
59
- def computeBounds(bounds, length, numStrings, numOnes):
60
- """Using the appropriate bound, computes the value of that bound for given
61
- parameter values."""
62
- results = []
63
- for b in bounds:
64
- raw_bound = b(length, numOnes, numStrings)
65
- scaled = (raw_bound/numStrings)*100
66
- results.append(scaled)
67
- return results
68
-
69
- def filenamer(meshingList, length, numStrings, attempts, boundList = None, time = False):
70
- """Generates an appropriate filename for a plot based on experiment parameters."""
71
- plotname = ''
72
- ids = []
73
-
74
- for bundle in meshingList:
75
- identifier = bundle[0]
76
- ids.append(identifier)
77
- plotname = plotname + '{}, '
78
- for b in boundList:
79
- ids.append(b)
80
- plotname = plotname + '{}, '
81
- plotname = plotname.format(*ids)
82
- plotname = plotname +'comp {}len {}str {}att'
83
- if time:
84
- plotname = plotname + ' time'
85
- plotname += '.png'
86
- plotname = plotname.format(length, numStrings, attempts)
87
-
88
- return plotname
89
-
90
- def dumpToFile(means, std_devs, tmeans, tstd_devs, bound_results, id_string):
91
- """Automatically dumps the results of the run to a file for logging and error recovery."""
92
- #name dump file with the human-readable time and date of program execution
93
- timestamp = t.time()
94
- value = datetime.datetime.fromtimestamp(timestamp)
95
- run_id = (value.strftime('%Y-%m-%d %H;%M;%S'))
96
- path = "experiment_raw_results/{}".format(run_id)
97
-
98
- with open(path, "wb+") as file:
99
- data = id_string, means, std_devs, tmeans, tstd_devs, bound_results
100
- pickle.dump(data, file)
101
- file.close()
102
-
103
- def trial(stringSetGenerator, meshers, time = False):
104
- """Generates a string set with given function + parameters, then meshes
105
- using one or more meshing methods and outputs the size of the mesh for
106
- each. Can also optionally output the computation time required for each
107
- meshing method.
108
- Note that the string set generator and meshers are passed to trial as
109
- callable function objects (which may have keyword arguments partially
110
- specified already)."""
111
- strings = stringSetGenerator()
112
- mesh_results = []
113
- time_results = []
114
- for mesher in meshers:
115
- start = t.time()
116
- mesh_results.append(mesher(strings))
117
- duration = t.time() - start
118
- #report times in milliseconds
119
- time_results.append(duration*1000)
120
- return tuple(mesh_results), tuple(time_results)
121
-
122
- def repeatedTrials(stringSet = "random", length = 16, numStrings = 100, numOnes = -1, q = -1, filename = None, meshers = None, reps = 10, time = False):
123
- """This function performs a series of trials comparing meshing algorithms on different iid string sets.
124
- It returns numpy arrays of the means and std deviations of meshing sizes for each meshing method.
125
- It also optionally returns numpy arrays of the mean and std dev times to compute those meshings.
126
- mesherList takes a list of tuples where the first element is the identifier for mesher, and the second is a list of supplementary kwargs for that
127
- mesher function call (some meshers require a number of attempts, etc). """
128
- gen = stringSetManager(stringSet, length, numStrings, numOnes, q, filename)
129
- results = np.empty((reps, len(meshers)))
130
- if time:
131
- times = np.empty((reps, len(meshers)))
132
- for i in range(reps):
133
- result, time_result = trial(gen, meshers, time = time)
134
- results[i] = np.asarray(result)
135
- if time:
136
- times[i] = np.asarray(time_result)
137
-
138
- means = np.mean(results, axis = 0)
139
- std_devs = np.std(results, axis = 0)
140
- if time:
141
- tmeans = np.mean(times, axis = 0)
142
- tstd_devs = np.std(times, axis = 0)
143
- else:
144
- tmeans, tstd_devs = None, None
145
- return means, std_devs, tmeans, tstd_devs
146
-
147
- #remember to include handling for q later
148
- def experiment(stringSet = "random", length = 16, numStrings = 100, x = range(1,8), filename = None, meshingList = None, boundList = None, reps = 10, time = False):
149
- """Performs random meshing experiments on a given list of meshing algorithms. Can optionally compute & record runtime of these algorithms
150
- as well as the size of their computed meshings. Must specify properties of random string set (length of strings, number of strings, range of
151
- occupancy values, etc."""
152
- dim = len(x)
153
- meshers = mesherManager(meshingList)
154
- tmeans = None
155
- tstd_devs = None
156
- bound_results = None
157
- if time:
158
- tmeans = np.empty((dim, len(meshingList)))
159
- tstd_devs = np.empty((dim, len(meshingList)))
160
- if boundList:
161
- bounds = boundGenerator(boundList)
162
- bound_results = np.empty((dim, len(boundList)))
163
-
164
- means = np.empty((dim, len(meshingList)))
165
- std_devs = np.empty((dim, len(meshingList)))
166
-
167
- for i in range(dim):
168
- result = repeatedTrials(stringSet = stringSet, length = length, numStrings = numStrings, numOnes = x[i], meshers = meshers, reps = reps, time = time)
169
- means[i] = np.asarray(result[0])
170
- std_devs[i] = np.asarray(result[1])
171
- if time:
172
- tmeans[i] = np.asarray(result[2])
173
- tstd_devs[i] = np.asarray(result[3])
174
- if boundList:
175
- results = computeBounds(bounds, length, numStrings, x[i])
176
- bound_results[i] = np.asarray(results)
177
- return means, std_devs, tmeans, tstd_devs, bound_results
178
-
179
-
180
- def plotIt(means, std_devs, tmeans, tstd_devs, bound_results, stringSet = "random", length = 16, numStrings = 100, x = range(1,8), attempts = 10, filename = None, meshingList = None, boundList = [], reps = 10, title = "generated plot", save = False, custom = False, time = False):
181
- """Runs meshing experiments on specified algorithms for given parameter values. Then plots this information using matplotlib and either
182
- displays it or saves to a file. Set custom = True to disable automatic plot formatting and use your own instead.
183
- Also automatically dumps the raw data of the last run to a temporary file (in pickled form) so plotting errors don't destroy the results
184
- of long-duration experiments."""
185
-
186
- for i in range(len(meshingList)):
187
- plt.errorbar(np.asarray(x), np.asarray(means[:,i]), np.asarray(std_devs[:,i]), markersize=3, lw=1, fmt='-o')
188
- for i in range(len(boundList)):
189
- plt.errorbar(np.asarray(x), np.asarray(bound_results[:,i]), np.zeros(len(x)), markersize=3, lw=1, fmt='-o')
190
-
191
- plotname = filenamer(meshingList, length, numStrings, attempts, boundList, False)
192
- if not custom:
193
- # fix the y axis to 0,60 unless the plots seem to have very low values
194
- if means[0,len(meshingList)-1] > 40:
195
- plt.ylim([0,60])
196
-
197
- plt.ylabel('Percentage of pages freed')
198
- plt.xlabel('Number of objects per page')
199
-
200
- labels = [bundle[0] for bundle in meshingList] + [id for id in boundList]
201
- colors = ["blue", "green", "red", "cyan"]
202
- patches = []
203
- for i in range(len(meshingList)+len(boundList)):
204
- patches.append(mpatches.Patch(color = colors[i], label = labels[i]))
205
- plt.legend(handles = patches)
206
- plt.title(title)
207
-
208
- else:
209
- #add your own plot formatting code here
210
- pass
211
-
212
- if save:
213
- plt.savefig(plotname, dpi = 1000)
214
- else:
215
- plt.show()
216
- plt.close()
217
-
218
- if time:
219
- for i in range(len(meshingList)):
220
- plt.errorbar(np.asarray(x), np.asarray(tmeans[:,i]), np.asarray(tstd_devs[:,i]), markersize=3, lw=1, fmt='-o')
221
-
222
- if not custom:
223
- plt.ylabel('Average runtime (ms)')
224
- plt.xlabel('Number of objects per page')
225
-
226
- labels = [bundle[0] for bundle in meshingList]
227
- colors = ["blue", "green", "red", "cyan"]
228
- patches = []
229
- for i in range(len(meshingList)):
230
- patches.append(mpatches.Patch(color = colors[i], label = labels[i]))
231
- plt.legend(handles = patches)
232
- plt.title(title)
233
- else:
234
- #add your own plot formatting code here
235
- pass
236
- if save:
237
- time_plotname = filenamer(meshingList, length, numStrings, attempts, boundList, True)
238
- plt.savefig(time_plotname, dpi = 1000)
239
- else:
240
- plt.show()
241
- plt.close()
242
-
243
- dumpToFile(means, std_devs, tmeans, tstd_devs, bound_results, plotname)
244
-
245
-
246
- #to do: implement ability to read in and mesh string sets instead of randomly generating them
247
- if __name__ == '__main__':
248
- stringSet = "random"
249
- stdOutput = True
250
-
251
- length = 128
252
- ones_range_min = 1
253
- ones_range_max = int(length/2)
254
- increment = 4
255
- numStrings = 1000
256
- attempts = 100
257
- reps = 10
258
-
259
- # length = 16
260
- # ones_range_min = 1
261
- # ones_range_max = int(length/2)
262
- # increment = 1
263
- # numStrings = 100
264
- # attempts = 50
265
- # reps = 10
266
-
267
- # length = 256
268
- # ones_range_min = 40
269
- # ones_range_max = 59
270
- # increment = 4
271
- # numStrings = 10000
272
- # attempts = 100
273
- # reps = 4
274
-
275
- # meshingList = [("split", {'attempts' : attempts, 'stdOutput' : stdOutput}),
276
- ## ("dumb", {'attempts' : attempts, 'stdOutput' : stdOutput}),
277
- # ("greedysplit", {'stdOutput' : stdOutput, 'cutoff' : (10**(-2))}),
278
- # ("greedysplit", {'stdOutput' : stdOutput}),
279
- # ("maxmatch", {'stdOutput' : stdOutput})
280
- # ]
281
-
282
- meshingList = [("greedysplit", {'stdOutput' : stdOutput, 'cutoff' : (10**(-3))}),
283
- ("greedy", {'stdOutput' : stdOutput, 'cutoff' : (10**(-3))})#,
284
- # ("greedysplit", {'stdOutput' : stdOutput}),
285
- # ('greedy', {'stdOutput' : stdOutput})
286
- ]
287
-
288
- # meshingList = [("greedysplit", {'stdOutput' : stdOutput, 'cutoff' : 10**(-5)}),
289
- # ("greedysplit", {'stdOutput' : stdOutput})
290
- # ]
291
-
292
- boundList = []
293
- # boundList = ["impdeg+1"]
294
-
295
- save = False
296
- time = True
297
- title = "Meshing {} {}-bit {} occupancy strings. {} attempts".format(numStrings, length, stringSet, attempts)
298
-
299
- x = range(ones_range_min, ones_range_max, increment)
300
-
301
- means, std_devs, tmeans, tstd_devs, bound_results = experiment(stringSet = stringSet, length = length, numStrings = numStrings, x = x, meshingList = meshingList, boundList = boundList, reps = reps, time = time)
302
- plotIt(means, std_devs, tmeans, tstd_devs, bound_results, stringSet = stringSet, length = length, numStrings = numStrings, x = x, attempts = attempts, meshingList = meshingList, boundList = boundList, reps = reps, title = title, save = save, time = time)
303
-
@@ -1,66 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created on Sat Feb 27 21:32:33 2016
4
-
5
- @author: devd
6
- """
7
- from __future__ import division
8
- from createRandomString import *
9
- #from greedyMesher import *
10
- from meshers import *
11
- import matplotlib.pyplot as plt
12
- import numpy as np
13
-
14
-
15
-
16
-
17
- def experiment(length, ones_range_min, ones_range_max, reps, numStrings):
18
-
19
- strings = []
20
- ones = []
21
- avg = []
22
- stddev = []
23
-
24
- for numOnes in range(ones_range_min, ones_range_max+1):
25
- ones.append(numOnes)
26
- vals = []
27
- for iterations in range (reps):
28
- for i in range(numStrings):
29
- strings.append(createRandomString(length, numOnes))
30
- b, unmatched = greedyMesher(strings)
31
- pages_freed = (numStrings - len(unmatched))/2
32
- percentage = (pages_freed/numStrings)*100
33
- vals.append(percentage)
34
- strings = []
35
- v = np.asarray(vals)
36
- a = np.mean(v)
37
- avg.append(a)
38
- s = np.std(v)
39
- stddev.append(s)
40
- return ones, avg, stddev
41
-
42
- def plot_it(length, ones_range_min, ones_range_max, reps, numStrings):
43
-
44
- ones, avg, stddev = experiment(length, ones_range_min, ones_range_max, reps, numStrings)
45
-
46
- plt.errorbar(np.asarray(ones), np.asarray(avg), np.asarray(stddev), markersize=3, lw=1, fmt='-o')
47
- plt.ylim([0,60])
48
- plt.ylabel('Percentage of pages freed')
49
- plt.xlabel('Number of objects per page')
50
- plt.title('GREEDY FIRST-MATCH MESHING RESULTS \n{}-object pages, {} pages'.format(length, numStrings))
51
- plt.show()
52
- #plt.savefig('{}p{}'.format(length, numStrings) + '.png', dpi = 1000)
53
- #plt.close()
54
-
55
- #length = [32,64]
56
- length = [32]
57
- ones_range_min = 1
58
- ones_range_max = 16
59
- reps = 10
60
- #numStrings = [80,100,150,200]
61
- numStrings = [80]
62
-
63
- for l in length:
64
- for n in numStrings:
65
- plot_it(l, 1, int(l/2), reps, n)
66
- print 'greedy plot {},{} done'.format(l,n)