AMPL_ENTITY#

group AMPL_ENTITY

Functions for entities:

Enums

enum AMPL_ENTITYTYPE#

Values:

enumerator AMPL_VARIABLE#

A decision variable (e.g., var x;).

enumerator AMPL_CONSTRAINT#

A constraint definition (e.g., s.t.

c: …)

enumerator AMPL_OBJECTIVE#

An objective function (e.g., minimize cost: …).

enumerator AMPL_PARAMETER#

A parameter (e.g., param p;).

enumerator AMPL_SET#

A set definition (e.g., set S;).

enumerator AMPL_TABLE#

A table declaration used for data exchange.

enumerator AMPL_PROBLEM#

A problem statement grouping objectives and constraints.

enumerator AMPL_UNDEFINED#

An unknown or unsupported entity type.

Functions

AMPL_ERRORINFO *AMPL_EntityGetIndexarity(AMPL *ampl, const char *entityname, size_t *arity)#

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 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
Parameters:
  • ampl – Pointer to the AMPL struct.

  • entityname – Name of entity as string.

  • arity – Pointer to the sum of the dimensions of the indexing sets or 0 if the entity is not indexed.

Returns:

Pointer to the AMPL_ERRORINFO struct.

AMPL_ERRORINFO *AMPL_EntityGetXref(AMPL *ampl, const char *entityname, char ***xref, size_t *size)#

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

Parameters:
  • ampl – Pointer to the AMPL struct.

  • entityname – Name of entity as string.

  • xref – Pointer to the array of strings representing all entities.

  • size – Pointer to the number of entities which depend on this one.

Returns:

Pointer to the AMPL_ERRORINFO struct.

AMPL_ERRORINFO *AMPL_EntityGetNumInstances(AMPL *ampl, const char *entityname, size_t *size)#

Get the number of instances of this entity.

Parameters:
  • ampl – Pointer to the AMPL struct.

  • entityname – Name of entity as string.

  • size – Pointer to the number of instances of this entity.

Returns:

Pointer to the AMPL_ERRORINFO struct.

AMPL_ERRORINFO *AMPL_EntityGetTuples(AMPL *ampl, const char *entityname, AMPL_TUPLE ***tuples, size_t *size)#

Get all indices as tuples of this entity.

Parameters:
  • ampl – Pointer to the AMPL struct.

  • entityname – Name of entity as string.

  • tuples – Pointer to the array of tuples representing all indicies of this entity.

  • size – Pointer to the number of indices of this entity.

Returns:

Pointer to the AMPL_ERRORINFO struct.

AMPL_ERRORINFO *AMPL_EntityGetIndexingSets(AMPL *ampl, const char *entityname, char ***indexingsets, size_t *size)#

Get the AMPL string representation of the sets on which this entity is indexed (an empty array if the entity is scalar).

Parameters:
  • ampl – Pointer to the AMPL struct.

  • entityname – Name of entity as string.

  • indexingsets – Pointer to the array of strings representing the indexing sets.

  • size – Pointer to the number of indexing sets.

Returns:

Pointer to the AMPL_ERRORINFO struct.

AMPL_ERRORINFO *AMPL_EntityGetType(AMPL *ampl, const char *entityname, AMPL_ENTITYTYPE *type)#

Get the type of this entity.

Parameters:
  • ampl – Pointer to the AMPL struct.

  • entityname – Name of entity as string.

  • type – Pointer to the type of the entity.

Returns:

Pointer to the AMPL_ERRORINFO struct.

AMPL_ERRORINFO *AMPL_EntityGetTypeString(AMPL *ampl, const char *entityname, const char **typestr)#

Get the type of this entity as string.

Parameters:
  • ampl – Pointer to the AMPL struct.

  • entityname – Name of entity as string.

  • typestr – Pointer to the type of the entity as string.

Returns:

Pointer to the AMPL_ERRORINFO struct.

AMPL_ERRORINFO *AMPL_EntityGetDeclaration(AMPL *ampl, const char *entityname, char **declaration)#

Get the declaration of this entity as string.

Parameters:
  • ampl – Pointer to the AMPL struct.

  • entityname – Name of entity as string.

  • declaration – Pointer to the declaration of the entity as string.

Returns:

Pointer to the AMPL_ERRORINFO struct.

AMPL_ERRORINFO *AMPL_EntityDrop(AMPL *ampl, const char *entityname)#

Drop all instances in this entity, corresponding to the AMPL code: drop name;.

Parameters:
  • ampl – Pointer to the AMPL struct.

  • entityname – Name of entity as string.

Returns:

Pointer to the AMPL_ERRORINFO struct.

AMPL_ERRORINFO *AMPL_EntityRestore(AMPL *ampl, const char *entityname)#

Restore all instances in this entity, corresponding to the AMPL code: restore name;.

Parameters:
  • ampl – Pointer to the AMPL struct.

  • entityname – Name of entity as string.

Returns:

Pointer to the AMPL_ERRORINFO struct.

AMPL_ERRORINFO *AMPL_EntityGetValues(AMPL *ampl, const char *entityname, const char *const *suffixes, size_t n, AMPL_DATAFRAME **output)#

Get the values of this entity.

Parameters:
  • ampl – Pointer to the AMPL struct.

  • entityname – Name of entity as string.

  • suffixes – Suffixes to get the values of.

  • n – Number of suffixes.

  • output – Pointer to the dataframe containing the values of the entity.

Returns:

Pointer to the AMPL_ERRORINFO struct.

AMPL_ERRORINFO *AMPL_EntitySetValues(AMPL *ampl, const char *entityname, AMPL_DATAFRAME *data)#

Set the values of this entity.

Parameters:
  • ampl – Pointer to the AMPL struct.

  • entityname – Name of entity as string.

  • data – Pointer to the dataframe containing the values of the entity to be set.

Returns:

Pointer to the AMPL_ERRORINFO struct.

AMPL_ERRORINFO *AMPL_EntitySetSuffixes(AMPL *ampl, const char *entityname, AMPL_DATAFRAME *data)#

Set the suffixes of this entity.

Parameters:
  • ampl – Pointer to the AMPL struct.

  • entityname – Name of entity as string.

  • data – Pointer to the dataframe containing the suffix data of the entity to be set.

Returns:

Pointer to the AMPL_ERRORINFO struct.

AMPL_ERRORINFO *AMPL_EntityIsInstance(AMPL *ampl, const char *entityname, AMPL_TUPLE *index)#

Set the suffixes of this entity.

Parameters:
  • ampl – Pointer to the AMPL struct.

  • entityname – Name of entity as string.

  • index – Index of instance as tuple.

Returns:

Pointer to the AMPL_ERRORINFO struct.