# Set¶

class Set

Represents an AMPL set. In case of not indexed sets, this class exposes iterators for accessing its elements. The members of the set are tuples. All these methods throw a TypeError if called for an indexed set.

In case of indexed sets, you can gain access to the instances using the operator [].

All the accessors in this class throw an RuntimeError if the instance has been deleted in the underlying AMPL interpreter.

Data can be assigned to the set using the methods setValues (for non-indexed sets only) or using setData and an object of class DataFrame.

Set.arity()

The arity of the set, or number of components in each member of this set.

Returns: The arity of the set.
Set.size()

Get the number of tuples in this set. Valid only for non indexed sets.

Returns: The number of tuples in the set.
Set.members()

Get the members of this Set. Valid only for non indexed sets.

Returns: The list of members of the set.
Set.contains(tuple)

Check wether this set instance contains the specified tuple.

Returns: TRUE if this set instance contains the specified tuple.
Set.getValues()

Get values of this set in a data.frame. Valid only for non indexed sets.

Returns: data.frame containing the values of this set.
Set.setValues(values)

Set values. Valid only for non indexed sets.