handle two dimensions on Chi separately
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com> # Conflicts: # DAS/simulator.py # DAS/validator.py
This commit is contained in:
parent
e18822b8aa
commit
b49be37489
|
@ -3,7 +3,7 @@
|
||||||
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, blockSizeR, blockSizeC, numberNodes, failureModel, failureRate, class1ratio, chi, vpn1, vpn2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run):
|
def __init__(self, blockSizeR, blockSizeC, numberNodes, failureModel, failureRate, class1ratio, chiR, chiC, 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.numberNodes = numberNodes
|
self.numberNodes = numberNodes
|
||||||
|
@ -13,7 +13,8 @@ class Shape:
|
||||||
self.failureRate = failureRate
|
self.failureRate = failureRate
|
||||||
self.netDegree = netDegree
|
self.netDegree = netDegree
|
||||||
self.class1ratio = class1ratio
|
self.class1ratio = class1ratio
|
||||||
self.chi = chi
|
self.chiR = chiR
|
||||||
|
self.chiC = chiC
|
||||||
self.vpn1 = vpn1
|
self.vpn1 = vpn1
|
||||||
self.vpn2 = vpn2
|
self.vpn2 = vpn2
|
||||||
self.bwUplinkProd = bwUplinkProd
|
self.bwUplinkProd = bwUplinkProd
|
||||||
|
@ -30,7 +31,8 @@ class Shape:
|
||||||
shastr += "-fm-"+str(self.failureModel)
|
shastr += "-fm-"+str(self.failureModel)
|
||||||
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 += "-chir-"+str(self.chiR)
|
||||||
|
shastr += "-chic-"+str(self.chiC)
|
||||||
shastr += "-vpn1-"+str(self.vpn1)
|
shastr += "-vpn1-"+str(self.vpn1)
|
||||||
shastr += "-vpn2-"+str(self.vpn2)
|
shastr += "-vpn2-"+str(self.vpn2)
|
||||||
shastr += "-bwupprod-"+str(self.bwUplinkProd)
|
shastr += "-bwupprod-"+str(self.bwUplinkProd)
|
||||||
|
|
|
@ -54,17 +54,20 @@ class Simulator:
|
||||||
lightVal = lightNodes * self.shape.vpn1
|
lightVal = lightNodes * self.shape.vpn1
|
||||||
heavyVal = heavyNodes * self.shape.vpn2
|
heavyVal = heavyNodes * self.shape.vpn2
|
||||||
totalValidators = lightVal + heavyVal
|
totalValidators = lightVal + heavyVal
|
||||||
totalRows = totalValidators * self.shape.chi
|
totalRows = totalValidators * self.shape.chiR
|
||||||
|
totalColumns = totalValidators * self.shape.chiC
|
||||||
rows = list(range(self.shape.blockSizeC)) * (int(totalRows/self.shape.blockSizeC)+1)
|
rows = list(range(self.shape.blockSizeC)) * (int(totalRows/self.shape.blockSizeC)+1)
|
||||||
columns = list(range(self.shape.blockSizeR)) * (int(totalRows/self.shape.blockSizeR)+1)
|
columns = list(range(self.shape.blockSizeR)) * (int(totalColumns/self.shape.blockSizeR)+1)
|
||||||
rows = rows[0:totalRows]
|
rows = rows[0:totalRows]
|
||||||
columns = columns[0:totalRows]
|
columns = columns[0:totalRows]
|
||||||
random.shuffle(rows)
|
random.shuffle(rows)
|
||||||
random.shuffle(columns)
|
random.shuffle(columns)
|
||||||
offset = lightVal*self.shape.chi
|
offsetR = lightVal*self.shape.chiR
|
||||||
|
offsetC = lightVal*self.shape.chiC
|
||||||
self.logger.debug("There is a total of %d nodes, %d light and %d heavy." % (self.shape.numberNodes, lightNodes, heavyNodes), extra=self.format)
|
self.logger.debug("There is a total of %d nodes, %d light and %d heavy." % (self.shape.numberNodes, lightNodes, heavyNodes), extra=self.format)
|
||||||
self.logger.debug("There is a total of %d validators, %d in light nodes and %d in heavy nodes" % (totalValidators, lightVal, heavyVal), extra=self.format)
|
self.logger.debug("There is a total of %d validators, %d in light nodes and %d in heavy nodes" % (totalValidators, lightVal, heavyVal), extra=self.format)
|
||||||
self.logger.debug("Shuffling a total of %d rows/columns to be assigned (X=%d)" % (len(rows), self.shape.chi), extra=self.format)
|
self.logger.debug("Shuffling a total of %d rows to be assigned (X=%d)" % (len(rows), self.shape.chiR), extra=self.format)
|
||||||
|
self.logger.debug("Shuffling a total of %d columns to be assigned (X=%d)" % (len(columns), self.shape.chiC), extra=self.format)
|
||||||
self.logger.debug("Shuffled rows: %s" % str(rows), extra=self.format)
|
self.logger.debug("Shuffled rows: %s" % str(rows), extra=self.format)
|
||||||
self.logger.debug("Shuffled columns: %s" % str(columns), extra=self.format)
|
self.logger.debug("Shuffled columns: %s" % str(columns), extra=self.format)
|
||||||
|
|
||||||
|
@ -73,14 +76,18 @@ class Simulator:
|
||||||
for i in range(self.shape.numberNodes):
|
for i in range(self.shape.numberNodes):
|
||||||
if self.config.evenLineDistribution:
|
if self.config.evenLineDistribution:
|
||||||
if i < int(lightVal/self.shape.vpn1): # First start with the light nodes
|
if i < int(lightVal/self.shape.vpn1): # First start with the light nodes
|
||||||
start = i *self.shape.chi*self.shape.vpn1
|
startR = i *self.shape.chiR*self.shape.vpn1
|
||||||
end = (i+1)*self.shape.chi*self.shape.vpn1
|
endR = (i+1)*self.shape.chiR*self.shape.vpn1
|
||||||
|
startC = i *self.shape.chiC*self.shape.vpn1
|
||||||
|
endC = (i+1)*self.shape.chiC*self.shape.vpn1
|
||||||
else:
|
else:
|
||||||
j = i - int(lightVal/self.shape.vpn1)
|
j = i - int(lightVal/self.shape.vpn1)
|
||||||
start = offset+( j *self.shape.chi*self.shape.vpn2)
|
startR = offsetR+( j *self.shape.chiR*self.shape.vpn2)
|
||||||
end = offset+((j+1)*self.shape.chi*self.shape.vpn2)
|
endR = offsetR+((j+1)*self.shape.chiR*self.shape.vpn2)
|
||||||
r = rows[start:end]
|
startC = offsetC+( j *self.shape.chiC*self.shape.vpn2)
|
||||||
c = columns[start:end]
|
endC = offsetC+((j+1)*self.shape.chiC*self.shape.vpn2)
|
||||||
|
r = rows[startR:endR]
|
||||||
|
c = columns[startC:endC]
|
||||||
val = Validator(i, int(not i!=0), self.logger, self.shape, self.config, r, c)
|
val = Validator(i, int(not i!=0), self.logger, self.shape, self.config, r, c)
|
||||||
self.logger.debug("Node %d has row IDs: %s" % (val.ID, val.rowIDs), extra=self.format)
|
self.logger.debug("Node %d has row IDs: %s" % (val.ID, val.rowIDs), extra=self.format)
|
||||||
self.logger.debug("Node %d has column IDs: %s" % (val.ID, val.columnIDs), extra=self.format)
|
self.logger.debug("Node %d has column IDs: %s" % (val.ID, val.columnIDs), extra=self.format)
|
||||||
|
|
|
@ -42,7 +42,7 @@ class Validator:
|
||||||
"""It initializes the validator with the logger shape and rows/columns.
|
"""It initializes the validator with the logger shape and rows/columns.
|
||||||
|
|
||||||
If rows/columns are specified these are observed, otherwise (default)
|
If rows/columns are specified these are observed, otherwise (default)
|
||||||
chi rows and columns are selected randomly.
|
chiR rows and chiC columns are selected randomly.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.shape = shape
|
self.shape = shape
|
||||||
|
@ -55,12 +55,12 @@ class Validator:
|
||||||
self.sendQueue = deque()
|
self.sendQueue = deque()
|
||||||
self.amIproposer = amIproposer
|
self.amIproposer = amIproposer
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
if self.shape.chi < 1:
|
if self.shape.chiR < 1 and self.shape.chiC < 1:
|
||||||
self.logger.error("Chi has to be greater than 0", extra=self.format)
|
self.logger.error("Chi has to be greater than 0", extra=self.format)
|
||||||
elif self.shape.chi > self.shape.blockSizeR:
|
elif self.shape.chiC > self.shape.blockSizeR:
|
||||||
self.logger.error("Chi has to be smaller than %d" % self.shape.blockSizeR, extra=self.format)
|
self.logger.error("ChiC has to be smaller than %d" % self.shape.blockSizeR, extra=self.format)
|
||||||
elif self.shape.chi > self.shape.blockSizeC:
|
elif self.shape.chiR > self.shape.blockSizeC:
|
||||||
self.logger.error("Chi has to be smaller than %d" % self.shape.blockSizeC, extra=self.format)
|
self.logger.error("ChiR has to be smaller than %d" % self.shape.blockSizeC, extra=self.format)
|
||||||
else:
|
else:
|
||||||
if amIproposer:
|
if amIproposer:
|
||||||
self.nodeClass = 0
|
self.nodeClass = 0
|
||||||
|
@ -74,8 +74,8 @@ class Validator:
|
||||||
self.vRowIDs = []
|
self.vRowIDs = []
|
||||||
self.vColumnIDs = []
|
self.vColumnIDs = []
|
||||||
for i in range(self.vpn):
|
for i in range(self.vpn):
|
||||||
self.vRowIDs.append(set(rows[i*self.shape.chi:(i+1)*self.shape.chi]) if rows else set(random.sample(range(self.shape.blockSizeC), self.shape.chi)))
|
self.vRowIDs.append(set(rows[i*self.shape.chiR:(i+1)*self.shape.chiR]) if rows else set(random.sample(range(self.shape.blockSizeC), self.shape.chiR)))
|
||||||
self.vColumnIDs.append(set(columns[i*self.shape.chi:(i+1)*self.shape.chi]) if columns else set(random.sample(range(self.shape.blockSizeR), self.shape.chi)))
|
self.vColumnIDs.append(set(columns[i*self.shape.chiC:(i+1)*self.shape.chiC]) if columns else set(random.sample(range(self.shape.blockSizeR), self.shape.chiC)))
|
||||||
self.rowIDs = set.union(*self.vRowIDs)
|
self.rowIDs = set.union(*self.vRowIDs)
|
||||||
self.columnIDs = set.union(*self.vColumnIDs)
|
self.columnIDs = set.union(*self.vColumnIDs)
|
||||||
self.rowNeighbors = collections.defaultdict(dict)
|
self.rowNeighbors = collections.defaultdict(dict)
|
||||||
|
|
Loading…
Reference in New Issue