14.2.27 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.pick
– Pick a number of elements from the expression.Expression.toString
– Return a string representation of the expression object.Parameter.asExpr
– Convert parameter to an expressionParameter.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 parameterParameter.getValue
– Get the current parameter values.Parameter.isSparse
– Return whether the parameter has a sparsity pattern.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: ( Expression
)
-
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.reshape
¶ reshape(int[] dims) -> Parameter
Reshape the parameter. The new shape must have the same size as the old.
Parameters:
(dims
int
[]) – The new shapeReturn: ( Parameter
)
-
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.
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: