Parameter Class¶
Represents an AMPL parameter. The values can be double or string (in case of
symbolic parameters).
Data can be assigned to the parameter using the methods ampl.Entities.Parameter.Set
and ampl.Entities.Parameter.SetValues
directly from objects of this class or using
ampl.AMPL.SetData
and a DataFrame
object.
- Namespace
ampl.Entities
- Assemblies
- AMPL
Inheritance Hierarchy¶
System.Object
ampl.Entities.Entity
ampl.Entities.Entity{ampl.VariantRef}
ampl.Entities.Parameter
Syntax¶
public class Parameter : Entity<VariantRef>, IEnumerable<VariantRef>, IEnumerable
-
class
ampl.Entities.
Parameter
Methods¶
-
Get
(System.Object[])¶ Return type: ampl.VariantRef public VariantRef Get(params object[] index)
-
Get
(ampl.Tuple) Return type: ampl.VariantRef public VariantRef Get(Tuple t = null)
-
GetEnumerator
()¶ Return type: System.Collections.Generic.IEnumerator<System.Collections.Generic.IEnumerator`1>{ampl.VariantRef<ampl.VariantRef>} public IEnumerator<VariantRef> GetEnumerator()
-
Set
(System.Object)¶ Set the value of a scalar parameter.
Arguments: - value (System.Object) – Value to be set to
public void Set(object value)
-
Set
(ampl.Tuple, System.Double) Set the value of a single instance of this parameter. See operator [] for an alternative way
public void Set(Tuple index, double value)
-
Set
(ampl.Tuple, System.String) public void Set(Tuple index, string value)
-
SetValues
(System.Double[])¶ Assign the specified n 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.
Arguments: - values (System.Double<System.Double>[]) – Values to be assigned
public void SetValues(double[] values)
-
SetValues
(System.Double[], System.Double[], System.Double[], System.Boolean) Assign the specified values to a 2-d parameter, using the two dimensions as two indices.
Arguments: - row_indices (System.Double<System.Double>[]) – Indices of the rows
- col_indices (System.Double<System.Double>[]) – Indices of the columns
- data (System.Double<System.Double>[]) – Values to be assigned
- transpose (System.Boolean) – True to transpose the values in the matrix
public void SetValues(double[] row_indices, double[] col_indices, double[] data, bool transpose)
-
SetValues
(System.String[]) Assign the specified n 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.
Arguments: - values (System.String<System.String>[]) – Values to be assigned
public void SetValues(string[] values)
-
SetValues
(System.String[], System.String[], System.Double[], System.Boolean) public void SetValues(string[] row_indices, string[] col_indices, double[] data, bool transpose)
-
SetValues
(ampl.Tuple[], System.Double[]) 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];
Arguments: - indices (ampl.Tuple<ampl.Tuple>[]) – an array of indices of the instances to be set
- values (System.Double<System.Double>[]) – values to set
public void SetValues(Tuple[] indices, double[] values)
-
SetValues
(ampl.Tuple[], System.String[]) public void SetValues(Tuple[] indices, string[] values)
-
Properties¶
-
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
.Note that if the parameter has a default expression which refers to another parameter which value is not defined, this will return true.
Return type: System.Boolean public bool HasDefault { get; }
-
IsSymbolic
()¶ True if the parameter is declared as symbolic (can store both numerical and string values)
Return type: System.Boolean public bool IsSymbolic { get; }
-
ampl.Entities.Parameter.Item[System.Object[]]
Return type: ampl.Variant public Variant this[params object[] index] { get; set; }
-