class_docstr: Function calling Pyomo model
  
  Parameters
  ----------
  model: pyomo.environ.model
      Pyomo model
  
  Returns
  -------
  float
      the fitness
  
  Notes
  -----
  - You will require an Pyomo installation (with pip: "pip install pyomo")
  - Any changes on the model externally can lead to unexpected behaviours.
class_docstr_tok: ["Function","calling","Pyomo","model","Parameters","--","--","--","--","--","model",":","pyomo.environ.model","Pyomo","model","Returns","--","--","--","-","float","the","fitness","Notes","--","--","-","-","You","will","require","an","Pyomo","installation","(","with","pip",":","``","pip","install","pyomo","''",")","-","Any","changes","on","the","model","externally","can","lead","to","unexpected","behaviours","."]
code: def __init__(self, model: pyomo.Model) -> None:
      if isinstance(model, pyomo.ConcreteModel):
          self._model_instance = (
              model.clone()
          )  # To enable the objective function to run in parallel
      else:
          raise NotImplementedError(
              "AbstractModel is not supported. Please use create_instance() in Pyomo to create a model instance."
          )
  
      instru_params: ParamDict = {}
      self.all_vars: tp.List[pyomo.Var] = []
      self.all_params: tp.List[pyomo.Param] = []
      self.all_constraints: tp.List[pyomo.Constraint] = []
      self.all_objectives: tp.List[pyomo.Objective] = []
  
      # Relevant document: https://pyomo.readthedocs.io/en/stable/working_models.html
  
      for v in self._model_instance.component_objects(
          pyomo.Var, active=True
      ):
          self.all_vars.append(v)
          _make_pyomo_variable_to_parametrization(v, instru_params)
      for v in self._model_instance.component_objects(
          pyomo.Param, active=True
      ):
          self.all_params.append(v)
      for v in self._model_instance.component_objects(
          pyomo.Constraint, active=True
      ):
          self.all_constraints.append(v)
      for v in self._model_instance.component_objects(
          pyomo.Objective, active=True
      ):
          # if v.sense == -1:
          #    print(f"Only minimization problem is supported. The value of the objective function {v.name} will be multiplied by -1.")
          self.all_objectives.append(v)
  
      if not self.all_objectives:
          raise NotImplementedError("Cannot find objective function")
  
      if len(self.all_objectives) > 1:
          raise NotImplementedError(
              "Multi-objective function is not supported yet."
          )
  
      self._value_assignment_code_obj = ""
  
      instru = p.Instrumentation(**instru_params).set_name("")
      for c_idx in range(0, len(self.all_constraints)):
          instru.register_cheap_constraint(
              partial(self._pyomo_constraint_wrapper, c_idx)
          )
      super().__init__(
          function=partial(self._pyomo_obj_function_wrapper, 0),
          parametrization=instru,
      )  # Single objective
  
      exp_tag = ",".join([n.name for n in self.all_objectives])
      exp_tag += "|" + ",".join([n.name for n in self.all_vars])
      exp_tag += "|" + ",".join([n.name for n in self.all_constraints])
      self.add_descriptors(name=exp_tag)
  
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 1 to create a new Pyomo object from inherited base classes: base with example: obj = Pyomo(model)