Parameter#
- class ampl.Entities.Parameter : ampl.Entities.Entity<K>#
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
andampl.Entities.Parameter.SetValues
directly from objects of this class or usingampl.AMPL.SetData
and aDataFrame
object.Public Functions
- new VariantRef Get (params object[] index)#
- new VariantRef Get (Tuple t = null)
- new IEnumerator<VariantRef> GetEnumerator ()#
- void SetValues (Tuple[] indices, double[] values)#
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];
- Param indices:
an array of indices of the instances to be set
- Param values:
values to set
- void SetValues (Tuple[] indices, string[] values)
- void SetValues (double[] row_indices, double[] col_indices, double[] data, bool transpose)
Assign the specified values to a 2-d parameter, using the two dimensions as two indices.
- Param row_indices:
Indices of the rows
- Param col_indices:
Indices of the columns
- Param data:
Values to be assigned
- Param transpose:
True to transpose the values in the matrix
- void SetValues (string[] row_indices, string[] col_indices, double[] data, bool transpose)
- void SetValues (double[] values)
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.
- Param values:
Values to be assigned
- void SetValues (string[] values)
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.
- Param values:
Values to be assigned
- void Set (ampl.Tuple index, double value)
Set the value of a single instance of this parameter.
See operator [] for an alternative way
- Param index:
- Param value:
- void Set (ampl.Tuple index, string value)
- K[] AsArray ()#
- override string ToString ()#
Returns a textual representation of this entity.
- DataFrame GetValues ()#
Get the principal values of this entity as a DataFrame.
The specific returned value depends on the type of entity. For:
Variables and Objectives it returns the suffix
val
Parameters it returns their values
Constraints it returns the suffix
dual
Sets it returns all the members of the set, Note that it does not apply to indexed sets. See
ampl.SetInstance.GetValues
- Return:
A DataFrame containing the values for all instances
- DataFrame GetValues (params string[] suffixes)
Get the specified suffixes value for all instances in a DataFrame.
- Param suffixes:
Suffixes to get
- Return:
A DataFrame containing the specified values
- void SetValues (DataFrame data)
Set the values of this entity to the correponding values of a DataFrame indexed over the same sets(or a subset).
This function assigns the values in the first data column of the passed dataframe to the entity the function is called from. In particular, the statement::
`x.SetValues(y.GetValues());`
is semantically equivalent to the AMPL statement::
`let { s in S } x[s] := y[s];`
- Param data:
The data to set the entity to
Properties
- bool IsSymbolic { get; set; }#
True if the parameter is declared as symbolic (can store both numerical and string values)
- bool HasDefault { get; set; }#
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.
- this[params object[] index { get; set; }#
- string Name { get; set; }#
Get the name of this entity.
- int Indexarity { get; set; }#
Get the indexarity of this entity (sum of the dimensions of the indexing sets).
This value indicates the arity of the tuple to be passed to the method
ampl.Entities.EntityBase.Get
in order to access an instance of this entity. See the following AMPL examples::var x; # indexarity = 0 var y {1..2}; # indexarity = 1 var z {1..2,3..4}; # indexarity = 2 var zz {{ (1, 2)} }; # indexarity = 2
Get the sum of the dimensions of the indexing sets or 0 if the entity is not indexed
- bool IsScalar { get; set; }#
Check whether this entity is scalar.
Equivalent to testing whether indexarity is equal to zero, is true if the entity is scalar (not indexed over any set)
- int NumInstances { get; set; }#
Get the number of instances in this entity.
- string[] IndexingSets { get; set; }#
Get the AMPL string representation of the sets on which this entity is indexed.The obtained vector can be modified without any effect to the entity.
Is equal to the string representation of the indexing sets for this entity or an empty array if the entity is scalar
- string[] XRef { get; set; }#
Get the names of all entities which depend on this one.
ParameterMap#
- class ampl.Entities.ParameterMap : ampl.Entities.EntityMap<ENTITY>#
Enables iterable access to the parameters.