class_docstr: Class for converting a gym environment, a controller style, and others into a black-box optimization benchmark.
class_docstr_tok: ["Class","for","converting","a","gym","environment",",","a","controller","style",",","and","others","into","a","black-box","optimization","benchmark","."]
docstr: Conformant: we directly optimize inputs, not parameters of a policy.
docstr_tok: ["Conformant",":","we","directly","optimize","inputs",",","not","parameters","of","a","policy","."]
code: def gym_conformant(self, x: np.ndarray, env: tp.Any):
      """Conformant: we directly optimize inputs, not parameters of a policy."""
      reward = 0.0
      for _, a in enumerate(x):
          a = self.action_cast(a, env)
          # try:
          _, r, done, _ = self.step(
              a, env
          )  # Outputs = observation, reward, done, info.
          # except AssertionError:  # Illegal action.
          #    return 1e20 / (1.0 + i)  # We encourage late failures rather than early failures.
          reward *= self.gamma
          reward += r
          if done:
              break
      # env.render()  if you want to display.
      return -reward
  
imports: import os
  import copy
  import scipy.stats
  import typing
  import numpy
  import gym
  import nevergrad
  from nevergrad.parametrization import parameter
  from ..base import ExperimentFunction
label_desc: Use image node_id 15 for calling the GymMulti obj's underlying member method code with example usage: obj.gym_conformant(x, env) and returns: unknown