Other plots

This commit is contained in:
HajarZaiz 2023-04-21 09:45:17 +00:00
parent 9d699ada51
commit 4f0e888c1b
3 changed files with 67 additions and 9 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ myenv
doc/_build doc/_build
!results/plots.py !results/plots.py
Frontend/ Frontend/
smallConf.py

View File

@ -6,6 +6,7 @@ import matplotlib.pyplot as plt
import numpy as np import numpy as np
import seaborn as sns import seaborn as sns
from itertools import combinations from itertools import combinations
from mplfinance.original_flavor import candlestick_ohlc
class Visualizer: class Visualizer:
@ -83,7 +84,7 @@ class Visualizer:
return data return data
def averageRuns(self, data, runs): def averageRuns(self, data, runs):
"""Get the average of run 0 and run 1 for each key""" """Get the average of all runs for each key"""
newData = {} newData = {}
allTta = [] allTta = []
print("Getting the average of the runs...") print("Getting the average of the runs...")
@ -207,3 +208,38 @@ class Visualizer:
filename = os.path.join(histogramFolder, 'histogram.png') filename = os.path.join(histogramFolder, 'histogram.png')
plt.savefig(filename) plt.savefig(filename)
plt.clf() plt.clf()
def plotHist(self, bandwidth):
"""Plot Bandwidth Frequency Histogram"""
plt.hist(bandwidth, bins=5)
plt.xlabel('Bandwidth')
plt.ylabel('Frequency')
plt.title('Bandwidth Histogram')
"""Create the directory if it doesn't exist already"""
histogramFolder = self.folderPath + '/histogram'
if not os.path.exists(histogramFolder):
os.makedirs(histogramFolder)
filename = os.path.join(histogramFolder, 'histogram.png')
plt.savefig(filename)
plt.clf()
def plotCandleStick(self, TX_prod, TX_avg, TX_max):
#x-axis corresponding to steps
steps = range(len(TX_prod))
#Plot the candlestick chart
ohlc = []
for i in range(len(TX_prod)):
ohlc.append([steps[i], TX_prod[i], TX_max[i], TX_avg[i]])
fig, ax = plt.subplots()
candlestick_ohlc(ax, ohlc, width=0.6, colorup='green', colordown='red')
#Ticks, title and labels
plt.xticks(steps, ['run{}'.format(i) for i in steps], rotation=45)
plt.title('Candlestick Chart')
plt.xlabel('Step')
plt.ylabel('Price')
#Test
plt.show()

View File

@ -19,6 +19,13 @@ import numpy as np
from DAS.shape import Shape from DAS.shape import Shape
dumpXML = 1 dumpXML = 1
# save progress vectors to XML
saveProgress = 1
# plot progress for each run to PNG
plotProgress = 1
visualization = 1 visualization = 1
logLevel = logging.INFO logLevel = logging.INFO
@ -34,26 +41,26 @@ evenLineDistribution = True
runs = range(3) runs = range(3)
# Number of validators # Number of validators
numberNodes = range(256, 313, 128) numberNodes = range(128, 513, 128)
# Percentage of block not released by producer # Percentage of block not released by producer
failureRates = range(10, 31, 40) failureRates = range(40, 81, 20)
# Block size in one dimension in segments. Block is blockSizes * blockSizes segments. # Block size in one dimension in segments. Block is blockSizes * blockSizes segments.
blockSizes = range(32,35,16) blockSizes = range(64, 113, 128)
# Per-topic mesh neighborhood size # Per-topic mesh neighborhood size
netDegrees = range(6, 9, 2) netDegrees = range(8, 9, 2)
# number of rows and columns a validator is interested in # number of rows and columns a validator is interested in
chis = range(2, 5, 2) chis = range(2, 3, 2)
# ratio of class1 nodes (see below for parameters per class) # ratio of class1 nodes (see below for parameters per class)
class1ratios = [0.8, 0.9] class1ratios = [0.8]
# Number of validators per beacon node # Number of validators per beacon node
validatorsPerNode1 = [1] validatorsPerNode1 = [2]
validatorsPerNode2 = [50] validatorsPerNode2 = [4]
# Set uplink bandwidth. In segments (~560 bytes) per timestep (50ms?) # Set uplink bandwidth. In segments (~560 bytes) per timestep (50ms?)
# 1 Mbps ~= 1e6 / 20 / 8 / 560 ~= 11 # 1 Mbps ~= 1e6 / 20 / 8 / 560 ~= 11
@ -67,6 +74,20 @@ deterministic = True
# If your run is deterministic you can decide the random seed. This is ignore otherwise. # If your run is deterministic you can decide the random seed. This is ignore otherwise.
randomSeed = "DAS" randomSeed = "DAS"
saveProgress = 1
saveRCdist = 1
# If True, print diagnostics when the block is not available
diagnostics = False
# Number of steps without progress to stop simulation
steps4StopCondition = 7
saveGit = False
successCondition = 0.9
stepDuration = 50
def nextShape(): def nextShape():
for run, fr, class1ratio, chi, vpn1, vpn2, blockSize, nn, netDegree, bwUplinkProd, bwUplink1, bwUplink2 in itertools.product( for run, fr, class1ratio, chi, vpn1, vpn2, blockSize, nn, netDegree, bwUplinkProd, bwUplink1, bwUplink2 in itertools.product(
runs, failureRates, class1ratios, chis, validatorsPerNode1, validatorsPerNode2, blockSizes, numberNodes, netDegrees, bwUplinksProd, bwUplinks1, bwUplinks2): runs, failureRates, class1ratios, chis, validatorsPerNode1, validatorsPerNode2, blockSizes, numberNodes, netDegrees, bwUplinksProd, bwUplinks1, bwUplinks2):