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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/ext/mesh/extconf.rb +22 -4
- data/ext/mesh/mesh.tar.gz +0 -0
- data/lib/mesh/version.rb +1 -1
- data/mesh.gemspec +3 -2
- metadata +4 -120
- data/ext/mesh/mesh/.bazelrc +0 -20
- data/ext/mesh/mesh/.bazelversion +0 -1
- data/ext/mesh/mesh/.clang-format +0 -15
- data/ext/mesh/mesh/.dockerignore +0 -5
- data/ext/mesh/mesh/.editorconfig +0 -16
- data/ext/mesh/mesh/.gitattributes +0 -4
- data/ext/mesh/mesh/.github/workflows/main.yml +0 -144
- data/ext/mesh/mesh/.gitignore +0 -51
- data/ext/mesh/mesh/AUTHORS +0 -5
- data/ext/mesh/mesh/CMakeLists.txt +0 -270
- data/ext/mesh/mesh/CODE_OF_CONDUCT.md +0 -77
- data/ext/mesh/mesh/Dockerfile +0 -30
- data/ext/mesh/mesh/LICENSE +0 -201
- data/ext/mesh/mesh/Makefile +0 -81
- data/ext/mesh/mesh/README.md +0 -97
- data/ext/mesh/mesh/WORKSPACE +0 -50
- data/ext/mesh/mesh/bazel +0 -350
- data/ext/mesh/mesh/mesh-pldi19-powers.pdf +0 -0
- data/ext/mesh/mesh/src/BUILD +0 -222
- data/ext/mesh/mesh/src/CMakeLists.txt +0 -85
- data/ext/mesh/mesh/src/bitmap.h +0 -590
- data/ext/mesh/mesh/src/cheap_heap.h +0 -170
- data/ext/mesh/mesh/src/common.h +0 -377
- data/ext/mesh/mesh/src/copts.bzl +0 -31
- data/ext/mesh/mesh/src/d_assert.cc +0 -75
- data/ext/mesh/mesh/src/fixed_array.h +0 -124
- data/ext/mesh/mesh/src/global_heap.cc +0 -547
- data/ext/mesh/mesh/src/global_heap.h +0 -569
- data/ext/mesh/mesh/src/gnu_wrapper.cc +0 -75
- data/ext/mesh/mesh/src/internal.h +0 -356
- data/ext/mesh/mesh/src/libmesh.cc +0 -239
- data/ext/mesh/mesh/src/mac_wrapper.cc +0 -528
- data/ext/mesh/mesh/src/measure_rss.cc +0 -44
- data/ext/mesh/mesh/src/measure_rss.h +0 -20
- data/ext/mesh/mesh/src/meshable_arena.cc +0 -776
- data/ext/mesh/mesh/src/meshable_arena.h +0 -309
- data/ext/mesh/mesh/src/meshing.h +0 -60
- data/ext/mesh/mesh/src/mini_heap.h +0 -532
- data/ext/mesh/mesh/src/mmap_heap.h +0 -104
- data/ext/mesh/mesh/src/one_way_mmap_heap.h +0 -77
- data/ext/mesh/mesh/src/partitioned_heap.h +0 -111
- data/ext/mesh/mesh/src/plasma/mesh.h +0 -33
- data/ext/mesh/mesh/src/real.cc +0 -52
- data/ext/mesh/mesh/src/real.h +0 -36
- data/ext/mesh/mesh/src/rng/mwc.h +0 -296
- data/ext/mesh/mesh/src/rng/mwc64.h +0 -58
- data/ext/mesh/mesh/src/rpl_printf.c +0 -1991
- data/ext/mesh/mesh/src/runtime.cc +0 -393
- data/ext/mesh/mesh/src/runtime.h +0 -114
- data/ext/mesh/mesh/src/shuffle_vector.h +0 -287
- data/ext/mesh/mesh/src/size_classes.def +0 -251
- data/ext/mesh/mesh/src/static/if.h +0 -36
- data/ext/mesh/mesh/src/static/log.h +0 -43
- data/ext/mesh/mesh/src/testing/benchmark/local_refill.cc +0 -103
- data/ext/mesh/mesh/src/testing/big-alloc.c +0 -28
- data/ext/mesh/mesh/src/testing/fragmenter.cc +0 -128
- data/ext/mesh/mesh/src/testing/global-large-stress.cc +0 -25
- data/ext/mesh/mesh/src/testing/local-alloc.c +0 -16
- data/ext/mesh/mesh/src/testing/meshing_benchmark.cc +0 -189
- data/ext/mesh/mesh/src/testing/thread.cc +0 -35
- data/ext/mesh/mesh/src/testing/unit/alignment.cc +0 -56
- data/ext/mesh/mesh/src/testing/unit/bitmap_test.cc +0 -274
- data/ext/mesh/mesh/src/testing/unit/concurrent_mesh_test.cc +0 -185
- data/ext/mesh/mesh/src/testing/unit/mesh_test.cc +0 -143
- data/ext/mesh/mesh/src/testing/unit/rng_test.cc +0 -22
- data/ext/mesh/mesh/src/testing/unit/size_class_test.cc +0 -66
- data/ext/mesh/mesh/src/testing/unit/triple_mesh_test.cc +0 -285
- data/ext/mesh/mesh/src/testing/userfaultfd-kernel-copy.cc +0 -164
- data/ext/mesh/mesh/src/thread_local_heap.cc +0 -163
- data/ext/mesh/mesh/src/thread_local_heap.h +0 -268
- data/ext/mesh/mesh/src/wrapper.cc +0 -433
- data/ext/mesh/mesh/support/export_mesh.cmake +0 -28
- data/ext/mesh/mesh/support/gen-size-classes +0 -57
- data/ext/mesh/mesh/support/install_all_configs +0 -33
- data/ext/mesh/mesh/support/remove_export_mesh.cmake +0 -48
- data/ext/mesh/mesh/support/update-bazelisk +0 -8
- data/ext/mesh/mesh/theory/32m80.png +0 -0
- data/ext/mesh/mesh/theory/64m80ind.png +0 -0
- data/ext/mesh/mesh/theory/bound_comparison.py +0 -67
- data/ext/mesh/mesh/theory/bounds/impdeg+1 +0 -135
- data/ext/mesh/mesh/theory/choose.py +0 -43
- data/ext/mesh/mesh/theory/common.py +0 -42
- data/ext/mesh/mesh/theory/compute_exp_Y.py +0 -134
- data/ext/mesh/mesh/theory/createRandomString.py +0 -69
- data/ext/mesh/mesh/theory/deg_bound_check.py +0 -100
- data/ext/mesh/mesh/theory/degcheck.py +0 -47
- data/ext/mesh/mesh/theory/dumps/32,1,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,2,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,3,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,4,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,5,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,6,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,7,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,8,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/dumps/32,9,80,dumb.txt +0 -81
- data/ext/mesh/mesh/theory/experiment.py +0 -303
- data/ext/mesh/mesh/theory/experiment_raw_results/.gitignore +0 -0
- data/ext/mesh/mesh/theory/greedy_experiment.py +0 -66
- data/ext/mesh/mesh/theory/greedy_experiment_copy.py +0 -46
- data/ext/mesh/mesh/theory/greedy_experiment_q.py +0 -75
- data/ext/mesh/mesh/theory/makeGraph.py +0 -64
- data/ext/mesh/mesh/theory/manyreps.png +0 -0
- data/ext/mesh/mesh/theory/manystrings.png +0 -0
- data/ext/mesh/mesh/theory/match_vs_color_experiment.py +0 -94
- data/ext/mesh/mesh/theory/maxmatch_vs_E[Y].py +0 -162
- data/ext/mesh/mesh/theory/maxmatch_vs_greedymatch.py +0 -96
- data/ext/mesh/mesh/theory/maxvdeg+1imp++32,80.png +0 -0
- data/ext/mesh/mesh/theory/mesh_util.py +0 -322
- data/ext/mesh/mesh/theory/meshers.py +0 -452
- data/ext/mesh/mesh/theory/meshingBenchmark.py +0 -96
- data/ext/mesh/mesh/theory/occupancyComparison.py +0 -133
- data/ext/mesh/mesh/theory/randmatch_vs_greedymatch.py +0 -97
- data/ext/mesh/mesh/theory/randmatch_vs_greedymatch_q.py +0 -103
- data/ext/mesh/mesh/theory/randmatch_vs_greedymatch_time.py +0 -117
- data/ext/mesh/mesh/theory/read_mesh_dump.py +0 -82
- data/ext/mesh/mesh/theory/test.py +0 -70
- data/ext/mesh/mesh/tools/bazel +0 -1
@@ -1,46 +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 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)
|
@@ -1,75 +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
|
-
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)
|
@@ -1,64 +0,0 @@
|
|
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
|
Binary file
|
@@ -1,94 +0,0 @@
|
|
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
|
-
|
@@ -1,162 +0,0 @@
|
|
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) )
|