SetInstance#
- class ampl.SetInstance : IEnumerable, ampl.Instance#
A SetInstance object stores the information regarding a specific instance of a set.The instances can be accessed through the function
ampl.Entities.Set.Get
of the parent entity or through its indexer.Represents a set instance.
For documentation on the properties see :dn:class:
ampl.Entities.Set
.Public Functions
- IEnumerator<Tuple> GetEnumerator ()#
Get the enumerator to this set instance contents.
- DataFrame GetValues ()#
Get all the tuples in this set in a DataFrame.
Valid only for non indexed sets.
- Return:
A DataFrame containing all the tuples in this set
- void SetValues (DataFrame df)#
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");
Set AA = ampl.GetSet("AA");
AA.SetValues(A.GetValues()); // A has now the members {1, 2}
- Param df:
The dataframe containing the values to be assigned
- void SetValues (Tuple[] values)
Set the tuples in this set instance.
- Param values:
The tuples to assign to this set
- void SetValues (double[] values)
Set the tuples to 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.- Param values:
An array of doubles to be grouped into tuples
- void SetValues (string[] values)
Set the tuples to 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.- Param values:
An array of strings to be grouped into tuples
Properties
- int Size { get; set; }#
Get the number of tuples in this set instance.
- Entities.EntityBase Entity { get; set; }#
Gets the parent entity.