Skip to content

Add fitness standard deviation restart condition#103

Open
githubpsyche wants to merge 1 commit intoRobertTLange:mainfrom
githubpsyche:add-fitness-std-cond
Open

Add fitness standard deviation restart condition#103
githubpsyche wants to merge 1 commit intoRobertTLange:mainfrom
githubpsyche:add-fitness-std-cond

Conversation

@githubpsyche
Copy link
Copy Markdown

Thanks for maintaining evosax!

SciPy's differential_evolution supports early stopping based on the standard deviation of the current population fitness values:

std(fitness) <= atol + tol * abs(mean(fitness))

This lets callers set a conservative maximum generation budget while still allowing easier runs to exit once the population has converged in objective value. I've found this same stopping rule useful for performance in my own work with evosax.

evosax already has restart-condition utilities in evosax.core.restart, and users often compose their own ask/tell loops. I thought this rule fit naturally as another small reusable predicate in that module, so this PR adds FitnessStdRestartParams(tol=0.001, atol=0.0) and fitness_std_cond(...).

The predicate returns False if any fitness value is non-finite; otherwise it applies the atol + tol * abs(mean(fitness)) threshold. I kept this intentionally narrow: no runner abstraction and no algorithm API changes. Let me know if you would prefer a different name or location for this utility.

I added restart tests for tolerance behavior, non-finite fitness values, and JIT compatibility. ruff and the full pytest tests/ suite pass locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant