diff --git a/DAS/shape.py b/DAS/shape.py index b707e51..484b3eb 100644 --- a/DAS/shape.py +++ b/DAS/shape.py @@ -3,7 +3,7 @@ class Shape: """This class represents a set of parameters for a specific simulation.""" - def __init__(self, blockSize, numberValidators, failureRate, class1ratio, chi1, chi2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run): + def __init__(self, blockSize, numberValidators, 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 @@ -11,8 +11,9 @@ class Shape: self.failureRate = failureRate self.netDegree = netDegree self.class1ratio = class1ratio - self.chi1 = chi1 - self.chi2 = chi2 + self.chi = chi + self.vpn1 = vpn1 + self.vpn2 = vpn2 self.bwUplinkProd = bwUplinkProd self.bwUplink1 = bwUplink1 self.bwUplink2 = bwUplink2 @@ -25,8 +26,9 @@ class Shape: shastr += "-nbv-"+str(self.numberValidators) shastr += "-fr-"+str(self.failureRate) shastr += "-c1r-"+str(self.class1ratio) - shastr += "-chi1-"+str(self.chi1) - shastr += "-chi2-"+str(self.chi2) + shastr += "-chi-"+str(self.chi) + shastr += "-vpn1-"+str(self.vpn1) + shastr += "-vpn2-"+str(self.vpn2) shastr += "-bwupprod-"+str(self.bwUplinkProd) shastr += "-bwup1-"+str(self.bwUplink1) shastr += "-bwup2-"+str(self.bwUplink2) diff --git a/DAS/simulator.py b/DAS/simulator.py index 2d6e635..65f8ef2 100644 --- a/DAS/simulator.py +++ b/DAS/simulator.py @@ -126,8 +126,9 @@ class Simulator: self.result = Result(self.shape) for val in self.validators: val.shape.failureRate = shape.failureRate - val.shape.chi1 = shape.chi1 - val.shape.chi2 = shape.chi2 + val.shape.chi = shape.chi + val.shape.vpn1 = shape.vpn1 + val.shape.vpn2 = shape.vpn2 # In GossipSub the initiator might push messages without participating in the mesh. # proposerPublishOnly regulates this behavior. If set to true, the proposer is not diff --git a/DAS/validator.py b/DAS/validator.py index 71e5791..ae7be43 100644 --- a/DAS/validator.py +++ b/DAS/validator.py @@ -55,17 +55,17 @@ class Validator: self.sendQueue = deque() self.amIproposer = amIproposer self.logger = logger - if self.shape.chi1 < 1 or self.shape.chi2 < 1: + if self.shape.chi < 1: self.logger.error("Chi has to be greater than 0", extra=self.format) - elif self.shape.chi1 > self.shape.blockSize or self.shape.chi2 > self.shape.blockSize: - self.logger.error("Chi has to be smaller than %d" % blockSize, extra=self.format) + elif self.shape.chi > self.shape.blockSize: + self.logger.error("Chi has to be smaller than %d" % self.shape.blockSize, extra=self.format) else: if self.amIproposer: self.chi = 1 # not used elif self.ID <= shape.numberValidators * shape.class1ratio: - self.chi = shape.chi1 + self.chi = shape.chi * shape.vpn1 else: - self.chi = shape.chi2 + self.chi = shape.chi * shape.vpn2 # TODO: union of random subsets vpn2 times if amIproposer: self.rowIDs = range(shape.blockSize) self.columnIDs = range(shape.blockSize) diff --git a/DAS/visualizer.py b/DAS/visualizer.py index e0579e2..7004c87 100644 --- a/DAS/visualizer.py +++ b/DAS/visualizer.py @@ -13,7 +13,7 @@ class Visualizer: self.execID = execID self.folderPath = "results/"+self.execID self.parameters = ['run', 'blockSize', 'failureRate', 'numberValidators', 'netDegree', - 'chi1', 'chi2', 'bwUplinkProd', 'bwUplink1', 'bwUplink2'] + 'chi', 'vpn1', 'vpn2', 'bwUplinkProd', 'bwUplink1', 'bwUplink2'] self.minimumDataPoints = 2 def plottingData(self): @@ -30,8 +30,9 @@ class Visualizer: failureRate = int(root.find('failureRate').text) numberValidators = int(root.find('numberValidators').text) netDegree = int(root.find('netDegree').text) - chi1 = int(root.find('chi1').text) - chi2 = int(root.find('chi2').text) + chi = int(root.find('chi').text) + vpn1 = int(root.find('vpn1').text) + vpn2 = int(root.find('vpn2').text) bwUplinkProd = int(root.find('bwUplinkProd').text) bwUplink1 = int(root.find('bwUplink1').text) bwUplink2 = int(root.find('bwUplink2').text) @@ -41,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, chi1, chi2, bwUplinkProd, bwUplink1, bwUplink2] + selectedValues = [run, blockSize, failureRate, numberValidators, 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 b718528..0bd509c 100644 --- a/config_example.py +++ b/config_example.py @@ -45,11 +45,15 @@ blockSizes = range(32,65,16) # Per-topic mesh neighborhood size netDegrees = range(6, 9, 2) +# number of rows and columns a validator is interested in +chis = range(1, 5, 2) + +# ratio of class1 nodes (see below for parameters per class) class1ratios = np.arange(0, 1, .2) -# Number of rows and columns a validator is interested in -chis1 = range(1, 5, 2) -chis2 = range(10, 30, 20) +# Number of validators per beacon node +validatorsPerNode1 = [1] +validatorsPerNode2 = [2, 4, 8, 16, 32] # Set uplink bandwidth. In segments (~560 bytes) per timestep (50ms?) # 1 Mbps ~= 1e6 / 20 / 8 / 560 ~= 11 @@ -64,9 +68,9 @@ deterministic = False randomSeed = "DAS" def nextShape(): - for run, fr, class1ratio, chi1, chi2, blockSize, nv, netDegree, bwUplinkProd, bwUplink1, bwUplink2 in itertools.product( - runs, failureRates, class1ratios, chis1, chis2, blockSizes, numberValidators, netDegrees, bwUplinksProd, bwUplinks1, bwUplinks2): + 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): # Network Degree has to be an even number if netDegree % 2 == 0: - shape = Shape(blockSize, nv, fr, class1ratio, chi1, chi2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run) + shape = Shape(blockSize, nv, fr, class1ratio, chi, vpn1, vpn2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run) yield shape diff --git a/study.py b/study.py index 3efd83e..2b2aab6 100644 --- a/study.py +++ b/study.py @@ -40,7 +40,7 @@ def study(): print("You need to pass a configuration file in parameter") exit(1) - shape = Shape(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + shape = Shape(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) sim = Simulator(shape, config) sim.initLogger() results = []