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
- 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
- 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¶
boolean isSparse()
Return whether the parameter has a sparsity pattern.
- Return
(
boolean
)
- 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.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.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