rename numberValidators to numberNodes

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2023-03-13 15:03:55 +01:00
parent 065086f88c
commit 9d9612fd34
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E
5 changed files with 21 additions and 21 deletions

View File

@ -3,10 +3,10 @@
class Shape: class Shape:
"""This class represents a set of parameters for a specific simulation.""" """This class represents a set of parameters for a specific simulation."""
def __init__(self, blockSize, numberValidators, failureRate, class1ratio, chi, vpn1, vpn2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run): def __init__(self, blockSize, numberNodes, failureRate, class1ratio, chi, vpn1, vpn2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run):
"""Initializes the shape with the parameters passed in argument.""" """Initializes the shape with the parameters passed in argument."""
self.run = run self.run = run
self.numberValidators = numberValidators self.numberNodes = numberNodes
self.blockSize = blockSize self.blockSize = blockSize
self.failureRate = failureRate self.failureRate = failureRate
self.netDegree = netDegree self.netDegree = netDegree
@ -23,7 +23,7 @@ class Shape:
"""Returns a printable representation of the shape""" """Returns a printable representation of the shape"""
shastr = "" shastr = ""
shastr += "bs-"+str(self.blockSize) shastr += "bs-"+str(self.blockSize)
shastr += "-nbv-"+str(self.numberValidators) shastr += "-nn-"+str(self.numberNodes)
shastr += "-fr-"+str(self.failureRate) shastr += "-fr-"+str(self.failureRate)
shastr += "-c1r-"+str(self.class1ratio) shastr += "-c1r-"+str(self.class1ratio)
shastr += "-chi-"+str(self.chi) shastr += "-chi-"+str(self.chi)

View File

@ -30,11 +30,11 @@ class Simulator:
self.glob.reset() self.glob.reset()
self.validators = [] self.validators = []
if self.config.evenLineDistribution: if self.config.evenLineDistribution:
rows = list(range(self.shape.blockSize)) * int(self.shape.chi*self.shape.numberValidators/self.shape.blockSize) rows = list(range(self.shape.blockSize)) * int(self.shape.chi*self.shape.numberNodes/self.shape.blockSize)
columns = list(range(self.shape.blockSize)) * int(self.shape.chi*self.shape.numberValidators/self.shape.blockSize) columns = list(range(self.shape.blockSize)) * int(self.shape.chi*self.shape.numberNodes/self.shape.blockSize)
random.shuffle(rows) random.shuffle(rows)
random.shuffle(columns) random.shuffle(columns)
for i in range(self.shape.numberValidators): for i in range(self.shape.numberNodes):
if self.config.evenLineDistribution: if self.config.evenLineDistribution:
val = Validator(i, int(not i!=0), self.logger, self.shape, val = Validator(i, int(not i!=0), self.logger, self.shape,
rows[(i*self.shape.chi):((i+1)*self.shape.chi)], rows[(i*self.shape.chi):((i+1)*self.shape.chi)],
@ -104,7 +104,7 @@ class Simulator:
v.columnNeighbors[id].update({vi.ID : Neighbor(vi, 1, self.shape.blockSize)}) v.columnNeighbors[id].update({vi.ID : Neighbor(vi, 1, self.shape.blockSize)})
if self.logger.isEnabledFor(logging.DEBUG): if self.logger.isEnabledFor(logging.DEBUG):
for i in range(0, self.shape.numberValidators): for i in range(0, self.shape.numberNodes):
self.logger.debug("Val %d : rowN %s", i, self.validators[i].rowNeighbors, extra=self.format) self.logger.debug("Val %d : rowN %s", i, self.validators[i].rowNeighbors, extra=self.format)
self.logger.debug("Val %d : colN %s", i, self.validators[i].columnNeighbors, extra=self.format) self.logger.debug("Val %d : colN %s", i, self.validators[i].columnNeighbors, extra=self.format)
@ -155,17 +155,17 @@ class Simulator:
missingVector.append(missingSamples) missingVector.append(missingSamples)
oldMissingSamples = missingSamples oldMissingSamples = missingSamples
self.logger.debug("PHASE SEND %d" % steps, extra=self.format) self.logger.debug("PHASE SEND %d" % steps, extra=self.format)
for i in range(0,self.shape.numberValidators): for i in range(0,self.shape.numberNodes):
self.validators[i].send() self.validators[i].send()
self.logger.debug("PHASE RECEIVE %d" % steps, extra=self.format) self.logger.debug("PHASE RECEIVE %d" % steps, extra=self.format)
for i in range(1,self.shape.numberValidators): for i in range(1,self.shape.numberNodes):
self.validators[i].receiveRowsColumns() self.validators[i].receiveRowsColumns()
self.logger.debug("PHASE RESTORE %d" % steps, extra=self.format) self.logger.debug("PHASE RESTORE %d" % steps, extra=self.format)
for i in range(1,self.shape.numberValidators): for i in range(1,self.shape.numberNodes):
self.validators[i].restoreRows() self.validators[i].restoreRows()
self.validators[i].restoreColumns() self.validators[i].restoreColumns()
self.logger.debug("PHASE LOG %d" % steps, extra=self.format) self.logger.debug("PHASE LOG %d" % steps, extra=self.format)
for i in range(0,self.shape.numberValidators): for i in range(0,self.shape.numberNodes):
self.validators[i].logRows() self.validators[i].logRows()
self.validators[i].logColumns() self.validators[i].logColumns()
@ -176,7 +176,7 @@ class Simulator:
(steps, statsTxInSlot[0], statsRxInSlot[0], (steps, statsTxInSlot[0], statsRxInSlot[0],
mean(statsTxInSlot[1:]), max(statsTxInSlot[1:]), mean(statsTxInSlot[1:]), max(statsTxInSlot[1:]),
mean(statsRxInSlot[1:]), max(statsRxInSlot[1:])), extra=self.format) mean(statsRxInSlot[1:]), max(statsRxInSlot[1:])), extra=self.format)
for i in range(0,self.shape.numberValidators): for i in range(0,self.shape.numberNodes):
self.validators[i].updateStats() self.validators[i].updateStats()
arrived, expected = self.glob.checkStatus(self.validators) arrived, expected = self.glob.checkStatus(self.validators)

View File

@ -62,7 +62,7 @@ class Validator:
else: else:
if self.amIproposer: if self.amIproposer:
self.chi = 1 # not used self.chi = 1 # not used
elif self.ID <= shape.numberValidators * shape.class1ratio: elif self.ID <= shape.numberNodes * shape.class1ratio:
self.chi = shape.chi * shape.vpn1 self.chi = shape.chi * shape.vpn1
else: else:
self.chi = shape.chi * shape.vpn2 # TODO: union of random subsets vpn2 times self.chi = shape.chi * shape.vpn2 # TODO: union of random subsets vpn2 times
@ -94,7 +94,7 @@ class Validator:
# TODO: this should be a parameter # TODO: this should be a parameter
if self.amIproposer: if self.amIproposer:
self.bwUplink = shape.bwUplinkProd self.bwUplink = shape.bwUplinkProd
elif self.ID <= shape.numberValidators * shape.class1ratio: elif self.ID <= shape.numberNodes * shape.class1ratio:
self.bwUplink = shape.bwUplink1 self.bwUplink = shape.bwUplink1
else: else:
self.bwUplink = shape.bwUplink2 self.bwUplink = shape.bwUplink2

View File

@ -12,7 +12,7 @@ class Visualizer:
def __init__(self, execID): def __init__(self, execID):
self.execID = execID self.execID = execID
self.folderPath = "results/"+self.execID self.folderPath = "results/"+self.execID
self.parameters = ['run', 'blockSize', 'failureRate', 'numberValidators', 'netDegree', self.parameters = ['run', 'blockSize', 'failureRate', 'numberNodes', 'netDegree',
'chi', 'vpn1', 'vpn2', 'bwUplinkProd', 'bwUplink1', 'bwUplink2'] 'chi', 'vpn1', 'vpn2', 'bwUplinkProd', 'bwUplink1', 'bwUplink2']
self.minimumDataPoints = 2 self.minimumDataPoints = 2
@ -28,7 +28,7 @@ class Visualizer:
run = int(root.find('run').text) run = int(root.find('run').text)
blockSize = int(root.find('blockSize').text) blockSize = int(root.find('blockSize').text)
failureRate = int(root.find('failureRate').text) failureRate = int(root.find('failureRate').text)
numberValidators = int(root.find('numberValidators').text) numberNodes = int(root.find('numberNodes').text)
netDegree = int(root.find('netDegree').text) netDegree = int(root.find('netDegree').text)
chi = int(root.find('chi').text) chi = int(root.find('chi').text)
vpn1 = int(root.find('vpn1').text) vpn1 = int(root.find('vpn1').text)
@ -42,7 +42,7 @@ class Visualizer:
for combination in combinations(self.parameters, 4): for combination in combinations(self.parameters, 4):
# Get the indices and values of the parameters in the combination # Get the indices and values of the parameters in the combination
indices = [self.parameters.index(element) for element in combination] indices = [self.parameters.index(element) for element in combination]
selectedValues = [run, blockSize, failureRate, numberValidators, netDegree, chi, vpn1, vpn2, bwUplinkProd, bwUplink1, bwUplink2] selectedValues = [run, blockSize, failureRate, numberNodes, netDegree, chi, vpn1, vpn2, bwUplinkProd, bwUplink1, bwUplink2]
values = [selectedValues[index] for index in indices] values = [selectedValues[index] for index in indices]
names = [self.parameters[i] for i in indices] names = [self.parameters[i] for i in indices]
keyComponents = [f"{name}_{value}" for name, value in zip(names, values)] keyComponents = [f"{name}_{value}" for name, value in zip(names, values)]

View File

@ -34,7 +34,7 @@ evenLineDistribution = False
runs = range(10) runs = range(10)
# Number of validators # Number of validators
numberValidators = range(256, 513, 128) numberNodes = range(256, 513, 128)
# Percentage of block not released by producer # Percentage of block not released by producer
failureRates = range(10, 91, 40) failureRates = range(10, 91, 40)
@ -68,9 +68,9 @@ deterministic = False
randomSeed = "DAS" randomSeed = "DAS"
def nextShape(): def nextShape():
for run, fr, class1ratio, chi, vpn1, vpn2, blockSize, nv, 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, numberValidators, netDegrees, bwUplinksProd, bwUplinks1, bwUplinks2): runs, failureRates, class1ratios, chis, validatorsPerNode1, validatorsPerNode2, blockSizes, numberNodes, netDegrees, bwUplinksProd, bwUplinks1, bwUplinks2):
# Network Degree has to be an even number # Network Degree has to be an even number
if netDegree % 2 == 0: if netDegree % 2 == 0:
shape = Shape(blockSize, nv, fr, class1ratio, chi, vpn1, vpn2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run) shape = Shape(blockSize, nn, fr, class1ratio, chi, vpn1, vpn2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run)
yield shape yield shape