code: def _make_pyomo_range_set_to_parametrization(
      domain: pyomo.RangeSet, params: ParamDict, params_name: str
  ) -> ParamDict:
      # https://pyomo.readthedocs.io/en/stable/pyomo_modeling_components/Sets.html
      # Refer to the implementation in pyomo/core/base/set.py
      ranges = list(domain.ranges())
      num_ranges = len(ranges)
      if num_ranges == 1 and (ranges[0].step in [-1, 0, 1]):
          if isinstance(ranges[0], pyomo.base.range.NumericRange):
              lb, ub = ranges[0].start, ranges[0].end
              if ranges[0].step < 0:
                  lb, ub = ub, lb
              if (lb is not None) and (not ranges[0].closed[0]):
                  lb = float(np.nextafter(lb, 1))
              if (ub is not None) and (not ranges[0].closed[1]):
                  ub = float(np.nextafter(ub, -1))
              params[params_name] = p.Scalar(lower=lb, upper=ub)
              if ranges[0].step in [-1, 1]:
                  # May consider using nested param
                  params[params_name].set_integer_casting()  # type: ignore
          else:
              raise NotImplementedError(
                  f"Cannot handle range type {type(ranges[0])}"
              )
      elif isinstance(domain, pyomo.FiniteSimpleRangeSet):
          # Need to handle step size
          params[params_name] = p.Choice(
              [range(*r) for r in domain.ranges()]
          )  # Assume the ranges do not overlapped
      else:
          raise NotImplementedError(
              f"Cannot handle domain type {type(domain)}"
          )
      return params
  
file_path: nevergrad/nevergrad/functions/pyomo/core.py
imports: from functools import partial
  import numpy
  import pyomo.environ
  import nevergrad.common.typing
  from nevergrad.parametrization import parameter
  from ..None import base
label_desc: Use image node_id 2 for calling a global function with example usage: _make_pyomo_range_set_to_parametrization(domain, params, params_name) and returns: params