Constrained optimization with Optuna and TPESampler

1. Severity of the issue: (select one)
None: I’m just curious or want clarification.
Low: Annoying but doesn’t hinder my work.
Medium: Significantly affects my productivity but can find a workaround.
High: Completely blocks me.

2. Environment:

  • Ray version: 2.42.1
  • Python version: 3.10
  • OS: Ubuntu/Linux
  • Cloud/Infrastructure: -
  • Other libs/tools (if relevant): -

3. What happened vs. what you expected:

  • Expected: -
  • Actual: -

Hello, I am interested in experimenting with objective constraints. Up to now I have followed the sugestions from another topic for penalizing erroneous configurations. From optuna docs, TPESampler is able to handle constraints directly with constraints_func argument. I was wondering if such functionality is available to ray, since it depends on setting the optuna trial’s attributes, e.g. as shown in a relevant medium article.

Can we access search algorithm internals (i.e. optuna trials) from within ray objective function or from a callback passed as RunConfig? In the later case callback is called with ray Trial param, however I couldn’t find a relation to the corresponding Optuna trial, as they are probably maintained separately.

Thanks
George