Initializer

(function from pyomo.core.base.initializer)

pyomo.core.base.initializer.Initializer(arg, allow_generators=False, treat_sequences_as_mappings=True, arg_not_specified=None, additional_args=0)[source]

Standardized processing of Component keyword arguments

Component keyword arguments accept a number of possible inputs, from scalars to dictionaries, to functions (rules) and generators. This function standardizes the processing of keyword arguments and returns “initializer classes” that are specialized to the specific data type provided.

Parameters:
  • arg – The argument passed to the component constructor. This could be almost any type, including a scalar, dict, list, function, generator, or None.

  • allow_generators (bool) – If False, then we will raise an exception if arg is a generator

  • treat_sequences_as_mappings (bool) – If True, then if arg is a sequence, we will treat it as if it were a mapping (i.e., dict(enumerate(arg))). Otherwise sequences will be returned back as the value of the initializer.

  • arg_not_specified – If arg is arg_not_specified, then the function will return None (and not an InitializerBase object).

  • additional_args (int) – The number of additional arguments that will be passed to any function calls (provided before the index value).