Parameter

class amplpy.Parameter(_impl)

Represents an AMPL parameter. The values can be float or string (in case of symbolic parameters).

Data can be assigned to the set using the methods set() and set_values() or using set_data() and an object of class DataFrame.

__init__(_impl)
__setitem__(index, value)
is_symbolic()

Returns True if the parameter is declared as symbolic (can store both numerical and string values).

has_default()

Check if the parameter has a default initial value. In case of the following AMPL code:

param a;
param b default a;

the function will return true for parameter b.

Returns:

True if the parameter has a default initial value. Please note that if the parameter has a default expression which refers to another parameter which value is not defined, this will return True.

value()

Get the value of this parameter. Valid only for non-indexed parameters.

set(*args)

Set the value of a single instance of this parameter.

Args:

args: value if the parameter is scalar, index and value otherwise.

Raises:

RuntimeError: If the entity has been deleted in the underlying AMPL.

TypeError: If the parameter is not scalar and the index is not provided.

set_values(values)

Assign the values (string or float) to the parameter instances with the specified indices, equivalent to the AMPL code:

let {i in indices} par[i] := values[i];
Args:

values: list, dictionary or DataFrame with the indices and the values to be set.

Raises:

TypeError: If called on a scalar parameter.

hasDefault()

Check if the parameter has a default initial value. In case of the following AMPL code:

param a;
param b default a;

the function will return true for parameter b.

Returns:

True if the parameter has a default initial value. Please note that if the parameter has a default expression which refers to another parameter which value is not defined, this will return True.

isSymbolic()

Returns True if the parameter is declared as symbolic (can store both numerical and string values).

setValues(values)

Assign the values (string or float) to the parameter instances with the specified indices, equivalent to the AMPL code:

let {i in indices} par[i] := values[i];
Args:

values: list, dictionary or DataFrame with the indices and the values to be set.

Raises:

TypeError: If called on a scalar parameter.

__module__ = 'amplpy.parameter'