SetInstance Class¶
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.
- Namespace
- Assemblies
AMPL
Inheritance Hierarchy¶
System.Object
Syntax¶
public class SetInstance : IEnumerable<Tuple>, IEnumerable
- class ampl.SetInstance
Methods¶
- GetEnumerator()¶
Get the enumerator to this set instance contents
- Return type
System.Collections.Generic.IEnumerator<ampl.Tuple>
public IEnumerator<Tuple> GetEnumerator()
- GetValues()¶
Get all the tuples in this set in a DataFrame. Valid only for non indexed sets.
- Return type
- Returns
A DataFrame containing all the tuples in this set
public DataFrame GetValues()
- SetValues(System.Double[])¶
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.public void SetValues(double[] values)
- SetValues(System.String[])
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.public void SetValues(string[] values)
- 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");
Set AA = ampl.GetSet("AA");
AA.SetValues(A.GetValues()); // A has now the members {1, 2}
public void SetValues(DataFrame df)
- SetValues(ampl.Tuple[])
Set the tuples in this set instance.
public void SetValues(Tuple[] values)
- GetEnumerator()
Get the enumerator to this set instance contents
- Return type
System.Collections.IEnumerator
IEnumerator IEnumerable.GetEnumerator()
Properties¶
- ampl.SetInstance.Size¶
Get the number of tuples in this set instance
- Return type
System.Int32
public int Size { get; }