-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_01.py
58 lines (50 loc) · 1.83 KB
/
create_01.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import argparse
from sys import stdout
import json5
from numpy.random import normal, choice
from numpy import round
parser = argparse.ArgumentParser('Create random sRND 0-1 circle scenario')
parser.add_argument('size', help='size of the circle', type=int)
parser.add_argument('output', nargs='?', type=argparse.FileType('w'), default=stdout, help='output file (json5)')
# parser.add_argument('-m', '--distance-mean', help='the mean of the distance to 0 for the low and high values', type=float, default=3, dest='v_mean')
# parser.add_argument('-d', '--standard-deviation', help='standard deviation of the low and high values', type=float, default=1, dest='v_dev')
parser.add_argument('-c', '--cost-mean', help='standard mean of the cost values', type=float, default=5, dest='c_mean')
parser.add_argument('-s', '--cost-standard-deviation', help='standard deviation of the cost values', type=float, default=1, dest='c_dev')
args = parser.parse_args()
def create_vertex():
# if choice(2) == 0:
# return {
# 'low': -1,
# 'high': 0
# }
# else:
# return {
# 'low': 0,
# 'high': 1
# }
# values = choice([-1, 0, 1], 2).astype(int).tolist()
# return {
# 'low': min(values),
# 'high': max(values)
# }
a = 0
b = 0
# while a == 0 and b == 0:
while a == b:
vals = choice([-1, 0, 1], 2).astype(int).tolist()
a = min(vals)
b = max(vals)
return {
'low': a,
'high': b
}
def create_cost():
c = 0
while c <= 0:
c = round(normal(args.c_mean, args.c_dev, size=1)).astype(int).tolist()[0]
return c
declaration = {
'vertices': [create_vertex() for _ in range(args.size)],
'edge_costs': [create_cost() for _ in range(args.size)]
}
json5.dump(declaration, args.output, indent=2)