Last chance! 50% off unlimited learning
Sale ends in
This class represents an optimization variable.
Variable(rows = NULL, cols = NULL, name = NA_character_, ...)# S4 method for Variable
as.character(x)
# S4 method for Variable
name(x)
# S4 method for Variable
value(object)
# S4 method for Variable
grad(object)
# S4 method for Variable
variables(object)
# S4 method for Variable
canonicalize(object)
The number of rows in the variable.
The number of columns in the variable.
(Optional) A character string representing the name of the variable.
(Optional) Additional attribute arguments. See Leaf for details.
A Variable object.
name(Variable)
: The name of the variable.
value(Variable)
: Get the value of the variable.
grad(Variable)
: The sub/super-gradient of the variable represented as a sparse matrix.
variables(Variable)
: Returns itself as a variable.
canonicalize(Variable)
: The canonical form of the variable.
dim
The dimensions of the variable.
name
(Optional) A character string representing the name of the variable.
x <- Variable(3, name = "x0") ## 3-int variable
y <- Variable(3, 3, name = "y0") # Matrix variable
as.character(y)
id(y)
is_nonneg(x)
is_nonpos(x)
size(y)
name(y)
value(y) <- matrix(1:9, nrow = 3)
value(y)
grad(y)
variables(y)
canonicalize(y)
Run the code above in your browser using DataLab