Tweaked example plotting scripts.

This commit is contained in:
Michael Whittaker 2021-01-31 22:59:02 -08:00
parent 03b307d5f0
commit 1616a855f1
2 changed files with 14 additions and 8 deletions

View file

@ -21,23 +21,25 @@ def main():
for name, qs in quorum_systems.items():
d = {0.0: 1, 0.1: 1, 0.2: 1, 0.3: 1, 0.4: 1, 0.5: 1,
0.6: 1, 0.7: 1, 0.8: 1, 0.9: 1, 1.0: 1}
fig, axes = plt.subplots(3, 4, figsize=(6 * 4, 4 * 3), sharey='all')
fig, axes = plt.subplots(3, 4, figsize=(6 * 2, 4 * 2), sharey='all')
axes_iter = (axes[row][col] for row in range(3) for col in range(4))
for fr in d.keys():
sigma = qs.strategy(read_fraction=fr)
ax = next(axes_iter)
plot_load_distribution_on(ax, sigma, nodes)
ax.set_title(f'Optimized For Read Fraction = {fr}')
ax.set_title(f'Optimized For\nRead Fraction = {fr}')
ax.set_xlabel('Read Fraction')
ax.legend()
ax.grid()
# ax.legend()
sigma = qs.strategy(read_fraction=d)
ax = next(axes_iter)
plot_load_distribution_on(ax, sigma, nodes)
ax.set_title('Optimized For Uniform Read Fraction')
ax.set_title('Optimized For\nUniform Read Fraction')
ax.set_xlabel('Read Fraction')
ax.legend()
ax.grid()
# ax.legend()
axes[0][0].set_ylabel('Load')
axes[1][0].set_ylabel('Load')

View file

@ -1,4 +1,5 @@
from quorums import *
import datetime
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
@ -10,16 +11,18 @@ def main():
c = Node('c', write_capacity=1000, read_capacity=10000)
d = Node('d', write_capacity=500, read_capacity=5000)
e = Node('e', write_capacity=1000, read_capacity=10000)
fr = 0.9
nodes = [a, b, c, d, e]
simple_majority = QuorumSystem(reads=majority([a, b, c, d, e]))
crumbling_walls = QuorumSystem(reads=a*b + c*d*e)
paths = QuorumSystem(reads=a*b + a*c*e + d*e + d*c*b)
opt = search(nodes, read_fraction=fr, timeout=datetime.timedelta(seconds=9))
fig, ax = plt.subplots(3, 3, figsize = (6.3 * 2, 4.8 * 2), sharey='row')
for i, qs in enumerate([simple_majority, crumbling_walls, paths]):
fr = 0.9
fig, ax = plt.subplots(3, 4, figsize = (6.3 * 2, 4.8 * 2), sharey='row')
for i, qs in enumerate([simple_majority, crumbling_walls, paths, opt]):
sigma = qs.strategy(read_fraction=fr)
print(qs, sigma.capacity(read_fraction=fr))
plot_node_load_on(ax[0][i], sigma, nodes=nodes, read_fraction=fr)
plot_node_utilization_on(ax[1][i], sigma, nodes=nodes, read_fraction=fr)
plot_node_throughput_on(ax[2][i], sigma, nodes=nodes, read_fraction=fr)
@ -27,6 +30,7 @@ def main():
ax[0][0].set_title('Simple Majority')
ax[0][1].set_title('Crumbling Walls')
ax[0][2].set_title('Paths')
ax[0][3].set_title(f'Opt {opt.reads}')
ax[0][0].set_ylabel('Load')
ax[1][0].set_ylabel('Utilization at Peak Throughput')
ax[2][0].set_ylabel('Throughput at Peak Throughput')