AMPL_VARIANT#

group AMPL_VARIANT

The struct can represent a string or a double number, and maps directly to the underlying AMPL type system.

Typedefs

typedef struct AMPL_Variant AMPL_VARIANT#

An AMPL variant.

Functions

int AMPL_VariantCreateEmpty(AMPL_VARIANT **variant)#

Allocates an empty AMPL_DATAFRAME struct.

Parameters:
  • variant – Pointer to the pointer of the AMPL_VARIANT struct.

Returns:

0 iff successful.

int AMPL_VariantCreateNumeric(AMPL_VARIANT **variant, double value)#

Allocates a numeric AMPL_VARIANT struct.

Parameters:
  • variant – Pointer to the pointer of the AMPL_VARIANT struct.

  • value – Numeric value.

Returns:

0 iff successful.

int AMPL_VariantCreateString(AMPL_VARIANT **variant, const char *cstr)#

Allocates a string AMPL_VARIANT struct.

Parameters:
  • variant – Pointer to the pointer of the AMPL_VARIANT struct.

  • cstr – String value.

Returns:

0 iff successful.

int AMPL_VariantCopy(AMPL_VARIANT **variant, AMPL_VARIANT *copy)#

Allocates a copy of an AMPL_VARIANT struct.

Parameters:
Returns:

0 iff successful.

int AMPL_VariantFree(AMPL_VARIANT **variant)#

Frees the AMPL_VARIANT struct.

Parameters:
  • variant – Pointer to the pointer of the AMPL_VARIANT struct.

Returns:

0 iff successful.

int AMPL_VariantCompare(AMPL_VARIANT *v1, AMPL_VARIANT *v2)#

Compares two AMPL_VARIANT structs.

Parameters:
Returns:

0 iff successful.

int AMPL_VariantGetNumericValue(AMPL_VARIANT *variant, double *value)#

Get the numeric value of an AMPL_VARIANT struct.

Parameters:
  • variant – Pointer to the AMPL_VARIANT struct.

  • value – Pointer to the numeric value.

Returns:

0 iff successful.

int AMPL_VariantGetStringValue(AMPL_VARIANT *variant, char **value)#

Get the string value of an AMPL_VARIANT struct.

Parameters:
  • variant – Pointer to the AMPL_VARIANT struct.

  • value – Pointer to the string value.

Returns:

0 iff successful.

int AMPL_VariantGetType(AMPL_VARIANT *variant, AMPL_TYPE *type)#

Get the type of an AMPL_VARIANT struct.

Parameters:
  • variant – Pointer to the AMPL_VARIANT struct.

  • type – Pointer to the type.

Returns:

0 iff successful.

int AMPL_VariantFormat(AMPL_VARIANT *variant, char **cstr)#

Get the string representation of an AMPL_VARIANT struct.

Parameters:
  • variant – Pointer to the AMPL_VARIANT struct.

  • cstr – Pointer to the string representation.

Returns:

0 iff successful.

AMPL_TYPE#

group AMPL_TYPE

This enumeration represents the basic value types supported by the AMPL C API.

It mirrors the underlying AMPL type system and is used to describe the runtime type of scalar values returned by the API (for example, option values, parameter values, or expression results).

The enum distinguishes between numeric values, string values, and the absence of a value.

Enums

enum AMPL_TYPE#

Values:

enumerator AMPL_EMPTY#

No value is present.

This is typically used to indicate an uninitialized value or an empty result.

enumerator AMPL_NUMERIC#

A numeric value represented as a double-precision floating point number.

enumerator AMPL_STRING#

A string value represented as a null-terminated UTF-8 string.