Parameter#
- class amplpy.Parameter#
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()andset_values()or usingset_data()and an object of classDataFrame.- __getitem__(key, /)#
Return self[key].
- __setitem__(key, value, /)#
Set self[key] to value.
- has_default(self)#
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.
- is_symbolic(self)#
Returns True if the parameter is declared as symbolic (can store both numerical and string values).
- set(self, *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(self, 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
DataFramewith the indices and the values to be set.- Raises:
TypeError: If called on a scalar parameter.
- value(self)#
Get the value of this parameter. Valid only for non-indexed parameters.