das-research/study.py

56 lines
2.0 KiB
Python
Raw Normal View History

2022-11-30 14:28:27 +00:00
#! /bin/python3
2023-01-25 20:51:59 +00:00
import time, sys, random, copy
2022-11-30 14:28:27 +00:00
from DAS import *
def study():
if len(sys.argv) < 2:
print("You need to pass a configuration file in parameter")
exit(1)
config = Configuration(sys.argv[1])
2023-01-25 20:51:59 +00:00
shape = Shape(0, 0, 0, 0, 0, 0)
sim = Simulator(shape)
2022-11-30 14:28:27 +00:00
sim.initLogger()
results = []
2022-11-30 14:28:27 +00:00
simCnt = 0
2023-01-25 20:51:59 +00:00
now = datetime.now()
execID = now.strftime("%Y-%m-%d_%H-%M-%S_")+str(random.randint(100,999))
2022-11-30 14:28:27 +00:00
sim.logger.info("Starting simulations:", extra=sim.format)
start = time.time()
for run in range(config.numberRuns):
for fr in range(config.failureRateStart, config.failureRateStop+1, config.failureRateStep):
for chi in range(config.chiStart, config.chiStop+1, config.chiStep):
for blockSize in range(config.blockSizeStart, config.blockSizeStop+1, config.blockSizeStep):
for nv in range(config.nvStart, config.nvStop+1, config.nvStep):
2023-01-26 13:30:56 +00:00
for netDegree in range(config.netDegreeStart, config.netDegreeStop+1, config.netDegreeStep):
if not config.deterministic:
random.seed(datetime.now())
2023-01-25 20:51:59 +00:00
shape = Shape(blockSize, nv, fr, chi, netDegree, run)
sim.resetShape(shape)
sim.initValidators()
sim.initNetwork()
result = sim.run()
2023-01-25 20:51:59 +00:00
sim.logger.info("Shape: %s ... Block Available: %d" % (str(sim.shape.__dict__), result.blockAvailable), extra=sim.format)
results.append(copy.deepcopy(result))
simCnt += 1
2022-11-30 14:28:27 +00:00
end = time.time()
sim.logger.info("A total of %d simulations ran in %d seconds" % (simCnt, end-start), extra=sim.format)
2023-01-25 20:51:59 +00:00
if config.dumpXML:
for res in results:
res.dump(execID)
sim.logger.info("Results dumped into results/%s/" % (execID), extra=sim.format)
2022-11-30 14:28:27 +00:00
study()