code: def test_performance_ngopt(
      dim: int, bounded: bool, discrete: bool
  ) -> None:
      instrumentation = ng.p.Array(shape=(dim,))
      if dim > 40 and not discrete or dim <= 40 and discrete:
          return
      if bounded:
          instrumentation.set_bounds(lower=-12.0, upper=15.0)
      if discrete:
          instrumentation.set_integer_casting()
      algorithms = [optlib.NGOpt, optlib.OnePlusOne, optlib.CMA]
      if discrete:
          algorithms = [
              optlib.NGOpt,
              optlib.DiscreteOnePlusOne,
              optlib.DoubleFastGADiscreteOnePlusOne,
          ]
      num_tests = 7
      fitness = []
      for i in range(num_tests):
          target = np.random.normal(0.0, 1.0, size=dim)
          factors = np.random.normal(0.0, 7.0, size=dim)
          fitness += [SimpleFitness(target, factors)]
      result_tab = []
      for alg in algorithms:
          results = []
          for i in range(num_tests):
              result_for_this_fitness = []
              for budget_multiplier in [10, 100, 1000]:
                  for num_workers in [1, 20]:
                      opt = alg(  # type: ignore
                          ng.p.Array(shape=(dim,)),
                          budget=budget_multiplier * dim,
                          num_workers=num_workers,
                      )
                      recom = opt.minimize(fitness[i])
                      result_for_this_fitness += [
                          fitness[i](recom.value)
                      ]
              results += result_for_this_fitness
          result_tab += [results]
          won_comparisons = [
              r < ngopt_res
              for (r, ngopt_res) in zip(result_tab[-1], result_tab[0])
          ]
          assert (
              sum(won_comparisons) < len(won_comparisons) // 2
          ), f"alg={alg}, dim={dim}, budget_multiplier={budget_multiplier}, num_workers={num_workers}, bounded={bounded}, discrete={discrete}, result = {result_tab}"
  
file_path: nevergrad/nevergrad/optimization/test_special.py
imports: import os
  import numpy
  import pytest
  import nevergrad.common.typing
  from .None import test_optimizerlib
  from .None import optimizerlib
  import nevergrad
label_desc: Use image node_id 1 for calling a global function with example usage: test_performance_ngopt(dim, bounded, discrete) without return types