class_docstr: Test suite for algorithm AxOptimizer
class_docstr_tok: ["Test","suite","for","algorithm","AxOptimizer"]
docstr: Test that algorithm optimizes somehow (this is on-par with random search)
docstr_tok: ["Test","that","algorithm","optimizes","somehow","(","this","is","on-par","with","random","search",")"]
code: def test_objectives_constraints(self):
      """Test that algorithm optimizes somehow (this is on-par with random search)"""
      _max_trials = 20
      task = BraninCurrinTask()
      space = self.create_space(task.get_search_space())
      algo = self.create_algo(
          config={
              **self.config,
              "constraints": ["constraint >= 3", "constraint <= 10"],
          },
          space=space,
      )
      algo.algorithm.max_trials = _max_trials
      safe_guard = 0
      trials = []
      objectives = []
      while trials or not algo.is_done:
          if safe_guard >= _max_trials:
              break
  
          if not trials:
              trials = algo.suggest(_max_trials - len(objectives))
  
          trial = trials.pop(0)
          results = task(trial.params["x"])
          objectives.append((results[0]["value"], results[1]["value"]))
          backward.algo_observe(
              algo,
              [trial],
              [
                  dict(
                      objective=objectives[-1][0],
                      constraint=objectives[-1][1],
                  )
              ],
          )
          safe_guard += 1
  
      objectives_branin, objectives_currin = list(zip(*objectives))
  
      assert algo.is_done
      # branin
      assert (
          min(objectives_branin)
          <= stats.mean(objectives_branin)
          - stats.stdev(objectives_branin) * 0.7
      )
      # currin
      assert 3 <= stats.mean(objectives_currin[-5:]) <= 10
  
imports: import statistics
  from typing import ClassVar, List
  import pytest
  from orion.algo.axoptimizer import import_optional
  from orion.benchmark.task.base import BenchmarkTask
  from orion.core.utils import backward
  from orion.testing.algo import BaseAlgoTests, TestPhase, first_phase_only
  import numpy
  from botorch.test_functions.multi_objective import BraninCurrin
  from torch import Tensor
label_desc: Use image node_id 7 for calling the TestAxOptimizer obj's underlying member method code with example usage: obj.test_objectives_constraints() without return types