Skip to content

Handle objective function crash#387

Merged
relf merged 11 commits intomasterfrom
handle_fobj_crash
Feb 14, 2026
Merged

Handle objective function crash#387
relf merged 11 commits intomasterfrom
handle_fobj_crash

Conversation

@relf
Copy link
Owner

@relf relf commented Feb 14, 2026

This pull request introduces several important refactorings and improvements to the EGO optimizer codebase, focusing on unifying and clarifying function trait usage, improving error handling, and enhancing test coverage for user function failures. The changes also adjust clustering defaults and improve logging for failed objective evaluations.

Refactoring and trait unification

  • Replaced the use of GroupFunc with a new, more general ObjFn trait throughout the EGO optimizer, including in the EgorFactory, Egor structs, and related function signatures. This unifies the way objective functions are represented and simplifies trait bounds. [1] [2] [3] [4] [5] [6]
  • Introduced the OptFn trait as a wrapper around either UserFn or ObjFn (depending on the presence of the nlopt feature), and updated the Optimizer struct and its methods to use OptFn for both the objective and constraints. [1] [2] [3] [4] [5]

Error handling and logging improvements

  • Changed the error variant for user function failures from a generic EgoError to a more descriptive UserFnError, clarifying error sources.
  • Enhanced logging and handling of failed objective function evaluations: failures now log a warning and return a matrix of NaNs instead of panicking, improving robustness. [1] [2]

Test improvements

  • Added a new test (test_sphere_periodic_failures) that simulates periodic failures in the user-defined objective function, ensuring that the optimizer correctly handles and records failed evaluations.

Documentation and naming consistency

  • Updated documentation and code examples to use the new ProblemFunc instead of the old ObjFunc for clarity and consistency. [1] [2] [3] [4]
  • Renamed trait bounds and methods from DomainConstraints to Constraints for improved clarity and consistency. [1] [2] [3] [4] [5] [6]

Clustering and configuration

  • Changed the default number of clusters in the surrogate model builder from 2 to 1, and clarified the meaning of the Enabled variant in the DataClustering enum. [1] [2]

@relf relf marked this pull request as ready for review February 14, 2026 17:39
@relf relf merged commit 17ecd86 into master Feb 14, 2026
19 checks passed
@relf relf deleted the handle_fobj_crash branch February 14, 2026 17:40
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