Make the population explicitly ordered.

This commit is contained in:
Matúš Tejiščák 2024-02-13 22:14:39 +01:00
parent e8abbbd16e
commit bbe4ac960f
1 changed files with 10 additions and 10 deletions

View File

@ -46,19 +46,18 @@ while True:
for w, r, p in r.fetchall()
}
pop = [(
(x,y),
xs.productivity*ys.productivity,
) for x, xs in scores.items()
for y, ys in scores.items()
]
while True:
(x, y), = random.sample(
k=1,
population=[
(x,y)
for x in scores.keys()
for y in scores.keys()
],
counts=[
xs.productivity*ys.productivity
for xs in scores.values()
for ys in scores.values()
],
population=[xy for xy,_ in pop],
counts=[score for _,score in pop],
)
r = db.execute('''
@ -70,6 +69,7 @@ while True:
''', (x, y))
if r.fetchall()[0][0]:
# we already know the answer
log.info('already got %s + %s', x, y)
continue
else:
break