s = ""
variables = set()
- # We take length itself half of the time, and uniform between 1
- # and length otherwise. The actual length can be slightly greater
-
- length = min(length, 1+torch.randint(length*2, (1,)).item())
while len(s) < length:
v = random_var(nb_variables=nb_variables)
s += v + "=" + random_expr(variables, budget=20) + ";"
def generate_sequences(nb, nb_variables=5, length=20):
assert nb_variables <= 26
sequences = []
- result_max=99
+ result_max = 99
+
for n in range(nb):
+ # We take length itself half of the time, and uniform between
+ # 1 and length otherwise. The actual length can be slightly
+ # greater
+
+ l = min(length, 1 + torch.randint(length * 2, (1,)).item())
result = None
while result == None or max(result.values()) > result_max:
- l = length
p, v = generate_program(nb_variables, l)
v = ", ".join(['"' + v + '": ' + v for v in v])
ldict = {}