Entity¶
-
public class
Entity
¶ An AMPL entity such as a parameter or a variable. An entity can either represent a single instance of an AMPL algebraic entity or, if the corresponding declaration has an indexing expression, a mapping from keys to instances. In the derived classes, it has methods to access instance-level properties which can be used in case the represented entity is scalar. To gain access to all the values in an entity (for all instances and all suffixes for that entities), use
getValues
.
Methods¶
getIndexingSets¶
getIndices¶
getValues¶
getValues¶
-
public DataFrame
getValues
(String... suffixes)¶ Get all the specified values for this entity as a DataFrame object. The valid strings are all AMPL built-in suffixes for the entity under consideration.
Parameters: - suffixes – A list of suffixes to be returned
Throws: - IllegalArgumentException – if the specified suffix does not exist.
Returns: A
DataFrame
object with a column for each indexing set and a column for each one of the specified suffixes.
hasIndexing¶
-
public boolean
hasIndexing
()¶ Check whether this entity is indexed over any set. Equivalent to testing whether
Entity.indexarity
is greater than zero.Returns: True if the entity is not scalar (is indexed over a set)
indexarity¶
-
public int
indexarity
()¶ Get the indexarity of this entity (sum of the dimensions of the indexing sets). This value indicates how many elements are to be passed to the method
BasicEntity.get
in order to access an instance of this entity.See the following AMPL examples:
var x; # indexarity = 0 var y {1..2}; # indexarity = 1 var z {1..2,3..4}; # indexarity = 2 var zz {{(1, 2)}}; # indexarity = 2
Returns: The sum of the dimensions of the indexing sets or 0 if the entity is not indexed
isScalar¶
-
public boolean
isScalar
()¶ Check whether this entity is scalar. Equivalent to testing whether
Entity.indexarity
is equal to zero.Returns: True if the entity is scalar (not indexed over any set)
setValues¶
-
public void
setValues
(DataFrame data)¶ Set the values of this entiy to the correponding values of a DataFrame indexed over the same sets (or a subset). This function assigns the values in the first data column of the passed dataframe to the entity the function is called from. In particular, the statement:: x.setValues(y.getValues()); is semantically equivalent to the AMPL statement:: let {s in S} x[s] := y[s]; *
Parameters: - data –