original_docstring:  Return list of sets, params, variables, constraints or objectives
  
      Args:
          instance: a Pyomo ConcreteModel object
          entity_type: "set", "par", "var", "con" or "obj"
  
      Returns:
          DataFrame of entities
  
      Example:
          >>> data = read_excel('mimo-example.xlsx')
          >>> model = create_model(data, range(1,25))
          >>> list_entities(model, 'obj')  #doctest: +NORMALIZE_WHITESPACE
                                           Description Domain
          Name
          obj   minimize(cost = sum of all cost types)     []
  
      
docstring: Return list of sets, params, variables, constraints or objectives
docstring_tokens: Return list of sets params variables constraints or objectives
code: def list_entities(instance, entity_type):
      """ Return list of sets, params, variables, constraints or objectives
  
      Args:
          instance: a Pyomo ConcreteModel object
          entity_type: "set", "par", "var", "con" or "obj"
  
      Returns:
          DataFrame of entities
  
      Example:
          >>> data = read_excel('mimo-example.xlsx')
          >>> model = create_model(data, range(1,25))
          >>> list_entities(model, 'obj')  #doctest: +NORMALIZE_WHITESPACE
                                           Description Domain
          Name
          obj   minimize(cost = sum of all cost types)     []
  
      """
  
      # helper function to discern entities by type
      def filter_by_type(entity, entity_type):
          if entity_type == 'set':
              return isinstance(entity, pyomo.Set) and not entity.virtual
          elif entity_type == 'par':
              return isinstance(entity, pyomo.Param)
          elif entity_type == 'var':
              return isinstance(entity, pyomo.Var)
          elif entity_type == 'con':
              return isinstance(entity, pyomo.Constraint)
          elif entity_type == 'obj':
              return isinstance(entity, pyomo.Objective)
          else:
              raise ValueError("Unknown entity_type '{}'".format(entity_type))
  
      # iterate through all model components and keep only
      iter_entities = instance.__dict__.iteritems()
      entities = sorted(
          (name, entity.doc, _get_onset_names(entity))
          for (name, entity) in iter_entities
          if filter_by_type(entity, entity_type))
  
      # if something was found, wrap tuples in DataFrame, otherwise return empty
      if entities:
          entities = pd.DataFrame(entities,
                                  columns=['Name', 'Description', 'Domain'])
          entities.set_index('Name', inplace=True)
      else:
          entities = pd.DataFrame()
      return entities
code_tokens: def list_entities ( instance , entity_type ) : def filter_by_type ( entity , entity_type ) : if entity_type == 'set' : return isinstance ( entity , pyomo . Set ) and not entity . virtual elif entity_type == 'par' : return isinstance ( entity , pyomo . Param ) elif entity_type == 'var' : return isinstance ( entity , pyomo . Var ) elif entity_type == 'con' : return isinstance ( entity , pyomo . Constraint ) elif entity_type == 'obj' : return isinstance ( entity , pyomo . Objective ) else : raise ValueError ( "Unknown entity_type '{}'" . format ( entity_type ) ) iter_entities = instance . __dict__ . iteritems ( ) entities = sorted ( ( name , entity . doc , _get_onset_names ( entity ) ) for ( name , entity ) in iter_entities if filter_by_type ( entity , entity_type ) ) if entities : entities = pd . DataFrame ( entities , columns = [ 'Name' , 'Description' , 'Domain' ] ) entities . set_index ( 'Name' , inplace = True ) else : entities = pd . DataFrame ( ) return entities
short_docstring: Return list of sets, params, variables, constraints or objectives
short_docstring_tokens: Return list of sets params variables constraints or objectives
comment: """ Return list of sets, params, variables, constraints or objectives
  
      Args:
          instance: a Pyomo ConcreteModel object
          entity_type: "set", "par", "var", "con" or "obj"
  
      Returns:
          DataFrame of entities
  
      Example:
          >>> data = read_excel('mimo-example.xlsx')
          >>> model = create_model(data, range(1,25))
          >>> list_entities(model, 'obj')  #doctest: +NORMALIZE_WHITESPACE
                                           Description Domain
          Name
          obj   minimize(cost = sum of all cost types)     []
  
      """$SEP$# helper function to discern entities by type$SEP$# iterate through all model components and keep only$SEP$# if something was found, wrap tuples in DataFrame, otherwise return empty