SetInstance¶
-
class ampl::SetInstance : public ampl::BasicInstance<internal::SetInstance>¶
A SetInstance object stores the information regarding a specific instance of a set.
The instances can be accessed through the function ampl::Set.get of the parent entity.
The set contains a collection of ampl::Tuple
Data can be assigned using setValues or using AMPL::setData and a DataFrame object.
All the accessors in this class throw an std::runtime_error if the instance has been deleted in the underlying AMPL interpreter.
Public Functions
-
inline std::size_t size() const¶
Get the number of tuples in this set instance.
-
inline std::size_t arity() const¶
The arity of s, or number of components in each member of this set.
-
inline bool contains(TupleRef t) const¶
Check wether this set instance contains the specified Tuple.
- Parameters
t – Tuple to be found
-
inline MemberRange members() const¶
Get all members (tuples) in this set instance.
-
inline void setValues(internal::Args objects, std::size_t n)¶
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 instance, and each
arity
elements in the array will be grouped into a Tuple.- Parameters
objects – An array of doubles or strings to be grouped into tuples
n – The number of objects in the array
-
inline void setValues(const Tuple objects[], std::size_t n)¶
Set the tuples in this set instance.
- Parameters
objects – An array of tuples
n – The number of tuples in the array
-
inline void setValues(DataFrame data)¶
Set the values in this set instance 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:
ampl::Set A = ampl.getSet(“A”), AA = ampl.getSet(“AA”); AA.setValues(A.getValues()); // A has now the members {1, 2}
-
inline std::string name() const¶
Returns the name of this instance.
-
inline std::string toString() const¶
Returns a string representation of this instance.
-
inline std::size_t size() const¶