From 9d9612fd34dbdee32f398f5c8be03e48b8708248 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Mon, 13 Mar 2023 15:03:55 +0100 Subject: [PATCH] rename numberValidators to numberNodes Signed-off-by: Csaba Kiraly --- DAS/shape.py | 6 +++--- DAS/simulator.py | 18 +++++++++--------- DAS/validator.py | 4 ++-- DAS/visualizer.py | 6 +++--- config_example.py | 8 ++++---- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/DAS/shape.py b/DAS/shape.py index 484b3eb..d83351d 100644 --- a/DAS/shape.py +++ b/DAS/shape.py @@ -3,10 +3,10 @@ class Shape: """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.""" self.run = run - self.numberValidators = numberValidators + self.numberNodes = numberNodes self.blockSize = blockSize self.failureRate = failureRate self.netDegree = netDegree @@ -23,7 +23,7 @@ class Shape: """Returns a printable representation of the shape""" shastr = "" shastr += "bs-"+str(self.blockSize) - shastr += "-nbv-"+str(self.numberValidators) + shastr += "-nn-"+str(self.numberNodes) shastr += "-fr-"+str(self.failureRate) shastr += "-c1r-"+str(self.class1ratio) shastr += "-chi-"+str(self.chi) diff --git a/DAS/simulator.py b/DAS/simulator.py index 65f8ef2..4cadf9f 100644 --- a/DAS/simulator.py +++ b/DAS/simulator.py @@ -30,11 +30,11 @@ class Simulator: self.glob.reset() self.validators = [] if self.config.evenLineDistribution: - rows = 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.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.numberNodes/self.shape.blockSize) random.shuffle(rows) random.shuffle(columns) - for i in range(self.shape.numberValidators): + for i in range(self.shape.numberNodes): if self.config.evenLineDistribution: val = Validator(i, int(not i!=0), self.logger, self.shape, 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)}) 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 : colN %s", i, self.validators[i].columnNeighbors, extra=self.format) @@ -155,17 +155,17 @@ class Simulator: missingVector.append(missingSamples) oldMissingSamples = missingSamples 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.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.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].restoreColumns() 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].logColumns() @@ -176,7 +176,7 @@ class Simulator: (steps, statsTxInSlot[0], statsRxInSlot[0], mean(statsTxInSlot[1:]), max(statsTxInSlot[1:]), 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() arrived, expected = self.glob.checkStatus(self.validators) diff --git a/DAS/validator.py b/DAS/validator.py index ae7be43..b0fbede 100644 --- a/DAS/validator.py +++ b/DAS/validator.py @@ -62,7 +62,7 @@ class Validator: else: if self.amIproposer: 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 else: 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 if self.amIproposer: self.bwUplink = shape.bwUplinkProd - elif self.ID <= shape.numberValidators * shape.class1ratio: + elif self.ID <= shape.numberNodes * shape.class1ratio: self.bwUplink = shape.bwUplink1 else: self.bwUplink = shape.bwUplink2 diff --git a/DAS/visualizer.py b/DAS/visualizer.py index 7004c87..d165f0d 100644 --- a/DAS/visualizer.py +++ b/DAS/visualizer.py @@ -12,7 +12,7 @@ class Visualizer: def __init__(self, execID): self.execID = 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'] self.minimumDataPoints = 2 @@ -28,7 +28,7 @@ class Visualizer: run = int(root.find('run').text) blockSize = int(root.find('blockSize').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) chi = int(root.find('chi').text) vpn1 = int(root.find('vpn1').text) @@ -42,7 +42,7 @@ class Visualizer: for combination in combinations(self.parameters, 4): # Get the indices and values of the parameters in the 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] names = [self.parameters[i] for i in indices] keyComponents = [f"{name}_{value}" for name, value in zip(names, values)] diff --git a/config_example.py b/config_example.py index 0bd509c..5272555 100644 --- a/config_example.py +++ b/config_example.py @@ -34,7 +34,7 @@ evenLineDistribution = False runs = range(10) # Number of validators -numberValidators = range(256, 513, 128) +numberNodes = range(256, 513, 128) # Percentage of block not released by producer failureRates = range(10, 91, 40) @@ -68,9 +68,9 @@ deterministic = False randomSeed = "DAS" def nextShape(): - for run, fr, class1ratio, chi, vpn1, vpn2, blockSize, nv, netDegree, bwUplinkProd, bwUplink1, bwUplink2 in itertools.product( - runs, failureRates, class1ratios, chis, validatorsPerNode1, validatorsPerNode2, blockSizes, numberValidators, netDegrees, bwUplinksProd, bwUplinks1, bwUplinks2): + 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): # Network Degree has to be an even number 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