minimum custody feature added

This commit is contained in:
Sudipta Basak 2024-06-18 19:51:00 +00:00
parent 4dc4f3a32a
commit 11d31d7350
No known key found for this signature in database
3 changed files with 12 additions and 6 deletions

View File

@ -98,13 +98,13 @@ class Node:
self.logger.warning("Row custody (*vpn) larger than number of rows!", extra=self.format) self.logger.warning("Row custody (*vpn) larger than number of rows!", extra=self.format)
self.rowIDs = range(self.shape.nbRows) self.rowIDs = range(self.shape.nbRows)
else: else:
self.rowIDs = set(random.sample(range(self.shape.nbRows), self.vpn*self.shape.custodyRows)) self.rowIDs = set(random.sample(range(self.shape.nbRows), max(self.vpn*self.shape.custodyRows, self.shape.minCustodyRows)))
if (self.vpn * self.shape.custodyCols) > self.shape.nbCols: if (self.vpn * self.shape.custodyCols) > self.shape.nbCols:
self.logger.warning("Column custody (*vpn) larger than number of columns!", extra=self.format) self.logger.warning("Column custody (*vpn) larger than number of columns!", extra=self.format)
self.columnIDs = range(self.shape.nbCols) self.columnIDs = range(self.shape.nbCols)
else: else:
self.columnIDs = set(random.sample(range(self.shape.nbCols), self.vpn*self.shape.custodyCols)) self.columnIDs = set(random.sample(range(self.shape.nbCols), max(self.vpn*self.shape.custodyCols, self.shape.minCustodyCols)))
self.rowNeighbors = collections.defaultdict(dict) self.rowNeighbors = collections.defaultdict(dict)
self.columnNeighbors = collections.defaultdict(dict) self.columnNeighbors = collections.defaultdict(dict)

View File

@ -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, nbCols, nbColsK, nbRows, nbRowsK, def __init__(self, nbCols, nbColsK, nbRows, nbRowsK,
numberNodes, failureModel, failureRate, maliciousNodes, custodyRows, custodyCols, netDegree, bwUplinkProd, run, nodeTypes): numberNodes, failureModel, failureRate, maliciousNodes, custodyRows, custodyCols, minCustodyRows, minCustodyCols, netDegree, bwUplinkProd, run, nodeTypes):
"""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
@ -17,6 +17,8 @@ class Shape:
self.netDegree = netDegree self.netDegree = netDegree
self.custodyRows = custodyRows self.custodyRows = custodyRows
self.custodyCols = custodyCols self.custodyCols = custodyCols
self.minCustodyRows = minCustodyRows
self.minCustodyCols = minCustodyCols
self.bwUplinkProd = bwUplinkProd self.bwUplinkProd = bwUplinkProd
self.nodeTypes = nodeTypes self.nodeTypes = nodeTypes
self.nodeClasses = [0] + [_k for _k in nodeTypes["classes"].keys()] self.nodeClasses = [0] + [_k for _k in nodeTypes["classes"].keys()]
@ -34,6 +36,8 @@ class Shape:
shastr += "-fr-"+str(self.failureRate) shastr += "-fr-"+str(self.failureRate)
shastr += "-cusr-"+str(self.custodyRows) shastr += "-cusr-"+str(self.custodyRows)
shastr += "-cusc-"+str(self.custodyCols) shastr += "-cusc-"+str(self.custodyCols)
shastr += "-mcusr-"+str(self.minCustodyRows)
shastr += "-mcusc-"+str(self.minCustodyCols)
shastr += "-bwupprod-"+str(self.bwUplinkProd) shastr += "-bwupprod-"+str(self.bwUplinkProd)
shastr += "-nd-"+str(self.netDegree) shastr += "-nd-"+str(self.netDegree)
shastr += "-r-"+str(self.run) shastr += "-r-"+str(self.run)

View File

@ -76,6 +76,8 @@ proposerPublishToC = "shape.netDegree"
validatorBasedCustody = False validatorBasedCustody = False
custodyRows = range(2, 3, 2) custodyRows = range(2, 3, 2)
custodyCols = range(2, 3, 2) custodyCols = range(2, 3, 2)
minCustodyRows = range(2, 3, 2)
minCustodyCols = range(2, 3, 2)
# Set uplink bandwidth in megabits/second # Set uplink bandwidth in megabits/second
bwUplinksProd = [200] bwUplinksProd = [200]
@ -146,11 +148,11 @@ colsK = range(32, 65, 128)
rowsK = range(32, 65, 128) rowsK = range(32, 65, 128)
def nextShape(): def nextShape():
for nbCols, nbColsK, nbRows, nbRowsK, run, fm, fr, mn, chR, chC, nn, netDegree, bwUplinkProd, nodeTypes in itertools.product( for nbCols, nbColsK, nbRows, nbRowsK, run, fm, fr, mn, chR, chC, minChR, minChC, nn, netDegree, bwUplinkProd, nodeTypes in itertools.product(
cols, colsK, rows, rowsK, runs, failureModels, failureRates, maliciousNodes, custodyRows, custodyCols, numberNodes, netDegrees, bwUplinksProd, nodeTypesGroup): cols, colsK, rows, rowsK, runs, failureModels, failureRates, maliciousNodes, custodyRows, custodyCols, minCustodyRows, minCustodyCols, numberNodes, netDegrees, bwUplinksProd, nodeTypesGroup):
# 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(nbCols, nbColsK, nbRows, nbRowsK, nn, fm, fr, mn, chR, chC, netDegree, bwUplinkProd, run, nodeTypes) shape = Shape(nbCols, nbColsK, nbRows, nbRowsK, nn, fm, fr, mn, chR, chC, minChR, minChC, netDegree, bwUplinkProd, run, nodeTypes)
yield shape yield shape
def evalConf(self, param, shape = None): def evalConf(self, param, shape = None):