"""Experimenter base class for problem statement and evaluation.

Experimenters represent black-box optimization problems.
Each experimenter defines a ProblemStatement, representing the search space and
the metrics it returns in Evaluate (via CompletedTrials).

Pseudo-code for using Experimenters with Vizier Designers:

exp = ExperimenterSubClass(...)  # Possibly configure the experimenter.
problem_statement = exp.problem_statement()
designer = Designer(problem_statement)  # Configure the search algorithm
for i in range(10):
  suggestions = designer.suggest(count=2)
  completed_trials = exp.evaluate(suggestions)
  designer.update(completed_trials)
"""

import abc
from typing import List, Sequence

from vizier import pyvizier


class Experimenter(metaclass=abc.ABCMeta):
  """Abstract base class for Experimenters."""

  # TODO: Use CompletedTrials as output type.
  @abc.abstractmethod
  def evaluate(self,
               suggestions: Sequence[pyvizier.Trial]) -> List[pyvizier.Trial]:
    """Evaluates and completes the Trials.

    Args:
      suggestions: Sequence of Trials to be evaluated.

    Returns:
      List of completed Trials.
    """
    pass

  @abc.abstractmethod
  def problem_statement(self) -> pyvizier.ProblemStatement:
    """The search configuration generated by this experimenter."""
    pass
