Set Class ========= 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, represented by objects of class :dn:class:`ampl.Tuple`. All these methods throw an `ArgumentException` if called for an indexed set. In case of indexed sets, you can gain access to the instances (of class :dn:class:`ampl.SetInstance`) using the methods :dn:method:`ampl.Set.Get`, using the indexing operator or via the iterators. Data can be assigned to the set using the methods :dn:method:`ampl.Set.SetValues` (for non-indexed sets only) or using :dn:method:`ampl.AMPL.SetData` and an object of class :dn:class:`ampl.DataFrame`. Namespace :dn:ns:`ampl.Entities` Assemblies * AMPL ---- .. contents:: :local: Inheritance Hierarchy --------------------- * :dn:cls:`System.Object` * :dn:cls:`ampl.Entities.Entity` * :dn:cls:`ampl.Entities.Entity{ampl.SetInstance}` * :dn:cls:`ampl.Entities.Set` Syntax ------ .. code-block:: csharp [ClassInterface(ClassInterfaceType.None)] public class Set : Entity, IEnumerable, IEnumerable, ISet .. dn:class:: ampl.Entities.Set :hidden: .. dn:class:: ampl.Entities.Set Properties ---------- .. dn:class:: ampl.Entities.Set :noindex: :hidden: .. dn:property:: ampl.Entities.Set.Arity The arity of s, or number of components in each member of this set :rtype: System.Int32 .. code-block:: csharp public int Arity { get; } .. dn:property:: ampl.Entities.Set.Members Get the members of this set. Valid only for non indexed sets. :rtype: System.Collections.Generic.IEnumerable{ampl.Tuple} .. code-block:: csharp public IEnumerable Members { get; } .. dn:property:: ampl.Entities.Set.Size Get the number of tuples in this set. Valid only for non indexed sets. :rtype: System.Int32 .. code-block:: csharp public int Size { get; } Methods ------- .. dn:class:: ampl.Entities.Set :noindex: :hidden: .. dn:method:: ampl.Entities.Set.Contains(ampl.Tuple) Check whether this set contains the specified Tuple. Valid only for non indexed sets. :param t: Tuple to be found :type t: ampl.Tuple :rtype: System.Boolean :return: True if the tuple is contained in this set .. code-block:: csharp public bool Contains(Tuple t) .. dn:method:: ampl.Entities.Set.Get(System.Object[]) :type index: System.Object[] :rtype: ampl.SetInstance .. code-block:: csharp public SetInstance Get(params object[] index) .. dn:method:: ampl.Entities.Set.Get(ampl.Tuple) :type t: ampl.Tuple :rtype: ampl.SetInstance .. code-block:: csharp public override SetInstance Get(Tuple t = null) .. dn:method:: ampl.Entities.Set.GetEnumerator() :rtype: System.Collections.Generic.IEnumerator{ampl.SetInstance} .. code-block:: csharp public override IEnumerator GetEnumerator() .. dn:method:: ampl.Entities.Set.GetValues() Get all the tuples in this set in a DataFrame. Valid only for non indexed sets. :rtype: ampl.DataFrame :return: A DataFrame containing all the tuples in this set .. code-block:: csharp public override DataFrame GetValues() .. dn:method:: ampl.Entities.Set.SetValues(System.Double[]) Set the tuples to this set using a flattened array. The size of the array must be a multiple of the arity of this set, and each `arity` elements in the array will be grouped into a Tuple. Valid only for non indexed sets. :param objects: An array of doubles to be grouped into tuples :type objects: System.Double[] .. code-block:: csharp public void SetValues(double[] objects) .. dn:method:: ampl.Entities.Set.SetValues(System.String[]) Set the tuples in this set instance using a flattened array. The size of the array must be a multiple of the arity of this set, and each `arity` elements in the array will be grouped into a Tuple. Valid only for non indexed sets. :param objects: An array of strings to be grouped into tuples :type objects: System.String[] .. code-block:: csharp public void SetValues(string[] objects) .. dn:method:: ampl.Entities.Set.SetValues(ampl.DataFrame) Set the values in this set to the indexing values of the passed DataFrame.The number of indexing columns of the parameter must be equal to the arity of this set instance. For example, considering the following AMPL entities and corresponding objects:: set A := 1..2; param p { i in A } := i+10; set AA; The following is valid:: Set A = ampl.getSet("A"), AA = ampl.GetSet("AA"); AA.setValues(A.GetValues()); // A has now the members {1, 2} Valid only for non indexed sets. :param data: The dataframe containing the values to be assigned :type data: ampl.DataFrame .. code-block:: csharp public void SetValues(DataFrame data) .. dn:method:: ampl.Entities.Set.SetValues(ampl.Tuple[]) Set the tuples in this set. Valid only for non indexed sets. :param objects: The tuples to assign to this set :type objects: ampl.Tuple[] .. code-block:: csharp public void SetValues(Tuple[] objects)