class_docstr: Operator for applying a constraint on a Parameter
  
  Parameters
  ----------
  func: function
      the constraint function, taking the same arguments that the function to optimize.
      This constraint function must return a float (or a list/tuple/array of floats),
      positive if the constraint is not satisfied, null or negative otherwise.
  optimizer: str
      name of the optimizer to use for solving the constraint
  budget: int
      the budget to use for applying the constraint
  
  Example
  -------
  >>> constrained_parameter = Constraint(constraint_function)(parameter)
  >>> constrained_parameter.value  # value after trying to satisfy the constraint
class_docstr_tok: ["Operator","for","applying","a","constraint","on","a","Parameter","Parameters","--","--","--","--","--","func",":","function","the","constraint","function",",","taking","the","same","arguments","that","the","function","to","optimize",".","This","constraint","function","must","return","a","float","(","or","a","list\/tuple\/array","of","floats",")",",","positive","if","the","constraint","is","not","satisfied",",","null","or","negative","otherwise",".","optimizer",":","str","name","of","the","optimizer","to","use","for","solving","the","constraint","budget",":","int","the","budget","to","use","for","applying","the","constraint","Example","--","--","--","-",">",">",">","constrained_parameter","=","Constraint","(","constraint_function",")","(","parameter",")",">",">",">","constrained_parameter.value","#","value","after","trying","to","satisfy","the","constraint"]
code: def _layered_get_value(self) -> tp.Any:
      # TODO: this can be made more efficient (fewer copy) if need be.
      # Override only apply_constraint if you can, tampering with this method is tricky
      if self._cache is not None:
          return self._cache
      parameter = self.parameter()
      satisfied = not np.any(
          self.function(*parameter.args, **parameter.kwargs)
      )
      if satisfied:
          self._cache = parameter.value
          return self._cache
      root: core.Parameter = self._layers[0]  # type: ignore
      recom = self.apply_constraint(parameter)
      root.set_standardized_data(
          np.zeros(root.dimension), reference=recom
      )
      self._cache = recom.value
      return self._cache
  
file_path: nevergrad/nevergrad/ops/constraints.py
imports: import numpy
  import nevergrad.common.typing
  from nevergrad.common import errors
  from nevergrad.parametrization import core
  from nevergrad import optimizers
  from nevergrad import callbacks
label_desc: Use image node_id 7 for calling the Constraint obj's underlying member method code with example usage: obj._layered_get_value() and returns: self, self, self