introduce node classes
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
49b1c239d7
commit
ef4e32ed53
18
DAS/shape.py
18
DAS/shape.py
|
@ -3,16 +3,20 @@
|
|||
class Shape:
|
||||
"""This class represents a set of parameters for a specific simulation."""
|
||||
|
||||
def __init__(self, blockSize, numberValidators, failureRate, chi, netDegree, bwUplink, run):
|
||||
def __init__(self, blockSize, numberValidators, failureRate, class1ratio, chi1, chi2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run):
|
||||
"""Initializes the shape with the parameters passed in argument."""
|
||||
self.run = run
|
||||
self.numberValidators = numberValidators
|
||||
self.blockSize = blockSize
|
||||
self.failureRate = failureRate
|
||||
self.netDegree = netDegree
|
||||
self.chi = chi
|
||||
self.class1ratio = class1ratio
|
||||
self.chi1 = chi1
|
||||
self.chi2 = chi2
|
||||
self.bwUplinkProd = bwUplinkProd
|
||||
self.bwUplink1 = bwUplink1
|
||||
self.bwUplink2 = bwUplink2
|
||||
self.randomSeed = ""
|
||||
self.bwUplink = bwUplink
|
||||
|
||||
def __repr__(self):
|
||||
"""Returns a printable representation of the shape"""
|
||||
|
@ -20,8 +24,12 @@ class Shape:
|
|||
shastr += "bs-"+str(self.blockSize)
|
||||
shastr += "-nbv-"+str(self.numberValidators)
|
||||
shastr += "-fr-"+str(self.failureRate)
|
||||
shastr += "-chi-"+str(self.chi)
|
||||
shastr += "-bwu-"+str(self.bwUplink)
|
||||
shastr += "-c1r-"+str(self.class1ratio)
|
||||
shastr += "-chi1-"+str(self.chi1)
|
||||
shastr += "-chi2-"+str(self.chi2)
|
||||
shastr += "-bwupprod-"+str(self.bwUplinkProd)
|
||||
shastr += "-bwup1-"+str(self.bwUplink1)
|
||||
shastr += "-bwup2-"+str(self.bwUplink2)
|
||||
shastr += "-nd-"+str(self.netDegree)
|
||||
shastr += "-r-"+str(self.run)
|
||||
return shastr
|
||||
|
|
|
@ -126,7 +126,8 @@ class Simulator:
|
|||
self.result = Result(self.shape)
|
||||
for val in self.validators:
|
||||
val.shape.failureRate = shape.failureRate
|
||||
val.shape.chi = shape.chi
|
||||
val.shape.chi1 = shape.chi1
|
||||
val.shape.chi2 = shape.chi2
|
||||
|
||||
# In GossipSub the initiator might push messages without participating in the mesh.
|
||||
# proposerPublishOnly regulates this behavior. If set to true, the proposer is not
|
||||
|
|
|
@ -55,11 +55,17 @@ class Validator:
|
|||
self.sendQueue = deque()
|
||||
self.amIproposer = amIproposer
|
||||
self.logger = logger
|
||||
if self.shape.chi < 1:
|
||||
if self.shape.chi1 < 1 or self.shape.chi2 < 1:
|
||||
self.logger.error("Chi has to be greater than 0", extra=self.format)
|
||||
elif self.shape.chi > self.shape.blockSize:
|
||||
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)
|
||||
else:
|
||||
if self.amIproposer:
|
||||
self.chi = 1 # not used
|
||||
elif self.ID <= shape.numberValidators * shape.class1ratio:
|
||||
self.chi = shape.chi1
|
||||
else:
|
||||
self.chi = shape.chi2
|
||||
if amIproposer:
|
||||
self.rowIDs = range(shape.blockSize)
|
||||
self.columnIDs = range(shape.blockSize)
|
||||
|
@ -69,11 +75,11 @@ class Validator:
|
|||
if rows:
|
||||
self.rowIDs = rows
|
||||
else:
|
||||
self.rowIDs = random.sample(range(self.shape.blockSize), self.shape.chi)
|
||||
self.rowIDs = random.sample(range(self.shape.blockSize), self.chi)
|
||||
if columns:
|
||||
self.columnIDs = columns
|
||||
else:
|
||||
self.columnIDs = random.sample(range(self.shape.blockSize), self.shape.chi)
|
||||
self.columnIDs = random.sample(range(self.shape.blockSize), self.chi)
|
||||
self.rowNeighbors = collections.defaultdict(dict)
|
||||
self.columnNeighbors = collections.defaultdict(dict)
|
||||
|
||||
|
@ -86,7 +92,12 @@ class Validator:
|
|||
# Set uplink bandwidth. In segments (~560 bytes) per timestep (50ms?)
|
||||
# 1 Mbps ~= 1e6 / 20 / 8 / 560 ~= 11
|
||||
# TODO: this should be a parameter
|
||||
self.bwUplink = shape.bwUplink if not self.amIproposer else 2200 # approx. 10Mbps and 200Mbps
|
||||
if self.amIproposer:
|
||||
self.bwUplink = shape.bwUplinkProd
|
||||
elif self.ID <= shape.numberValidators * shape.class1ratio:
|
||||
self.bwUplink = shape.bwUplink1
|
||||
else:
|
||||
self.bwUplink = shape.bwUplink2
|
||||
|
||||
self.repairOnTheFly = True
|
||||
self.sendLineUntil = (self.shape.blockSize + 1) // 2 # stop sending on a p2p link if at least this amount of samples passed
|
||||
|
|
|
@ -15,6 +15,7 @@ if needed.
|
|||
|
||||
import logging
|
||||
import itertools
|
||||
import numpy as np
|
||||
from DAS.shape import Shape
|
||||
|
||||
dumpXML = 1
|
||||
|
@ -44,12 +45,17 @@ blockSizes = range(32,65,16)
|
|||
# Per-topic mesh neighborhood size
|
||||
netDegrees = range(6, 9, 2)
|
||||
|
||||
class1ratios = np.arange(0, 1, .2)
|
||||
|
||||
# Number of rows and columns a validator is interested in
|
||||
chis = range(4, 9, 2)
|
||||
chis1 = range(1, 5, 2)
|
||||
chis2 = range(10, 30, 20)
|
||||
|
||||
# Set uplink bandwidth. In segments (~560 bytes) per timestep (50ms?)
|
||||
# 1 Mbps ~= 1e6 / 20 / 8 / 560 ~= 11
|
||||
bwUplinks = [11, 110]
|
||||
bwUplinksProd = [2200]
|
||||
bwUplinks1 = [2200]
|
||||
bwUplinks2 = [110]
|
||||
|
||||
# Set to True if you want your run to be deterministic, False if not
|
||||
deterministic = False
|
||||
|
@ -58,9 +64,9 @@ deterministic = False
|
|||
randomSeed = "DAS"
|
||||
|
||||
def nextShape():
|
||||
for run, fr, chi, blockSize, nv, netDegree, bwUplink in itertools.product(
|
||||
runs, failureRates, chis, blockSizes, numberValidators, netDegrees, bwUplinks):
|
||||
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):
|
||||
# Network Degree has to be an even number
|
||||
if netDegree % 2 == 0:
|
||||
shape = Shape(blockSize, nv, fr, chi, netDegree, bwUplink, run)
|
||||
shape = Shape(blockSize, nv, fr, class1ratio, chi1, chi2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run)
|
||||
yield shape
|
||||
|
|
Loading…
Reference in New Issue