FLATTEN_CROSS_PRODUCT

(data from pyomo.core.base.set)

pyomo.core.base.set.FLATTEN_CROSS_PRODUCT = True

Set objects

Pyomo Set objects are designed to be “API-compatible” with Python set objects. However, not all Set objects implement the full set API (e.g., only finite discrete Sets support add()).

All Sets implement one of the following APIs:

  1. class SetData(ComponentData) (base class for all AML Sets)

  2. class _FiniteSetMixin(object) (pure virtual interface, adds support for discrete/iterable sets)

  1. class _OrderedSetMixin(object) (pure virtual interface, adds support for ordered Sets)

This is a bit of a change from python set objects. First, the lowest-level (non-abstract) Data object supports infinite sets; that is, sets that contain an infinite number of values (this includes both bounded continuous ranges as well as unbounded discrete ranges). As there are an infinite number of values, iteration is not supported. The base class also implements all Python set operations. Note that SetData does not implement len(), as Python requires len() to return a positive integer.

Finite sets add iteration and support for len(). In addition, they support access to members through three methods: data() returns the members as a tuple (in the internal storage order), and may not be deterministic. ordered_data() returns the members, and is guaranteed to be in a deterministic order (in the case of insertion order sets, up to the determinism of the script that populated the set). Finally, sorted_data() returns the members in a sorted order (guaranteed deterministic, up to the implementation of < and ==).

..TODO: should these three members all return generators? This would further change the implementation of data(), but would allow consumers to potentially access the members in a more efficient manner.

Ordered sets add support for ord() and __getitem__, as well as the first, last, next and prev methods for stepping over set members.

Note that the base APIs are all declared (and to the extent possible, implemented) through Mixin classes.