-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimulate.py
executable file
·38 lines (32 loc) · 1.04 KB
/
simulate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python
import sys
import re
import logging
from optparse import OptionParser
from math import sqrt
import json
import re
import random
from BasicRappor import BasicRappor
from RandomX import RandomX
from User import User
from Simulator import simulate
def read_args():
parser = OptionParser()
parser.add_option("-c", "--config", dest="config", help="simulation config file")
parser.add_option("-p", "--param", dest="params", help="override config params")
parser.add_option("-s", "--save", dest="save", action="store_true", default=False, help="save simulated sample")
return parser.parse_args()
def setOverides(config, paramsString):
if (paramsString == False):
return
params = re.split(",", paramsString);
for param in params:
(key, val) = re.split("=", param)
config[key] = float(val)
if __name__ == '__main__':
(options, args) = read_args()
config = json.load(open(options.config,"r"));
setOverides(config, options.params or False)
config["save"] = options.save
simulate(config)