mirror of
https://github.com/logos-storage/das-research.git
synced 2026-01-07 15:43:08 +00:00
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:
|
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, 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."""
|
"""Initializes the shape with the parameters passed in argument."""
|
||||||
self.run = run
|
self.run = run
|
||||||
self.numberValidators = numberValidators
|
self.numberValidators = numberValidators
|
||||||
self.blockSize = blockSize
|
self.blockSize = blockSize
|
||||||
self.failureRate = failureRate
|
self.failureRate = failureRate
|
||||||
self.netDegree = netDegree
|
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.randomSeed = ""
|
||||||
self.bwUplink = bwUplink
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""Returns a printable representation of the shape"""
|
"""Returns a printable representation of the shape"""
|
||||||
@ -20,8 +24,12 @@ class Shape:
|
|||||||
shastr += "bs-"+str(self.blockSize)
|
shastr += "bs-"+str(self.blockSize)
|
||||||
shastr += "-nbv-"+str(self.numberValidators)
|
shastr += "-nbv-"+str(self.numberValidators)
|
||||||
shastr += "-fr-"+str(self.failureRate)
|
shastr += "-fr-"+str(self.failureRate)
|
||||||
shastr += "-chi-"+str(self.chi)
|
shastr += "-c1r-"+str(self.class1ratio)
|
||||||
shastr += "-bwu-"+str(self.bwUplink)
|
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 += "-nd-"+str(self.netDegree)
|
||||||
shastr += "-r-"+str(self.run)
|
shastr += "-r-"+str(self.run)
|
||||||
return shastr
|
return shastr
|
||||||
|
|||||||
@ -126,7 +126,8 @@ class Simulator:
|
|||||||
self.result = Result(self.shape)
|
self.result = Result(self.shape)
|
||||||
for val in self.validators:
|
for val in self.validators:
|
||||||
val.shape.failureRate = shape.failureRate
|
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.
|
# In GossipSub the initiator might push messages without participating in the mesh.
|
||||||
# proposerPublishOnly regulates this behavior. If set to true, the proposer is not
|
# proposerPublishOnly regulates this behavior. If set to true, the proposer is not
|
||||||
|
|||||||
@ -55,11 +55,17 @@ 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.chi1 < 1 or self.shape.chi2 < 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.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)
|
self.logger.error("Chi has to be smaller than %d" % blockSize, extra=self.format)
|
||||||
else:
|
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:
|
if amIproposer:
|
||||||
self.rowIDs = range(shape.blockSize)
|
self.rowIDs = range(shape.blockSize)
|
||||||
self.columnIDs = range(shape.blockSize)
|
self.columnIDs = range(shape.blockSize)
|
||||||
@ -69,11 +75,11 @@ class Validator:
|
|||||||
if rows:
|
if rows:
|
||||||
self.rowIDs = rows
|
self.rowIDs = rows
|
||||||
else:
|
else:
|
||||||
self.rowIDs = random.sample(range(self.shape.blockSize), self.shape.chi)
|
self.rowIDs = random.sample(range(self.shape.blockSize), self.chi)
|
||||||
if columns:
|
if columns:
|
||||||
self.columnIDs = columns
|
self.columnIDs = columns
|
||||||
else:
|
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.rowNeighbors = collections.defaultdict(dict)
|
||||||
self.columnNeighbors = collections.defaultdict(dict)
|
self.columnNeighbors = collections.defaultdict(dict)
|
||||||
|
|
||||||
@ -86,7 +92,12 @@ class Validator:
|
|||||||
# Set uplink bandwidth. In segments (~560 bytes) per timestep (50ms?)
|
# Set uplink bandwidth. In segments (~560 bytes) per timestep (50ms?)
|
||||||
# 1 Mbps ~= 1e6 / 20 / 8 / 560 ~= 11
|
# 1 Mbps ~= 1e6 / 20 / 8 / 560 ~= 11
|
||||||
# TODO: this should be a parameter
|
# 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.repairOnTheFly = True
|
||||||
self.sendLineUntil = (self.shape.blockSize + 1) // 2 # stop sending on a p2p link if at least this amount of samples passed
|
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 logging
|
||||||
import itertools
|
import itertools
|
||||||
|
import numpy as np
|
||||||
from DAS.shape import Shape
|
from DAS.shape import Shape
|
||||||
|
|
||||||
dumpXML = 1
|
dumpXML = 1
|
||||||
@ -44,12 +45,17 @@ blockSizes = range(32,65,16)
|
|||||||
# Per-topic mesh neighborhood size
|
# Per-topic mesh neighborhood size
|
||||||
netDegrees = range(6, 9, 2)
|
netDegrees = range(6, 9, 2)
|
||||||
|
|
||||||
|
class1ratios = np.arange(0, 1, .2)
|
||||||
|
|
||||||
# Number of rows and columns a validator is interested in
|
# 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?)
|
# Set uplink bandwidth. In segments (~560 bytes) per timestep (50ms?)
|
||||||
# 1 Mbps ~= 1e6 / 20 / 8 / 560 ~= 11
|
# 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
|
# Set to True if you want your run to be deterministic, False if not
|
||||||
deterministic = False
|
deterministic = False
|
||||||
@ -58,9 +64,9 @@ deterministic = False
|
|||||||
randomSeed = "DAS"
|
randomSeed = "DAS"
|
||||||
|
|
||||||
def nextShape():
|
def nextShape():
|
||||||
for run, fr, chi, blockSize, nv, netDegree, bwUplink in itertools.product(
|
for run, fr, class1ratio, chi1, chi2, blockSize, nv, netDegree, bwUplinkProd, bwUplink1, bwUplink2 in itertools.product(
|
||||||
runs, failureRates, chis, blockSizes, numberValidators, netDegrees, bwUplinks):
|
runs, failureRates, class1ratios, chis1, chis2, blockSizes, numberValidators, netDegrees, bwUplinksProd, bwUplinks1, bwUplinks2):
|
||||||
# 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(blockSize, nv, fr, chi, netDegree, bwUplink, run)
|
shape = Shape(blockSize, nv, fr, class1ratio, chi1, chi2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run)
|
||||||
yield shape
|
yield shape
|
||||||
|
|||||||
2
study.py
2
study.py
@ -40,7 +40,7 @@ def study():
|
|||||||
print("You need to pass a configuration file in parameter")
|
print("You need to pass a configuration file in parameter")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
shape = Shape(0, 0, 0, 0, 0, 0, 0)
|
shape = Shape(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
sim = Simulator(shape, config)
|
sim = Simulator(shape, config)
|
||||||
sim.initLogger()
|
sim.initLogger()
|
||||||
results = []
|
results = []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user