Skip to content

Commit 0ac3318

Browse files
committed
ENH: SCE-UA: Set theta dynamically, based on span of bounds in orders of magnitude
Fixes convergence in example such as: sambo.minimize(fun=lambda x: sum(x**2), bounds=[[-1e5, 1e5]]*2, max_iter=1000, method="sceua") Fixes #2
1 parent 696e8c5 commit 0ac3318

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sambo/_sceua.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def _apply_constraints(x, bounds, constraints, centroid, rng):
2626
def _evolve_complex(func, args, population, func_values, complex_indices, bounds, constraints, rng):
2727
alpha = 1
2828
beta = .5
29-
theta = .2
29+
# Higher bounds orders of magnitude => higher theta
30+
theta = np.interp(np.log10(bounds.ptp(axis=1).max()), (2, 5), (.2, .5))
31+
3032
best_idx, worst_idx = 0, -1 # Index 0 is best in population. We use 1 which is best of complex
3133

3234
complex_population = population[complex_indices]

0 commit comments

Comments
 (0)