AMPL_PARAMETER#
- group AMPL_PARAMETER
Represents an AMPL parameter.
The values are AMPL_VARIANTs. Data can be assigned to the parameter using the functions AMPL_ParameterSetValue() and AMPL_ParameterSetArgsValues() or using AMPL_SetData() and a AMPL_DATAFRAME struct.
Functions
-
AMPL_ERRORINFO *AMPL_ParameterSetValue(AMPL *ampl, const char *scalarExpression, AMPL_VARIANT *v)#
Set the value of a scalar parameter.
- Parameters:
ampl – Pointer to the AMPL struct.
scalarExpression – Name of scalar parameter as string.
v – Pointer to variant to set the value of a scalar parameter to.
- Returns:
Pointer to the AMPL_ERRORINFO struct.
-
AMPL_ERRORINFO *AMPL_ParameterSetNumeric(AMPL *ampl, const char *scalarExpression, double value)#
Set the value of a scalar parameter to numeric value.
- Parameters:
ampl – Pointer to the AMPL struct.
scalarExpression – Name of scalar parameter as string.
value – Double value to set the value of a scalar parameter to.
- Returns:
Pointer to the AMPL_ERRORINFO struct.
-
AMPL_ERRORINFO *AMPL_ParameterSetString(AMPL *ampl, const char *scalarExpression, const char *value)#
Set the value of a scalar parameter to string value.
- Parameters:
ampl – Pointer to the AMPL struct.
scalarExpression – Name of scalar parameter as string.
value – String value to set the value of a scalar parameter to.
- Returns:
Pointer to the AMPL_ERRORINFO struct.
-
AMPL_ERRORINFO *AMPL_ParameterIsSymbolic(AMPL *ampl, const char *entityname, bool *isSymbolic)#
Returns true if the parameter is declared as symbolic (can store both numerical and string values).
- Parameters:
ampl – Pointer to the AMPL struct.
entityname – Name of parameter as string.
isSymbolic – True if the parameter is symbolic, false otherwise (pointer to bool).
- Returns:
Pointer to the AMPL_ERRORINFO struct.
-
AMPL_ERRORINFO *AMPL_ParameterHasDefault(AMPL *ampl, const char *entityname, bool *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.- Parameters:
ampl – Pointer to the AMPL struct.
entityname – Name of parameter as string.
hasDefault – 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.
- Returns:
Pointer to the AMPL_ERRORINFO struct.
-
AMPL_ERRORINFO *AMPL_ParameterSetArgsDoubleValues(AMPL *ampl, const char *entityname, size_t size, const double *args)#
Assign the specified size double values to this parameter, assigning them to the parameter in the same order as the indices in the entity.
The number of values in the array must be equal to the specified size.
- Parameters:
ampl – Pointer to the AMPL struct.
entityname – Name of parameter as string.
size – Number of values to be assigned.
args – Values to be assigned as doubles.
-
AMPL_ERRORINFO *AMPL_ParameterSetArgsStringValues(AMPL *ampl, const char *entityname, size_t size, const char *const *args)#
Assign the specified size string values to this parameter, assigning them to the parameter in the same order as the indices in the entity.
The number of values in the array must be equal to the specified size.
- Parameters:
ampl – Pointer to the AMPL struct.
entityname – Name of parameter as string.
size – Number of values to be assigned.
args – Values to be assigned as strings.
-
AMPL_ERRORINFO *AMPL_ParameterSetArgsValues(AMPL *ampl, const char *entityname, size_t size, AMPL_ARGS *args)#
Assign the specified size values to this parameter, assigning them to the parameter in the same order as the indices in the entity.
The number of values in the array must be equal to the specified size.
- Parameters:
ampl – Pointer to the AMPL struct.
entityname – Name of parameter as string.
size – Number of values to be assigned.
args – Values to be assigned as AMPL_ARGS pointer.
-
AMPL_ERRORINFO *AMPL_ParameterSetValuesMatrix(AMPL *ampl, const char *entityname, size_t nrows, AMPL_ARGS *row_indices, size_t ncols, AMPL_ARGS *col_indices, const double *data, bool transpose)#
Assign the specified values to a 2-d parameter, using the two dimensions as two indices.
For example, the \(m \times n\) matrix:
\[\begin{split}`A = \left( \begin{array}{cccc} a_{11} & a_{12} & ... & a_{1n} \\ a_{21} & a_{22} & ... & a_{2n} \\ ... & ... & ... & ... \\ a_{ m1} & a_{m2} & ... & a_{mn} \end{array} \right)`\end{split}\]can be assigned to the AMPL parameter:
param A {1..m, 1..n};with the statementsetValues(A, false).As an example, to assign the matrix:
\[\begin{split}`A = \left( \begin{array}{cccc} 11 & 12 \\ 21 & 22 \\ 31 & 32 \end{array} \right)`\end{split}\]to the AMPL paramater:
param A{1..3, 1..2};we can use the following code:ampl.eval("param a{1..3, 1..2};"); Parameter a = ampl.getParameter("a"); double values[6]; double rows[3]; double cols[2]; for (int i = 0; i < 3; i++) { rows[i] = i + 1; for (int j = 0; j < 2; j++) values[i * 2 + j] = (i + 1) * 10 + (j + 1); } for (int i = 0; i < 2; i++) cols[i] = i + 1; a.setValues(3, rows, 2, cols, values, false);
- Parameters:
ampl – Pointer to the AMPL struct.
entityname – Name of the parameter.
nrows – Number of rows.
row_indices – Indices of the rows as AMPL_ARGS pointer.
ncols – Number of columns.
col_indices – Indices of the columns as AMPL_ARGS pointer.
data – Values to be assigned.
transpose – True to transpose the values in the matrix.
-
AMPL_ERRORINFO *AMPL_ParameterSetSomeValues(AMPL *ampl, const char *entityname, size_t size, AMPL_TUPLE **index, AMPL_VARIANT **v)#
Assign the values (string or double) to the parameter instances with the specified indices, equivalent to the AMPL code:
let {i in indices} par[i] := values[i];
- Parameters:
ampl – Pointer to the AMPL struct.
entityname – Name of the parameter.
size – Number of instances to be set.
index – An array of indices of the instances to be set.
v – Array of values to be assigned to the instances.
- Returns:
Pointer to the AMPL_ERRORINFO struct.
-
AMPL_ERRORINFO *AMPL_ParameterSetSomeArgsValues(AMPL *ampl, const char *entityname, size_t size, AMPL_TUPLE **index, AMPL_ARGS *args)#
Assign the values (string or double) to the parameter instances with the specified indices, equivalent to the AMPL code:
let {i in indices} par[i] := values[i];
- Parameters:
ampl – Pointer to the AMPL struct.
entityname – Name of the parameter.
size – Number of instances to be set.
index – An array of indices of the instances to be set.
args – Values to be assigned to the instances.
- Returns:
Pointer to the AMPL_ERRORINFO struct.
-
AMPL_ERRORINFO *AMPL_ParameterSetSomeStringValues(AMPL *ampl, const char *entityname, size_t size, AMPL_TUPLE **index, char **str_values)#
Assign the string values to the parameter instances with the specified indices, equivalent to the AMPL code:
let {i in indices} par[i] := values[i];
- Parameters:
ampl – Pointer to the AMPL struct.
entityname – Name of the parameter.
size – Number of instances to be set.
index – An array of indices of the instances to be set.
str_values – String values to be assigned to the instances.
- Returns:
Pointer to the AMPL_ERRORINFO struct.
-
AMPL_ERRORINFO *AMPL_ParameterSetSomeDoubleValues(AMPL *ampl, const char *entityname, size_t size, AMPL_TUPLE **index, double *dbl_values)#
Assign the double values to the parameter instances with the specified indices, equivalent to the AMPL code:
let {i in indices} par[i] := values[i];
- Parameters:
ampl – Pointer to the AMPL struct.
entityname – Name of the parameter.
size – Number of instances to be set.
index – An array of indices of the instances to be set.
dbl_values – String values to be assigned to the instances.
- Returns:
Pointer to the AMPL_ERRORINFO struct.
-
AMPL_ERRORINFO *AMPL_ParameterGetValue(AMPL *ampl, const char *entityname, AMPL_VARIANT **variant)#
Get the value of this parameter.
- Parameters:
ampl – Pointer to the AMPL struct.
entityname – Name of parameter as string.
variant – Pointer to the value to set the parameter instance to.
- Returns:
Pointer to the AMPL_ERRORINFO struct.
-
AMPL_ERRORINFO *AMPL_ParameterSetValue(AMPL *ampl, const char *scalarExpression, AMPL_VARIANT *v)#