Moved random scripts to examples directory.
I'll clean these up later.
This commit is contained in:
parent
e69ab121e8
commit
3ac5ebc848
6 changed files with 34 additions and 1 deletions
|
@ -1,5 +1,12 @@
|
||||||
|
# See https://stackoverflow.com/a/19521297/3187068
|
||||||
|
import matplotlib
|
||||||
|
matplotlib.use('pdf')
|
||||||
|
font = {'size': 8}
|
||||||
|
matplotlib.rc('font', **font)
|
||||||
|
|
||||||
from quorums import *
|
from quorums import *
|
||||||
import datetime
|
import datetime
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
def seconds(x: int) -> datetime.timedelta:
|
def seconds(x: int) -> datetime.timedelta:
|
||||||
|
@ -28,11 +35,14 @@ def main() -> None:
|
||||||
grid = QuorumSystem(reads=a*b + c*d*e)
|
grid = QuorumSystem(reads=a*b + c*d*e)
|
||||||
paths = QuorumSystem(reads=a*b + a*c*e + d*e + d*c*b)
|
paths = QuorumSystem(reads=a*b + a*c*e + d*e + d*c*b)
|
||||||
|
|
||||||
|
print('0-resilient Capacities')
|
||||||
|
print(maj.uniform_strategy().capacity(read_fraction=fr))
|
||||||
print(maj.capacity(read_fraction=fr))
|
print(maj.capacity(read_fraction=fr))
|
||||||
print(grid.capacity(read_fraction=fr))
|
print(grid.capacity(read_fraction=fr))
|
||||||
print(paths.capacity(read_fraction=fr))
|
print(paths.capacity(read_fraction=fr))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
print('0-resilient Searched')
|
||||||
opt = search(nodes=[a, b, c, d, e],
|
opt = search(nodes=[a, b, c, d, e],
|
||||||
resilience=1,
|
resilience=1,
|
||||||
read_fraction=fr)
|
read_fraction=fr)
|
||||||
|
@ -42,12 +52,31 @@ def main() -> None:
|
||||||
print(sigma.capacity(read_fraction=fr))
|
print(sigma.capacity(read_fraction=fr))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
for (sigma, name, filename, size) in [
|
||||||
|
(maj.uniform_strategy(), 'Majority Quorum System', 'majority_uniform', (3.25, 1.75)),
|
||||||
|
# (grid.strategy(read_fraction=fr), 'Grid Quorum System'),
|
||||||
|
(sigma, 'Searched Quorum System', 'searched', (3.25, 1.75)),
|
||||||
|
]:
|
||||||
|
fig, ax = plt.subplots(figsize=size)
|
||||||
|
plot_node_throughput_on(
|
||||||
|
ax,
|
||||||
|
sigma,
|
||||||
|
nodes = [a, b, c, d, e],
|
||||||
|
read_fraction=0.5,
|
||||||
|
)
|
||||||
|
ax.set_xlabel('Node')
|
||||||
|
ax.set_ylabel('Throughput')
|
||||||
|
fig.tight_layout()
|
||||||
|
fig.savefig(f'{filename}_throughputs.pdf')
|
||||||
|
|
||||||
|
print('1-resilient Capacities')
|
||||||
print(maj)
|
print(maj)
|
||||||
print(maj.capacity(read_fraction=fr, f=1))
|
print(maj.capacity(read_fraction=fr, f=1))
|
||||||
print(grid.capacity(read_fraction=fr, f=1))
|
print(grid.capacity(read_fraction=fr, f=1))
|
||||||
print(paths.capacity(read_fraction=fr, f=1))
|
print(paths.capacity(read_fraction=fr, f=1))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
print('1-resilient Searched')
|
||||||
opt = search(nodes=[a, b, c, d, e], resilience=1, read_fraction=fr, f=1)
|
opt = search(nodes=[a, b, c, d, e], resilience=1, read_fraction=fr, f=1)
|
||||||
sigma = opt.strategy(read_fraction=fr, f=1)
|
sigma = opt.strategy(read_fraction=fr, f=1)
|
||||||
print(opt)
|
print(opt)
|
||||||
|
@ -55,6 +84,9 @@ def main() -> None:
|
||||||
print(sigma.capacity(read_fraction=fr))
|
print(sigma.capacity(read_fraction=fr))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
print('Latency Optimal Capacities and Latencies')
|
||||||
|
print(maj.uniform_strategy().capacity(read_fraction=fr),
|
||||||
|
maj.uniform_strategy().latency(read_fraction=fr))
|
||||||
print(maj.capacity(read_fraction=fr, optimize='latency', load_limit=1/2000),
|
print(maj.capacity(read_fraction=fr, optimize='latency', load_limit=1/2000),
|
||||||
maj.latency(read_fraction=fr, optimize='latency', load_limit=1/2000))
|
maj.latency(read_fraction=fr, optimize='latency', load_limit=1/2000))
|
||||||
print(grid.capacity(read_fraction=fr, optimize='latency', load_limit=1/2000),
|
print(grid.capacity(read_fraction=fr, optimize='latency', load_limit=1/2000),
|
||||||
|
@ -63,6 +95,7 @@ def main() -> None:
|
||||||
paths.latency(read_fraction=fr, optimize='latency', load_limit=1/2000))
|
paths.latency(read_fraction=fr, optimize='latency', load_limit=1/2000))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
print('Latency Optimal Searched')
|
||||||
opt = search(nodes=[a, b, c, d, e], resilience=1, read_fraction=fr, optimize='latency', load_limit=1/2000)
|
opt = search(nodes=[a, b, c, d, e], resilience=1, read_fraction=fr, optimize='latency', load_limit=1/2000)
|
||||||
sigma = opt.strategy(read_fraction=fr, optimize='latency', load_limit=1/2000)
|
sigma = opt.strategy(read_fraction=fr, optimize='latency', load_limit=1/2000)
|
||||||
print(opt)
|
print(opt)
|
|
@ -94,7 +94,7 @@ assert(paths.resilience() >= 1)
|
||||||
|
|
||||||
distribution = {0.9: 0.9, 0.1: 0.1}
|
distribution = {0.9: 0.9, 0.1: 0.1}
|
||||||
print(simple_majority.capacity(read_fraction=distribution)) # 5089
|
print(simple_majority.capacity(read_fraction=distribution)) # 5089
|
||||||
print(crumbling_walls.capacity(read_fraction=distribution)) # 6824
|
print(crumbling_walls.capacity(read_fraction=distribution)) # 5824
|
||||||
print(paths.capacity(read_fraction=distribution)) # 5725
|
print(paths.capacity(read_fraction=distribution)) # 5725
|
||||||
|
|
||||||
print(simple_majority.capacity(read_fraction=distribution, f=1)) # 3816
|
print(simple_majority.capacity(read_fraction=distribution, f=1)) # 3816
|
Loading…
Reference in a new issue