Learn R Programming

CVXR (version 0.99-7)

Variable-class: The Variable class.

Description

This class represents an optimization variable.

Usage

Variable(rows = 1, cols = 1, name = NA_character_)

# S4 method for Variable as.character(x)

# S4 method for Variable id(object)

# S4 method for Variable is_positive(object)

# S4 method for Variable is_negative(object)

# S4 method for Variable size(object)

# S4 method for Variable get_data(object)

# S4 method for Variable name(object)

# S4 method for Variable value(object)

# S4 method for Variable value(object) <- value

# S4 method for Variable grad(object)

# S4 method for Variable variables(object)

# S4 method for Variable canonicalize(object)

Arguments

rows

The number of rows in the variable.

cols

The number of columns in the variable.

name

(Optional) A character string representing the name of the variable.

x, object

A '>Variable object.

value

The value to assign to the primal variable.

Methods (by generic)

  • id: The unique ID of the variable.

  • is_positive: A logical value indicating whether the variable is positive.

  • is_negative: A logical value indicating whether the variable is negative.

  • size: The c(row, col) dimensions of the variable.

  • get_data: Returns list(rows, cols, name).

  • name: The name of the variable.

  • value: The value of the variable.

  • value<-: Set the value of the primal variable.

  • grad: The sub/super-gradient of the variable represented as a sparse matrix.

  • variables: Returns itself as a variable.

  • canonicalize: The canonical form of the variable.

Slots

id

(Internal) A unique identification number used internally.

rows

The number of rows in the variable.

cols

The number of columns in the variable.

name

(Optional) A character string representing the name of the variable.

primal_value

(Internal) The primal value of the variable stored internally.

Examples

Run this code
# NOT RUN {
x <- Variable(3, name = "x0") ## 3-int variable
y <- Variable(3, 3, name = "y0") # Matrix variable
as.character(y)
id(y)
is_positive(x)
is_negative(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