14.2.30 Class Parameter

mosek.fusion.Parameter

The parameter class defines a parameter belonging to a specific model. A parameter is a placeholder for a constant (of any shape) whose value can be changed at any point in the life of the model. The Parameter object is not created directly, but through the factory methods Model.Parameter.

Implements

Expression

Members

Expression.Eval – Evaluate the expression and push the result onto the work stack.

Expression.Index – Get a single element in the expression.

Expression.ToString – Return a string representation of the expression object.

Parameter.AsExpr – Convert parameter to an expression

Parameter.GetNumNonzero – Get number of non-zero elements in the parameter. This means the number of elements in the sparsity pattern - not the number of numeric non-zeros.

Parameter.GetSize – Get the total number of elements in the parameter

Parameter.GetValue – Get the current parameter values.

Parameter.IsSparse – Return whether the parameter has a sparsity pattern.

Parameter.Pick – Pick a number of elements from the expression.

Parameter.Reshape – Reshape the parameter. The new shape must have the same size as the old.

Parameter.SetValue – Set the parameter values.

Parameter.Slice – Take a slice of the parameter.

Parameter.AsExpr
Expression AsExpr()

Convert parameter to an expression

Return

(Expression)

Parameter.GetNumNonzero
int GetNumNonzero()

Get number of non-zero elements in the parameter. This means the number of elements in the sparsity pattern - not the number of numeric non-zeros.

Return

(int)

Parameter.GetSize
long GetSize()

Get the total number of elements in the parameter

Return

(long)

Parameter.GetValue
double[] GetValue()

Get the current parameter values.

Return

(double[])

Parameter.IsSparse
bool IsSparse()

Return whether the parameter has a sparsity pattern.

Return

(bool)

Parameter.Pick
Parameter Pick(int[] idxs)
Parameter Pick(int[,] midxs)

Picks a number of elements from the expression and returns them as a one-dimensional expression.

Parameters
  • idxs (int[])

  • midxs (int[,])

Return

(Parameter)

Parameter.Reshape
Parameter Reshape(int[] dims)

Reshape the parameter. The new shape must have the same size as the old.

Parameters

dims (int[]) – The new shape

Return

(Parameter)

Parameter.SetValue
void SetValue(double value)
void SetValue(double[] values)
void SetValue(double[,] values2)

Sets the value of this parameter.

The number of input values must match the size of the shape of the parameter. If the parameter is sparse, values on zero-positions are simply ignored.

Parameters
  • value (double) – Set all parameter elements to this value.

  • values (double[]) – Set parameter elements to these values. The length of the array must match the size of the parameter. This form is valid no matter the shape of the parameter.

  • values2 (double[,]) – Set parameter elements to these values. The shape must exactly match the shape of the two-dimensional parameter.

Parameter.Slice
Parameter Slice(int start, int stop)
Parameter Slice(int[] astart, int[] astop)

Take a slice of the parameter.

Parameters
  • start (int) – The first index in a one-dimensional parameter.

  • stop (int) – The last-plus-one index in a one-dimensional parameter.

  • astart (int[]) – The first index in the parameter.

  • astop (int[]) – The last-plus-one index in the parameter.

Return

(Parameter)