From 74b215dd6f87ca3e350c5c8b58d329baa9e8fac6 Mon Sep 17 00:00:00 2001 From: Tom Body
Date: Mon, 13 Nov 2023 11:07:43 -0500 Subject: [PATCH] Fix select of a single random element --- freegs/optimiser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/freegs/optimiser.py b/freegs/optimiser.py index 1701559..4b4626c 100644 --- a/freegs/optimiser.py +++ b/freegs/optimiser.py @@ -65,7 +65,9 @@ def pickUnique(N, m, e): inds = sorted(e) # Sorted list of indices. Used to avoid clashes others = [] # The list of three agents for i in range(m): - newind = random.randint(0, N - 1 - i - len(e)) + high = N - 1 - i - len(e) + newind = random.randint(0, high) if high > 0 else 0 + for ind in inds: if newind == ind: newind += 1