Skip to content

Commit a3cc528

Browse files
committed
BUG: SCE-UA: Replace the single worst x, not n-2
1 parent 6485e76 commit a3cc528

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sambo/_sceua.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ def _evolve_complex(func, args, population, func_values, complex_indices, bounds
5151
complex_population[worst_idx] = contraction
5252
complex_values[worst_idx] = contraction_value
5353
else:
54-
n_worst = len(complex_indices) - 2 # This includes our +1 at index 0
55-
x = _sample_population(bounds, n_worst, constraints, rng)
56-
complex_population[-n_worst:] = x
57-
complex_values[-n_worst:] = np.apply_along_axis(func, 1, x, *args)
54+
# Replace worst with random point
55+
x = _sample_population(bounds, 1, constraints, rng)
56+
complex_population[worst_idx:] = x
57+
complex_values[worst_idx:] = np.apply_along_axis(func, 1, x, *args)
5858

5959
sorted_indices = np.argsort(complex_values)
6060
complex_population = complex_population[sorted_indices]

0 commit comments

Comments
 (0)