EntityBase#

class ampl.Entities.EntityBase : IEnumerable#

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 the function ampl.Entities.Entity.GetValues(). The algebraic entities which currenty have an equivalent class in the API are:

Variables (see ampl.Entities.Variable)

Constraints (see ampl.Entities.Constraint)

Objectives (see ampl.Entities.Objective)

Sets (see ampl.Entities.Set)

Parameters (see ampl.Entities.Parameter)

Subclassed by ampl.Entities.Entity< K >

Public Functions

override string ToString ()#

Returns a textual representation of this entity.

DataFrame GetValues ()#

Get the principal values of this entity as a DataFrame.

The specific returned value depends on the type of entity. For:

Variables and Objectives it returns the suffix val

Parameters it returns their values

Constraints it returns the suffix dual

Sets it returns all the members of the set, Note that it does not apply to indexed sets. See ampl.SetInstance.GetValues

Return:

A DataFrame containing the values for all instances

DataFrame GetValues (params string[] suffixes)

Get the specified suffixes value for all instances in a DataFrame.

Param suffixes:

Suffixes to get

Return:

A DataFrame containing the specified values

void SetValues (DataFrame data)#

Set the values of this entity 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];`

Param data:

The data to set the entity to

IEnumerator GetEnumerator ()#

Properties

string Name { get; set; }#

Get the name of this entity.

int Indexarity { get; set; }#

Get the indexarity of this entity (sum of the dimensions of the indexing sets).

This value indicates the arity of the tuple to be passed to the method ampl.Entities.EntityBase.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

Get the sum of the dimensions of the indexing sets or 0 if the entity is not indexed

bool IsScalar { get; set; }#

Check whether this entity is scalar.

Equivalent to testing whether indexarity is equal to zero, is true if the entity is scalar (not indexed over any set)

int NumInstances { get; set; }#

Get the number of instances in this entity.

string[] IndexingSets { get; set; }#

Get the AMPL string representation of the sets on which this entity is indexed.The obtained vector can be modified without any effect to the entity.

Is equal to the string representation of the indexing sets for this entity or an empty array if the entity is scalar

string[] XRef { get; set; }#

Get the names of all entities which depend on this one.

Entity#

Warning

doxygenclass: Cannot find class “ampl::Entities::Entity< K >” in doxygen xml output for project “amplapi” from directory: doxyxml