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: Returns a heuristic action in the given context.
  
  Parameters:
     o: gym observation
         new observation
     current_observations: list of gym observations
         current observations up to the present time step.
docstr_tok: ["Returns","a","heuristic","action","in","the","given","context",".","Parameters",":","o",":","gym","observation","new","observation","current_observations",":","list","of","gym","observations","current","observations","up","to","the","present","time","step","."]
code: def heuristic(self, o, current_observations):
      """Returns a heuristic action in the given context.
  
      Parameters:
         o: gym observation
             new observation
         current_observations: list of gym observations
             current observations up to the present time step.
      """
      current_observations = np.asarray(
          current_observations + [o], dtype=np.float32
      )
      self.archive = [
          self.archive[i]
          for i in range(len(self.archive))
          if self.archive[i][2] <= self.mean_loss
      ]
      self.archive = sorted(
          self.archive, key=lambda trace: -len(trace[0])
      )
      for trace in self.archive:
          to, ta, _ = trace
          assert len(to) == len(ta)
          if (
              len(current_observations) > len(to)
              and "extrapolate" not in self.control
          ):
              continue
          to = np.asarray(
              to[(-len(current_observations)) :], dtype=np.float32
          )
          # if all((_to - _o) for _to, _o in zip(to, current_observations)) <= 1e-7:
          if np.array_equal(to, current_observations):
              return np.asarray(
                  ta[len(current_observations) - 1], dtype=np.float32
              )
      return None
  
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 13 for calling the GymMulti obj's underlying member method code with example usage: obj.heuristic(o, current_observations) and returns: None, np