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¶
asExpr() -> Expression
Convert parameter to an expression
- Return
- Parameter.getNumNonzero¶
getNumNonzero() -> int
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¶
getSize() -> int
Get the total number of elements in the parameter
- Return
(
int
)
- Parameter.getValue¶
getValue() -> float[]
Get the current parameter values.
- Return
(
float
[])
- Parameter.isSparse¶
isSparse() -> bool
Return whether the parameter has a sparsity pattern.
- Return
(
bool
)
- Parameter.pick ([])¶
pick(int[] idxs) -> Parameter pick(int[][] midxs) -> Parameter
Picks a number of elements from the expression and returns them as a one-dimensional expression.
The standard Python operator
[]
can also be used for this purpose. See Sec. 14.1.3 (Pythonic extensions) for details.- Parameters
idxs
(int
[])midxs
(int
[][])
- Return
- Parameter.reshape¶
reshape(int[] dims) -> Parameter
Reshape the parameter. The new shape must have the same size as the old.
- Parameters
dims
(int
[]) – The new shape- Return
- Parameter.setValue¶
setValue(float value) setValue(float[] values) setValue(float[][] 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
(float
) – Set all parameter elements to this value.values
(float
[]) – 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
(float
[][]) – Set parameter elements to these values. The shape must exactly match the shape of the two-dimensional parameter.
- Parameter.slice ([])¶
slice(int start, int stop) -> Parameter slice(int[] astart, int[] astop) -> Parameter
Take a slice of the parameter.
The standard Python operator
[]
can also be used for this purpose. See Sec. 14.1.3 (Pythonic extensions) for details.- 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