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
ampl
- Assemblies
- AMPL
Inheritance Hierarchy¶
System.Object
ampl.Instance
ampl.SetInstance
Syntax¶
public class SetInstance : Instance, IDisposable, IEnumerable<Tuple>, IEnumerable
-
class
ampl.
SetInstance
Methods¶
-
Contains
(TupleBase)¶ Check whether this set instance contains the specified Tuple.
Arguments: - t (TupleBase) – Tuple to be found
Return type: System.Boolean
public bool Contains(TupleBase t)
-
Dispose
()¶ public override void Dispose()
-
Finalize
()¶ protected void Finalize()
-
GetEnumerator
()¶ Get the enumerator to this set instance contents
Return type: System.Collections.Generic.IEnumerator<System.Collections.Generic.IEnumerator`1>{ampl.Tuple<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: ampl.DataFrame 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 C# 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¶
-
Size
()¶ Get the number of tuples in this set instance
Return type: System.Int32 public int Size { get; }
-