Tuple-like Object Storage

class pyomo.core.kernel.tuple_container.TupleContainer(*args)[source]

Bases: pyomo.core.kernel.homogeneous_container.IHomogeneousContainer, _abcoll.Sequence

A partial implementation of the IHomogeneousContainer interface that provides tuple-like storage functionality.

Complete implementations need to set the _ctype property at the class level and initialize the remaining ICategorizedObject attributes during object creation. If using __slots__, a slot named “_data” must be included.

Note that this implementation allows nested storage of other ICategorizedObjectContainer implementations that are defined with the same ctype.


alias of abc.ABCMeta


x.__delattr__(‘name’) <==> del x.name


x.__eq__(y) <==> x==y


default object formatter


x.__getattribute__(‘name’) <==> x.name


x.__init__(…) initializes x; see help(type(x)) for signature


alias of abc.ABCMeta


x.__ne__(y) <==> x!=y

__new__(S, ...) → a new object with type S, a subtype of T

helper for pickle


helper for pickle


x.__setattr__(‘name’, value) <==> x.name = value

__sizeof__() → int

size of object in memory, in bytes


Convert this object to a string by first attempting to generate its fully qualified name. If the object does not have a name (because it does not have a parent, then a string containing the class name is returned.

classmethod __subclasshook__(C)

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).


list of weak references to the object (if defined)


Activate this container.


The active status of this object.


Get the child object associated with a given storage key for this container.

Raises:KeyError – if the argument is not a storage key for any children of this container

A generator over the children of this container.


Returns a copy of this object with the parent pointer set to None.

A clone is almost equivalent to deepcopy except that any categorized objects encountered that are not descendents of this object will reference the same object on the clone.


Generates an efficient traversal of all components stored under this container. Components are categorized objects that are either (1) not containers, or (2) are heterogeneous containers.

Parameters:active (True/None) – Controls whether or not to filter the iteration to include only the active part of the storage tree. The default is True. Setting this keyword to None causes the active status of objects to be ignored.
Returns:iterator of components in the storage tree
count(value) → integer -- return number of occurrences of value[source]

The object’s category type.


Deactivate this container.

getname(fully_qualified=False, name_buffer={}, convert=<type 'str'>, relative_to=None)

Dynamically generates a name for this object.

  • fully_qualified (bool) – Generate a full name by iterating through all anscestor containers. Default is False.
  • convert (function) – A function that converts a storage key into a string representation. Default is the built-in function str.
  • relative_to (object) – When generating a fully qualified name, generate the name relative to this block.

If a parent exists, this method returns a string representing the name of the object in the context of its parent; otherwise (if no parent exists), this method returns None.

index(value[, start[, stop]]) → integer -- return first index of value.[source]

Raises ValueError if the value is not present.


The object’s local name within the context of its parent. Alias for obj.getname(fully_qualified=False).


The object’s fully qualified name. Alias for obj.getname(fully_qualified=True).


The object’s parent (possibly None).


The object’s storage key within its parent