def __init__(self, *args, **kwds): from pyomo.core.base.sets import process_setarg # kwds.pop('noruleinit', None) Component.__init__(self, **kwds) # self._data = {} # if len(args) == 0 or (len(args) == 1 and args[0] is UnindexedComponent_set): # # If no indexing sets are provided, generate a dummy index # self._implicit_subsets = None self._index = UnindexedComponent_set elif len(args) == 1: # # If a single indexing set is provided, just process it. # self._implicit_subsets = None self._index = process_setarg(args[0]) else: # # If multiple indexing sets are provided, process them all, # and store the cross-product of these sets. The individual # sets need to stored in the Pyomo model, so the # _implicit_subsets class data is used for this temporary # storage. # # Example: Pyomo allows things like # "Param([1,2,3], range(100), initialize=0)". This # needs to create *3* sets: two SetOf components and then # the SetProduct. That means that the component needs to # hold on to the implicit SetOf objects until the component # is assigned to a model (where the implicit subsets can be # "transferred" to the model). # tmp = [process_setarg(x) for x in args] self._implicit_subsets = tmp self._index = tmp[0].cross(*tmp[1:])