diff --git a/DAS/requirements.txt b/DAS/requirements.txt index d0bb457..da7dcc7 100644 --- a/DAS/requirements.txt +++ b/DAS/requirements.txt @@ -1,3 +1,7 @@ bitarray==2.6.0 -DAS==0.28.7 +DAS==0.29.0 +dicttoxml==1.7.16 +matplotlib==3.6.2 networkx==3.0 +numpy==1.23.5 +seaborn==0.12.2 diff --git a/DAS/results.py b/DAS/results.py index e20cdec..0efe26d 100644 --- a/DAS/results.py +++ b/DAS/results.py @@ -39,11 +39,6 @@ class Result: resXml = dicttoxml(resd1) xmlstr = minidom.parseString(resXml) xmlPretty = xmlstr.toprettyxml() - filePath = "results/"+execID+"/nbv-"+str(self.shape.numberValidators)+\ - "-bs-"+str(self.shape.blockSize)+\ - "-nd-"+str(self.shape.netDegree)+\ - "-fr-"+str(self.shape.failureRate)+\ - "-chi-"+str(self.shape.chi)+\ - "-r-"+str(self.shape.run)+".xml" + filePath = "results/"+execID+"/"+str(self.shape)+".xml" with open(filePath, "w") as f: f.write(xmlPretty) diff --git a/DAS/shape.py b/DAS/shape.py index 2f99ebf..1dd19b2 100644 --- a/DAS/shape.py +++ b/DAS/shape.py @@ -11,7 +11,20 @@ class Shape: self.failureRate = failureRate self.netDegree = netDegree self.chi = chi + self.randomSeed = "" + def __repr__(self): + """Returns a printable representation of the shape""" + shastr = "" + shastr += "bs-"+str(self.blockSize) + shastr += "-nbv-"+str(self.numberValidators) + shastr += "-fr-"+str(self.failureRate) + shastr += "-chi-"+str(self.chi) + shastr += "-nd-"+str(self.netDegree) + shastr += "-r-"+str(self.run) + return shastr - + def setSeed(self, seed): + """Adds the random seed to the shape""" + self.randomSeed = seed diff --git a/config_example.py b/config_example.py index c2f7fcf..248a8e9 100644 --- a/config_example.py +++ b/config_example.py @@ -39,11 +39,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 +# Number of rows and columns a validator is interested in chis = range(4, 9, 2) +# Set to True if you want your run to be deterministic, False if not deterministic = False +# If your run is deterministic you can decide the random seed. This is ignore otherwise. +randomSeed = "DAS" + def nextShape(): for run in runs: for fr in failureRates: diff --git a/study.py b/study.py index f557fc2..e24fb46 100644 --- a/study.py +++ b/study.py @@ -13,8 +13,9 @@ from DAS import * # and https://github.com/joblib/joblib/issues/1017 def runOnce(sim, config, shape): - if not config.deterministic: - random.seed(datetime.now()) + if config.deterministic: + shape.setSeed(config.randomSeed+"-"+str(shape)) + random.seed(shape.randomSeed) sim.initLogger() sim.resetShape(shape) @@ -49,10 +50,7 @@ def study(): sim.logger.info("Starting simulations:", extra=sim.format) start = time.time() - results = Parallel(config.numJobs)(delayed(runOnce)(sim, config, shape) for shape in config.nextShape()) - - end = time.time() sim.logger.info("A total of %d simulations ran in %d seconds" % (len(results), end-start), extra=sim.format) @@ -61,8 +59,7 @@ def study(): res.dump(execID) sim.logger.info("Results dumped into results/%s/" % (execID), extra=sim.format) - visualization = 1 - if visualization: + if config.visualization: vis = Visualizer(execID) vis.plotHeatmaps()