change config language to simple (or complex) code
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
37ff89bd82
commit
4a4f02427c
|
@ -0,0 +1,53 @@
|
|||
"""Example configuration file
|
||||
|
||||
This file illustrates how to define options and simulation parameter ranges.
|
||||
It also defines the traversal order of the simulation space. As the file
|
||||
extension suggests, configuration is pure python code, allowing complex
|
||||
setups. Use at your own risk.
|
||||
|
||||
To use this example, run
|
||||
python3 study.py config_example
|
||||
|
||||
Otherwise copy it and modify as needed. The default traversal order defined
|
||||
in the nested loop of nextShape() is good for most cases, but customizable
|
||||
if needed.
|
||||
"""
|
||||
|
||||
import logging
|
||||
from DAS.shape import Shape
|
||||
|
||||
dumpXML = 1
|
||||
visualization = 1
|
||||
logLevel = logging.INFO
|
||||
|
||||
# Number of simulation runs with the same parameters for statistical relevance
|
||||
runs = range(10)
|
||||
|
||||
# Number of validators
|
||||
numberValidators = range(256, 513, 128)
|
||||
|
||||
# Percentage of block not released by producer
|
||||
failureRates = range(10, 91, 40)
|
||||
|
||||
# Block size in one dimension in segments. Block is blockSizes * blockSizes segments.
|
||||
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
|
||||
chis = range(4, 9, 2)
|
||||
|
||||
deterministic = False
|
||||
|
||||
def nextShape():
|
||||
for run in runs:
|
||||
for fr in failureRates:
|
||||
for chi in chis:
|
||||
for blockSize in blockSizes:
|
||||
for nv in numberValidators:
|
||||
for netDegree in netDegrees:
|
||||
# Network Degree has to be an even number
|
||||
if netDegree % 2 == 0:
|
||||
shape = Shape(blockSize, nv, fr, chi, netDegree, run)
|
||||
yield shape
|
14
study.py
14
study.py
|
@ -1,6 +1,7 @@
|
|||
#! /bin/python3
|
||||
|
||||
import time, sys, random, copy
|
||||
import importlib
|
||||
from DAS import *
|
||||
|
||||
|
||||
|
@ -9,7 +10,7 @@ def study():
|
|||
print("You need to pass a configuration file in parameter")
|
||||
exit(1)
|
||||
|
||||
config = Configuration(sys.argv[1])
|
||||
config = importlib.import_module(sys.argv[1])
|
||||
shape = Shape(0, 0, 0, 0, 0, 0)
|
||||
sim = Simulator(shape, config)
|
||||
sim.initLogger()
|
||||
|
@ -22,19 +23,10 @@ def study():
|
|||
sim.logger.info("Starting simulations:", extra=sim.format)
|
||||
start = time.time()
|
||||
|
||||
for run in range(config.numberRuns):
|
||||
for nv in range(config.nvStart, config.nvStop+1, config.nvStep):
|
||||
for blockSize in range(config.blockSizeStart, config.blockSizeStop+1, config.blockSizeStep):
|
||||
for fr in range(config.failureRateStart, config.failureRateStop+1, config.failureRateStep):
|
||||
for netDegree in range(config.netDegreeStart, config.netDegreeStop+1, config.netDegreeStep):
|
||||
for chi in range(config.chiStart, config.chiStop+1, config.chiStep):
|
||||
|
||||
for shape in config.nextShape():
|
||||
if not config.deterministic:
|
||||
random.seed(datetime.now())
|
||||
|
||||
# Network Degree has to be an even number
|
||||
if netDegree % 2 == 0:
|
||||
shape = Shape(blockSize, nv, fr, chi, netDegree, run)
|
||||
sim.resetShape(shape)
|
||||
sim.initValidators()
|
||||
sim.initNetwork()
|
||||
|
|
Loading…
Reference in New Issue