mesh-rb 0.0.1

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 (131) hide show
  1. checksums.yaml +7 -0
  2. data/.idea/.gitignore +8 -0
  3. data/.idea/mesh-rb.iml +16 -0
  4. data/.idea/misc.xml +4 -0
  5. data/.idea/modules.xml +8 -0
  6. data/.idea/vcs.xml +9 -0
  7. data/Gemfile +2 -0
  8. data/Gemfile.lock +17 -0
  9. data/Rakefile +16 -0
  10. data/bin/mesh +30 -0
  11. data/ext/mesh/extconf.rb +13 -0
  12. data/ext/mesh/mesh/.bazelrc +20 -0
  13. data/ext/mesh/mesh/.bazelversion +1 -0
  14. data/ext/mesh/mesh/.clang-format +15 -0
  15. data/ext/mesh/mesh/.dockerignore +5 -0
  16. data/ext/mesh/mesh/.editorconfig +16 -0
  17. data/ext/mesh/mesh/.gitattributes +4 -0
  18. data/ext/mesh/mesh/.github/workflows/main.yml +144 -0
  19. data/ext/mesh/mesh/.gitignore +51 -0
  20. data/ext/mesh/mesh/AUTHORS +5 -0
  21. data/ext/mesh/mesh/CMakeLists.txt +270 -0
  22. data/ext/mesh/mesh/CODE_OF_CONDUCT.md +77 -0
  23. data/ext/mesh/mesh/Dockerfile +30 -0
  24. data/ext/mesh/mesh/LICENSE +201 -0
  25. data/ext/mesh/mesh/Makefile +81 -0
  26. data/ext/mesh/mesh/README.md +97 -0
  27. data/ext/mesh/mesh/WORKSPACE +50 -0
  28. data/ext/mesh/mesh/bazel +350 -0
  29. data/ext/mesh/mesh/mesh-pldi19-powers.pdf +0 -0
  30. data/ext/mesh/mesh/src/BUILD +222 -0
  31. data/ext/mesh/mesh/src/CMakeLists.txt +85 -0
  32. data/ext/mesh/mesh/src/bitmap.h +590 -0
  33. data/ext/mesh/mesh/src/cheap_heap.h +170 -0
  34. data/ext/mesh/mesh/src/common.h +377 -0
  35. data/ext/mesh/mesh/src/copts.bzl +31 -0
  36. data/ext/mesh/mesh/src/d_assert.cc +75 -0
  37. data/ext/mesh/mesh/src/fixed_array.h +124 -0
  38. data/ext/mesh/mesh/src/global_heap.cc +547 -0
  39. data/ext/mesh/mesh/src/global_heap.h +569 -0
  40. data/ext/mesh/mesh/src/gnu_wrapper.cc +75 -0
  41. data/ext/mesh/mesh/src/internal.h +356 -0
  42. data/ext/mesh/mesh/src/libmesh.cc +239 -0
  43. data/ext/mesh/mesh/src/mac_wrapper.cc +528 -0
  44. data/ext/mesh/mesh/src/measure_rss.cc +44 -0
  45. data/ext/mesh/mesh/src/measure_rss.h +20 -0
  46. data/ext/mesh/mesh/src/meshable_arena.cc +776 -0
  47. data/ext/mesh/mesh/src/meshable_arena.h +309 -0
  48. data/ext/mesh/mesh/src/meshing.h +60 -0
  49. data/ext/mesh/mesh/src/mini_heap.h +532 -0
  50. data/ext/mesh/mesh/src/mmap_heap.h +104 -0
  51. data/ext/mesh/mesh/src/one_way_mmap_heap.h +77 -0
  52. data/ext/mesh/mesh/src/partitioned_heap.h +111 -0
  53. data/ext/mesh/mesh/src/plasma/mesh.h +33 -0
  54. data/ext/mesh/mesh/src/real.cc +52 -0
  55. data/ext/mesh/mesh/src/real.h +36 -0
  56. data/ext/mesh/mesh/src/rng/mwc.h +296 -0
  57. data/ext/mesh/mesh/src/rng/mwc64.h +58 -0
  58. data/ext/mesh/mesh/src/rpl_printf.c +1991 -0
  59. data/ext/mesh/mesh/src/runtime.cc +393 -0
  60. data/ext/mesh/mesh/src/runtime.h +114 -0
  61. data/ext/mesh/mesh/src/shuffle_vector.h +287 -0
  62. data/ext/mesh/mesh/src/size_classes.def +251 -0
  63. data/ext/mesh/mesh/src/static/if.h +36 -0
  64. data/ext/mesh/mesh/src/static/log.h +43 -0
  65. data/ext/mesh/mesh/src/testing/benchmark/local_refill.cc +103 -0
  66. data/ext/mesh/mesh/src/testing/big-alloc.c +28 -0
  67. data/ext/mesh/mesh/src/testing/fragmenter.cc +128 -0
  68. data/ext/mesh/mesh/src/testing/global-large-stress.cc +25 -0
  69. data/ext/mesh/mesh/src/testing/local-alloc.c +16 -0
  70. data/ext/mesh/mesh/src/testing/meshing_benchmark.cc +189 -0
  71. data/ext/mesh/mesh/src/testing/thread.cc +35 -0
  72. data/ext/mesh/mesh/src/testing/unit/alignment.cc +56 -0
  73. data/ext/mesh/mesh/src/testing/unit/bitmap_test.cc +274 -0
  74. data/ext/mesh/mesh/src/testing/unit/concurrent_mesh_test.cc +185 -0
  75. data/ext/mesh/mesh/src/testing/unit/mesh_test.cc +143 -0
  76. data/ext/mesh/mesh/src/testing/unit/rng_test.cc +22 -0
  77. data/ext/mesh/mesh/src/testing/unit/size_class_test.cc +66 -0
  78. data/ext/mesh/mesh/src/testing/unit/triple_mesh_test.cc +285 -0
  79. data/ext/mesh/mesh/src/testing/userfaultfd-kernel-copy.cc +164 -0
  80. data/ext/mesh/mesh/src/thread_local_heap.cc +163 -0
  81. data/ext/mesh/mesh/src/thread_local_heap.h +268 -0
  82. data/ext/mesh/mesh/src/wrapper.cc +433 -0
  83. data/ext/mesh/mesh/support/export_mesh.cmake +28 -0
  84. data/ext/mesh/mesh/support/gen-size-classes +57 -0
  85. data/ext/mesh/mesh/support/install_all_configs +33 -0
  86. data/ext/mesh/mesh/support/remove_export_mesh.cmake +48 -0
  87. data/ext/mesh/mesh/support/update-bazelisk +8 -0
  88. data/ext/mesh/mesh/theory/32m80.png +0 -0
  89. data/ext/mesh/mesh/theory/64m80ind.png +0 -0
  90. data/ext/mesh/mesh/theory/bound_comparison.py +67 -0
  91. data/ext/mesh/mesh/theory/bounds/impdeg+1 +135 -0
  92. data/ext/mesh/mesh/theory/choose.py +43 -0
  93. data/ext/mesh/mesh/theory/common.py +42 -0
  94. data/ext/mesh/mesh/theory/compute_exp_Y.py +134 -0
  95. data/ext/mesh/mesh/theory/createRandomString.py +69 -0
  96. data/ext/mesh/mesh/theory/deg_bound_check.py +100 -0
  97. data/ext/mesh/mesh/theory/degcheck.py +47 -0
  98. data/ext/mesh/mesh/theory/dumps/32,1,80,dumb.txt +81 -0
  99. data/ext/mesh/mesh/theory/dumps/32,2,80,dumb.txt +81 -0
  100. data/ext/mesh/mesh/theory/dumps/32,3,80,dumb.txt +81 -0
  101. data/ext/mesh/mesh/theory/dumps/32,4,80,dumb.txt +81 -0
  102. data/ext/mesh/mesh/theory/dumps/32,5,80,dumb.txt +81 -0
  103. data/ext/mesh/mesh/theory/dumps/32,6,80,dumb.txt +81 -0
  104. data/ext/mesh/mesh/theory/dumps/32,7,80,dumb.txt +81 -0
  105. data/ext/mesh/mesh/theory/dumps/32,8,80,dumb.txt +81 -0
  106. data/ext/mesh/mesh/theory/dumps/32,9,80,dumb.txt +81 -0
  107. data/ext/mesh/mesh/theory/experiment.py +303 -0
  108. data/ext/mesh/mesh/theory/experiment_raw_results/.gitignore +0 -0
  109. data/ext/mesh/mesh/theory/greedy_experiment.py +66 -0
  110. data/ext/mesh/mesh/theory/greedy_experiment_copy.py +46 -0
  111. data/ext/mesh/mesh/theory/greedy_experiment_q.py +75 -0
  112. data/ext/mesh/mesh/theory/makeGraph.py +64 -0
  113. data/ext/mesh/mesh/theory/manyreps.png +0 -0
  114. data/ext/mesh/mesh/theory/manystrings.png +0 -0
  115. data/ext/mesh/mesh/theory/match_vs_color_experiment.py +94 -0
  116. data/ext/mesh/mesh/theory/maxmatch_vs_E[Y].py +162 -0
  117. data/ext/mesh/mesh/theory/maxmatch_vs_greedymatch.py +96 -0
  118. data/ext/mesh/mesh/theory/maxvdeg+1imp++32,80.png +0 -0
  119. data/ext/mesh/mesh/theory/mesh_util.py +322 -0
  120. data/ext/mesh/mesh/theory/meshers.py +452 -0
  121. data/ext/mesh/mesh/theory/meshingBenchmark.py +96 -0
  122. data/ext/mesh/mesh/theory/occupancyComparison.py +133 -0
  123. data/ext/mesh/mesh/theory/randmatch_vs_greedymatch.py +97 -0
  124. data/ext/mesh/mesh/theory/randmatch_vs_greedymatch_q.py +103 -0
  125. data/ext/mesh/mesh/theory/randmatch_vs_greedymatch_time.py +117 -0
  126. data/ext/mesh/mesh/theory/read_mesh_dump.py +82 -0
  127. data/ext/mesh/mesh/theory/test.py +70 -0
  128. data/ext/mesh/mesh/tools/bazel +1 -0
  129. data/lib/mesh/version.rb +3 -0
  130. data/mesh.gemspec +14 -0
  131. metadata +172 -0
@@ -0,0 +1,46 @@
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 meshers import *
10
+ import matplotlib.pyplot as plt
11
+ from matplotlib.backends.backend_pdf import PdfPages
12
+
13
+
14
+ length = 32
15
+ ones_range_min = 4
16
+ ones_range_max = 16
17
+ reps = 10
18
+ numStrings = 100
19
+
20
+ strings = []
21
+ ones = []
22
+ numUnmatched = []
23
+ perc = []
24
+ for numOnes in range(ones_range_min, ones_range_max+1):
25
+ for iterations in range (reps):
26
+ for i in range(numStrings):
27
+ strings.append(createRandomString(length, numOnes))
28
+ b, unmatched = greedyMesher(strings)
29
+ ones.append(numOnes)
30
+ percentage = (len(unmatched)/numStrings)*100
31
+ numUnmatched.append(len(unmatched))
32
+ perc.append(percentage)
33
+ strings = []
34
+ plt.plot(ones, numUnmatched,'ro')
35
+ plt.ylabel('Number of unmatched strings')
36
+ plt.xlabel('Number of ones per string')
37
+ plt.title('GREEDY FIRST-MATCH MESHING RESULTS \n{}-bit strings, {} trials per x value'.format(length, reps))
38
+ #plt.show()
39
+
40
+
41
+ plt.plot(ones, perc,'ro')
42
+ plt.ylabel('Percentage of unmatched strings')
43
+ plt.xlabel('Number of ones per string')
44
+ plt.title('GREEDY FIRST-MATCH MESHING RESULTS \n{}-bit strings, {} trials per x value, {} strings per trial'.format(length, reps, numStrings))
45
+ plt.show()
46
+ #plt.savefig('test.png', dpi = 1000)
@@ -0,0 +1,75 @@
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
+ import matplotlib.pyplot as plt
11
+ import numpy as np
12
+ import math
13
+ from choose import compute_q
14
+
15
+ #def nCr(n,r):
16
+ # f = math.factorial
17
+ # return f(n) / f(r) / f(n-r)
18
+ #
19
+ #def compute_q(length, numOnes):
20
+ # result = float((nCr(length-numOnes, numOnes)))/(nCr(length, numOnes))
21
+ # return result
22
+
23
+
24
+ def experiment(length, ones_range_min, ones_range_max, reps, numStrings):
25
+
26
+ strings = []
27
+ ones = []
28
+ avg = []
29
+ stddev = []
30
+
31
+ for numOnes in range(ones_range_min, ones_range_max+1):
32
+ ones.append(numOnes)
33
+ vals = []
34
+ for iterations in range (reps):
35
+ for i in range(numStrings):
36
+ strings.append(createRandomString(length, numOnes))
37
+ b, unmatched = greedyMesher(strings)
38
+ pages_freed = (numStrings - len(unmatched))/2
39
+ percentage = (pages_freed/numStrings)*100
40
+ vals.append(percentage)
41
+ strings = []
42
+ v = np.asarray(vals)
43
+ a = np.mean(v)
44
+ avg.append(a)
45
+ s = np.std(v)
46
+ stddev.append(s)
47
+ return ones, avg, stddev
48
+
49
+ def plot_it(length, ones_range_min, ones_range_max, reps, numStrings):
50
+
51
+ ones, avg, stddev = experiment(length, ones_range_min, ones_range_max, reps, numStrings)
52
+
53
+ q = [compute_q(length, x) for x in ones]
54
+
55
+ plt.errorbar(np.asarray(q), np.asarray(avg), np.asarray(stddev), markersize=3, lw=1, fmt='-o')
56
+ plt.ylim([0,60])
57
+ plt.ylabel('Percentage of pages freed')
58
+ plt.xlabel('q (probability of 2 pages meshing)')
59
+ plt.title('GREEDY FIRST-MATCH MESHING RESULTS \n{}-object pages, {} pages'.format(length, numStrings))
60
+ plt.show()
61
+ #plt.savefig('{}p{}'.format(length, numStrings) + '.png', dpi = 1000)
62
+ #plt.close()
63
+
64
+ #length = [32,64]
65
+ length = [32]
66
+ ones_range_min = 1
67
+ ones_range_max = 16
68
+ reps = 10
69
+ #numStrings = [80,100,150,200]
70
+ numStrings = [80,100]
71
+
72
+ for l in length:
73
+ for n in numStrings:
74
+ plot_it(l, 1, int(l/2), reps, n)
75
+ print 'greedy plot {},{} done'.format(l,n)
@@ -0,0 +1,64 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Sat Feb 27 23:07:03 2016
4
+
5
+ @author: devd
6
+ """
7
+ import numpy as np
8
+ from scipy.sparse import csr_matrix
9
+ import networkx as nx
10
+
11
+ def makeAdjacencyMatrix(strings, sparse):
12
+ nums = [long(s, base=2) for s in strings]
13
+ dim = len(strings)
14
+ graph = np.zeros((dim,dim))
15
+ for i in range(dim):
16
+ for j in range(dim):
17
+ if i == j:
18
+ continue
19
+ num = nums[i]
20
+ num2 = nums[j]
21
+ if num & num2 == 0:
22
+ graph[i,j] = 1
23
+ if sparse:
24
+ graph = csr_matrix(graph)
25
+ return graph
26
+
27
+
28
+
29
+
30
+ def makeGraph(strings):
31
+ nums = [long(s, base=2) for s in strings]
32
+ dim = len(strings)
33
+ g = np.zeros((dim,dim))
34
+ for i in range(dim):
35
+ for j in range(dim):
36
+ if i == j:
37
+ continue
38
+ num = nums[i]
39
+ num2 = nums[j]
40
+ if num & num2 == 0:
41
+ g[i,j] = 1
42
+ graph = nx.Graph(g)
43
+ return graph
44
+
45
+
46
+ #g = makeGraph(['000','001','111','101', '110', '010'])
47
+ #nx.draw(g)
48
+ #degrees = g.degree(g.nodes())
49
+ #print max(degrees.values())
50
+ #print min(degrees.values())
51
+ #print degrees
52
+
53
+
54
+
55
+
56
+
57
+
58
+ #g_c = nx.complement(g)
59
+ #color = nx.greedy_color(g_c)
60
+ #print color
61
+ #i = 0
62
+ #for key, value in color.iteritems():
63
+ # i = max(i, value)
64
+ #print i + 1
Binary file
@@ -0,0 +1,94 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Sun Feb 28 22:44:37 2016
4
+
5
+ @author: devd
6
+ """
7
+
8
+ from __future__ import division
9
+ from createRandomString import *
10
+ from makeGraph import *
11
+ import matplotlib.pyplot as plt
12
+ import matplotlib.patches as mpatches
13
+ import networkx as nx
14
+ import numpy as np
15
+
16
+
17
+ def color_counter(graph):
18
+ color = nx.greedy_color(graph)
19
+ i = 0
20
+ for key, value in color.iteritems():
21
+ i = max(i, value)
22
+ return i+1
23
+
24
+ def experiment(length, ones_range_min, ones_range_max, reps, numStrings):
25
+ strings = []
26
+ ones = []
27
+ match_avg = []
28
+ match_std_dev = []
29
+ color_avg = []
30
+ color_std_dev = []
31
+
32
+ for numOnes in range(ones_range_min, ones_range_max+1):
33
+ ones.append(numOnes)
34
+ freed_pages_matching = []
35
+ freed_pages_coloring = []
36
+ for iterations in range (reps):
37
+ for i in range(numStrings):
38
+ strings.append(createRandomString(length, numOnes))
39
+ # strings = createIndependentRandomStrings(length, numStrings, numOnes = numOnes)
40
+
41
+ graph = makeGraph(strings)
42
+ frdpgs_matching = len(nx.max_weight_matching(graph))/2
43
+ perc = (frdpgs_matching/numStrings)*100
44
+ freed_pages_matching.append(perc)
45
+
46
+ graph_c = nx.complement(graph)
47
+ frdpgs_coloring = numStrings - color_counter(graph_c)
48
+ perc = (frdpgs_coloring/numStrings)*100
49
+ freed_pages_coloring.append(perc)
50
+
51
+ strings = []
52
+ m = np.asarray(freed_pages_matching)
53
+ m_a = np.mean(m)
54
+ match_avg.append(m_a)
55
+ m_s = np.std(m)
56
+ match_std_dev.append(m_s)
57
+
58
+ c = np.asarray(freed_pages_coloring)
59
+ c_a = np.mean(c)
60
+ color_avg.append(c_a)
61
+ c_s = np.std(c)
62
+ color_std_dev.append(c_s)
63
+
64
+ return ones, match_avg, match_std_dev, color_avg, color_std_dev
65
+
66
+
67
+ def plot_it(length, ones_range_min, ones_range_max, reps, numStrings):
68
+ ones, match_avg, match_std_dev, color_avg, color_std_dev = experiment(length, ones_range_min, ones_range_max, reps, numStrings)
69
+
70
+ plt.errorbar(np.asarray(ones), np.asarray(match_avg), np.asarray(match_std_dev), markersize=3, lw=1, fmt='-o')
71
+ plt.errorbar(np.asarray(ones), np.asarray(color_avg), np.asarray(color_std_dev), markersize=3, lw=1, fmt='-o')
72
+ plt.ylim([0,100])
73
+ plt.ylabel('Percentage of pages freed')
74
+ plt.xlabel('Number of objects per page')
75
+ blue_patch = mpatches.Patch(color='blue', label='matching')
76
+ green_patch = mpatches.Patch(color = 'green', label = 'clique')
77
+ plt.legend(handles=[blue_patch, green_patch])
78
+ plt.title('MAX MATCHING VS MIN CLIQUE COVER MESHING RESULTS \n{}-object pages, {} pages'.format(length, numStrings))
79
+ # plt.show()
80
+ plt.savefig('{}m{}ind'.format(length, numStrings) + '.png', dpi = 1000)
81
+ # plt.close()
82
+
83
+ length = [64]
84
+ ones_range_min = 1
85
+ ones_range_max = 32
86
+ reps = 10
87
+ #numStrings = [80,100,150,200]
88
+ numStrings = [80]
89
+
90
+ for l in length:
91
+ for n in numStrings:
92
+ plot_it(l, ones_range_min, int(l/2), reps, n)
93
+ print 'match vs color plot {},{} done'.format(l,n)
94
+
@@ -0,0 +1,162 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Fri Apr 15 15:25:44 2016
4
+
5
+ @author: devd
6
+ """
7
+
8
+ from __future__ import division
9
+ from createRandomString import *
10
+ from makeGraph 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 compute_exp_Y import compute_exp_Y, compute_degree_bound, compute_isolated_edge_bound, compute_degreeplusone_bound, compute_improved_degreeplusone_bound
17
+ from choose import compute_q
18
+
19
+ def experiment(length, ones_range_min, ones_range_max, reps, numStrings):
20
+ strings = []
21
+ ones = []
22
+ maxmatch_avg = []
23
+ maxmatch_std_dev = []
24
+ # greedymatch_avg = []
25
+ # greedymatch_std_dev = []
26
+ y_estimate = []
27
+ justy = []
28
+ raw = []
29
+ qs = []
30
+
31
+
32
+ for numOnes in range(ones_range_min, ones_range_max+1):
33
+ ones.append(numOnes)
34
+ q = compute_q(length, numOnes)
35
+ qs.append(q*100)
36
+ # qs.append(compute_q(length, numOnes)*100)
37
+ freed_pages_maxmatching = []
38
+ freed_pages_greedymatching = []
39
+ for iterations in range (reps):
40
+ for i in range(numStrings):
41
+ strings.append(createRandomString(length, numOnes))
42
+ # strings = createIndependentRandomStrings(length = length, numStrings = numStrings, q = q)
43
+
44
+ graph = makeGraph(strings)
45
+ frdpgs_maxmatching = len(nx.max_weight_matching(graph))/2
46
+ perc = (frdpgs_maxmatching/numStrings)*100
47
+ freed_pages_maxmatching.append(perc)
48
+
49
+ strings = []
50
+
51
+
52
+
53
+ m = np.asarray(freed_pages_maxmatching)
54
+ raw.append(freed_pages_maxmatching)
55
+ m_a = np.mean(m)
56
+ maxmatch_avg.append(m_a)
57
+ m_s = np.std(m)
58
+ maxmatch_std_dev.append(m_s)
59
+
60
+ # y = compute_exp_Y(length, numOnes, numStrings)
61
+ # y = compute_degreeplusone_bound(length, numOnes, numStrings)
62
+ y = compute_improved_degreeplusone_bound(length, numOnes, numStrings)
63
+
64
+ # y_est_raw = max(y,compute_degree_bound(length, numOnes, numStrings),compute_isolated_edge_bound(length, numOnes, numStrings))
65
+ # y_est_raw = compute_isolated_edge_bound(length, numOnes, numStrings)
66
+ # y_est_raw = compute_degree_bound(length, numOnes, numStrings)
67
+ # y_est_raw = y
68
+ yperc = (math.floor(y)/numStrings)*100
69
+ y_estimate.append(yperc)
70
+
71
+
72
+ # mistakes = {}
73
+ # for i in range(len(raw)):
74
+ # oops = []
75
+ # for entry in raw[i]:
76
+ # if entry < y_estimate[i]:
77
+ # oops.append(entry)
78
+ # mistakes[i+1] = oops
79
+ # print 'mistakes:'
80
+ # print mistakes
81
+
82
+
83
+
84
+
85
+
86
+ # use this version of mistakes
87
+ mistakes = {}
88
+ for i in range(len(raw)):
89
+ oops = 0
90
+ for entry in raw[i]:
91
+ if entry < y_estimate[i]:
92
+ oops += 1
93
+ mistakes[i+1] = oops
94
+ print 'mistakes:'
95
+ print mistakes
96
+
97
+ print 'E[Y]:'
98
+ ey = {}
99
+ for i in range(len(y_estimate)):
100
+ ey[i+1] = y_estimate[i]
101
+ print ey
102
+ #
103
+
104
+ # yperc = (y/numStrings)*100
105
+ # justy.append(yperc)
106
+
107
+ # c = np.asarray(freed_pages_greedymatching)
108
+ # c_a = np.mean(c)
109
+ # greedymatch_avg.append(c_a)
110
+ # c_s = np.std(c)
111
+ # greedymatch_std_dev.append(c_s)
112
+
113
+
114
+
115
+ return ones, maxmatch_avg, maxmatch_std_dev, y_estimate, justy, qs
116
+
117
+
118
+ def plot_it(length, ones_range_min, ones_range_max, reps, numStrings):
119
+ ones, match_avg, match_std_dev, y_estimate, justy, qs = experiment(length, ones_range_min, ones_range_max, reps, numStrings)
120
+
121
+ # print y_estimate
122
+ plt.errorbar(np.asarray(ones), np.asarray(match_avg), np.asarray(match_std_dev), markersize=3, lw=1, fmt='-o')
123
+ # plt.errorbar(np.asarray(ones), np.asarray(color_avg), np.asarray(color_std_dev), markersize=3, lw=1, fmt='-o')
124
+ plt.errorbar(np.asarray(ones), np.asarray(y_estimate), np.zeros(len(ones)), markersize=3, lw=1, fmt='-o')
125
+ # plt.errorbar(np.asarray(ones), np.asarray(justy), np.zeros(len(ones)), markersize=3, lw=1, fmt='-o')
126
+ # plt.plot(np.asarray(ones), y_estimate, markersize = 3, lw=1, fmt='o')
127
+ # plt.errorbar(np.asarray(ones), np.asarray(qs), np.zeros(len(ones)), markersize=3, lw=1, fmt='-o')
128
+ plt.ylim([0,60])
129
+ # plt.xlim([10, 14])
130
+ plt.ylabel('Percentage of pages freed')
131
+ plt.xlabel('Number of objects per page')
132
+ blue_patch = mpatches.Patch(color='blue', label='max matching')
133
+ green_patch = mpatches.Patch(color = 'green', label = 'lower bound')
134
+ red_patch = mpatches.Patch(color = 'red', label = 'q')
135
+ plt.legend(handles=[blue_patch, green_patch])
136
+ # plt.legend(handles=[blue_patch, green_patch, red_patch])
137
+ plt.title('MAX MATCHING VS LOWER BOUND \n{}-object pages, {} pages'.format(length, numStrings))
138
+ # plt.show()
139
+ # plt.savefig('maxvE[Y]{},{}'.format(length, numStrings) + '.png', dpi = 1000)
140
+ plt.savefig('maxvdeg+1imp++{},{}'.format(length, numStrings) + '.png', dpi = 1000)
141
+ # plt.savefig('manystrings.png', dpi = 1000)
142
+ plt.close()
143
+
144
+
145
+ if __name__ == '__main__':
146
+ #length = [32,64]
147
+ length = [32]
148
+ ones_range_min = 1
149
+ ones_range_max = 32
150
+ reps = 10
151
+ # numStrings = [80,100,150,200]
152
+ numStrings= [80]
153
+
154
+
155
+ start = time.time()
156
+ for l in length:
157
+ for n in numStrings:
158
+ plot_it(l, ones_range_min, int(l/2), reps, n)
159
+ # plot_it(l, 10, 13, 10, n)
160
+ print 'max match vs E[Y] plot {},{} done'.format(l,n)
161
+ end = time.time()
162
+ print('making this took {} seconds'.format(end-start) )