Add some more configuration parameters and some more testing
This commit is contained in:
parent
c3a9eb6b4d
commit
6e42055cb9
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/python3
|
#!/bin/python3
|
||||||
|
|
||||||
import configparser
|
import configparser, logging, sys
|
||||||
|
|
||||||
class Configuration:
|
class Configuration:
|
||||||
"""This class stores all the configuration parameters for the given run."""
|
"""This class stores all the configuration parameters for the given run."""
|
||||||
|
@ -11,39 +11,75 @@ class Configuration:
|
||||||
config = configparser.RawConfigParser()
|
config = configparser.RawConfigParser()
|
||||||
config.read(fileName)
|
config.read(fileName)
|
||||||
|
|
||||||
self.nvStart = int(config.get("Simulation Space", "numberValidatorStart"))
|
try:
|
||||||
self.nvStop = int(config.get("Simulation Space", "numberValidatorStop"))
|
self.nvStart = int(config.get("Simulation Space", "numberValidatorStart"))
|
||||||
self.nvStep = int(config.get("Simulation Space", "numberValidatorStep"))
|
self.nvStop = int(config.get("Simulation Space", "numberValidatorStop"))
|
||||||
|
self.nvStep = int(config.get("Simulation Space", "numberValidatorStep"))
|
||||||
|
|
||||||
self.blockSizeStart = int(config.get("Simulation Space", "blockSizeStart"))
|
self.blockSizeStart = int(config.get("Simulation Space", "blockSizeStart"))
|
||||||
self.blockSizeStop = int(config.get("Simulation Space", "blockSizeStop"))
|
self.blockSizeStop = int(config.get("Simulation Space", "blockSizeStop"))
|
||||||
self.blockSizeStep = int(config.get("Simulation Space", "blockSizeStep"))
|
self.blockSizeStep = int(config.get("Simulation Space", "blockSizeStep"))
|
||||||
|
|
||||||
self.netDegreeStart = int(config.get("Simulation Space", "netDegreeStart"))
|
self.netDegreeStart = int(config.get("Simulation Space", "netDegreeStart"))
|
||||||
self.netDegreeStop = int(config.get("Simulation Space", "netDegreeStop"))
|
self.netDegreeStop = int(config.get("Simulation Space", "netDegreeStop"))
|
||||||
self.netDegreeStep = int(config.get("Simulation Space", "netDegreeStep"))
|
self.netDegreeStep = int(config.get("Simulation Space", "netDegreeStep"))
|
||||||
|
|
||||||
self.failureRateStart = int(config.get("Simulation Space", "failureRateStart"))
|
self.failureRateStart = int(config.get("Simulation Space", "failureRateStart"))
|
||||||
self.failureRateStop = int(config.get("Simulation Space", "failureRateStop"))
|
self.failureRateStop = int(config.get("Simulation Space", "failureRateStop"))
|
||||||
self.failureRateStep = int(config.get("Simulation Space", "failureRateStep"))
|
self.failureRateStep = int(config.get("Simulation Space", "failureRateStep"))
|
||||||
|
|
||||||
self.chiStart = int(config.get("Simulation Space", "chiStart"))
|
self.chiStart = int(config.get("Simulation Space", "chiStart"))
|
||||||
self.chiStop = int(config.get("Simulation Space", "chiStop"))
|
self.chiStop = int(config.get("Simulation Space", "chiStop"))
|
||||||
self.chiStep = int(config.get("Simulation Space", "chiStep"))
|
self.chiStep = int(config.get("Simulation Space", "chiStep"))
|
||||||
|
except:
|
||||||
|
sys.exit("Configuration Error: It seems some of the [Simulation Space] parameters are missing. Cannot continue :( ")
|
||||||
|
|
||||||
self.numberRuns = int(config.get("Advanced", "numberRuns"))
|
|
||||||
self.deterministic = config.get("Advanced", "deterministic")
|
|
||||||
self.dumpXML = config.get("Advanced", "dumpXML")
|
|
||||||
|
|
||||||
if self.nvStop < (self.blockSizeStart*4):
|
|
||||||
print("ERROR: The number of validators cannot be lower than the block size * 4")
|
try:
|
||||||
exit(1)
|
self.numberRuns = int(config.get("Advanced", "numberRuns"))
|
||||||
if self.chiStart < 1:
|
self.deterministic = config.get("Advanced", "deterministic")
|
||||||
print("Chi has to be greater than 0")
|
self.dumpXML = config.get("Advanced", "dumpXML")
|
||||||
exit(1)
|
self.logLevel = config.get("Advanced", "logLevel")
|
||||||
|
self.visualization = config.get("Advanced", "visualization")
|
||||||
|
except:
|
||||||
|
sys.exit("Configuration Error: It seems some of the [Advanced] parameters are missing. Cannot continue :( ")
|
||||||
|
self.test()
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
|
||||||
|
print("Testing configuration...")
|
||||||
|
if self.logLevel == "INFO":
|
||||||
|
self.logLevel = logging.INFO
|
||||||
|
elif self.logLevel == "DEBUG":
|
||||||
|
self.logLevel = logging.DEBUG
|
||||||
|
else:
|
||||||
|
self.logLevel = logging.INFO
|
||||||
|
|
||||||
|
if self.nvStart >= self.nvStop:
|
||||||
|
sys.exit("Configuration Error: numberValidatorStart has to be smaller than numberValidatorStop")
|
||||||
|
|
||||||
|
if self.failureRateStart >= self.failureRateStop:
|
||||||
|
sys.exit("Configuration Error: failureRateStart has to be smaller than failureRateStop")
|
||||||
|
|
||||||
|
if self.blockSizeStart >= self.blockSizeStop:
|
||||||
|
sys.exit("Configuration Error: blockSizeStart has to be smaller than blockSizeStop")
|
||||||
|
|
||||||
|
if self.netDegreeStart >= self.netDegreeStop:
|
||||||
|
sys.exit("Configuration Error: netDegreeStart has to be smaller than netDegreeStop")
|
||||||
|
|
||||||
|
if self.chiStart >= self.chiStop:
|
||||||
|
sys.exit("Configuration Error: chiStart has to be smaller than chiStop")
|
||||||
|
|
||||||
|
|
||||||
|
if self.nvStart < self.blockSizeStop:
|
||||||
|
sys.exit("Configuration Error: numberValidatorStart hast to be larger than blockSizeStop.")
|
||||||
|
|
||||||
|
if self.chiStart < 2:
|
||||||
|
sys.exit("Configuration Error: Chi has to be greater than 1.")
|
||||||
|
|
||||||
if self.chiStop > self.blockSizeStart:
|
if self.chiStop > self.blockSizeStart:
|
||||||
print("Chi (%d) has to be smaller or equal to block the size (%d)" % (self.chiStop, self.blockSizeStart))
|
sys.exit("Configuration Error: Chi (%d) has to be smaller or equal to block the size (%d)" % (self.chiStop, self.blockSizeStart))
|
||||||
exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,14 @@ from DAS.validator import *
|
||||||
class Simulator:
|
class Simulator:
|
||||||
"""This class implements the main DAS simulator."""
|
"""This class implements the main DAS simulator."""
|
||||||
|
|
||||||
def __init__(self, shape):
|
def __init__(self, shape, config):
|
||||||
"""It initializes the simulation with a set of parameters (shape)."""
|
"""It initializes the simulation with a set of parameters (shape)."""
|
||||||
self.shape = shape
|
self.shape = shape
|
||||||
self.format = {"entity": "Simulator"}
|
self.format = {"entity": "Simulator"}
|
||||||
self.result = Result(self.shape)
|
self.result = Result(self.shape)
|
||||||
self.validators = []
|
self.validators = []
|
||||||
self.logger = []
|
self.logger = []
|
||||||
self.logLevel = logging.INFO
|
self.logLevel = config.logLevel
|
||||||
self.proposerID = 0
|
self.proposerID = 0
|
||||||
self.glob = []
|
self.glob = []
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ blockSizeStep = 16
|
||||||
|
|
||||||
netDegreeStart = 6
|
netDegreeStart = 6
|
||||||
netDegreeStop = 8
|
netDegreeStop = 8
|
||||||
netDegreeStep = 1
|
netDegreeStep = 2
|
||||||
|
|
||||||
chiStart = 4
|
chiStart = 4
|
||||||
chiStop = 8
|
chiStop = 8
|
||||||
|
@ -26,3 +26,5 @@ chiStep = 2
|
||||||
deterministic = 0
|
deterministic = 0
|
||||||
numberRuns = 2
|
numberRuns = 2
|
||||||
dumpXML = 1
|
dumpXML = 1
|
||||||
|
visualization = 1
|
||||||
|
logLevel = INFO
|
||||||
|
|
2
study.py
2
study.py
|
@ -11,7 +11,7 @@ def study():
|
||||||
|
|
||||||
config = Configuration(sys.argv[1])
|
config = Configuration(sys.argv[1])
|
||||||
shape = Shape(0, 0, 0, 0, 0, 0)
|
shape = Shape(0, 0, 0, 0, 0, 0)
|
||||||
sim = Simulator(shape)
|
sim = Simulator(shape, config)
|
||||||
sim.initLogger()
|
sim.initLogger()
|
||||||
results = []
|
results = []
|
||||||
simCnt = 0
|
simCnt = 0
|
||||||
|
|
Loading…
Reference in New Issue